FastDFS安装配置

原创
2013/07/25 13:52
阅读数 1.4W
 
第一步:安装FastDFS
1.解压 FastDFS_v4.07.tar.gz ==>FastDFS
2. cd FastDFS ==>vim make.sh
修改以下内容
TARGET_PREFIX=/usr/local/fdfs
TARGET_CONF_PATH=/usr/local/fdfs/conf
mkdir -p /usr/local/fdfs
mkdir -p /usr/local/fdfs/conf


修改
if [ "$uname" = "Linux" ]; then
    if [ "$WITH_LINUX_SERVICE" = "1" ]; then
      if [ ! -d $TARGET_CONF_PATH ]; then
        mkdir -p $TARGET_CONF_PATH
        cp -f conf/tracker.conf $TARGET_CONF_PATH
        cp -f conf/storage.conf $TARGET_CONF_PATH
        cp -f conf/client.conf $TARGET_CONF_PATH
        cp -f conf/http.conf $TARGET_CONF_PATH
        cp -f conf/mime.types $TARGET_CONF_PATH
      fi


      cp -f init.d/fdfs_trackerd /etc/rc.d/init.d/
      cp -f init.d/fdfs_storaged /etc/rc.d/init.d/
      /sbin/chkconfig --add fdfs_trackerd
      /sbin/chkconfig --add fdfs_storaged
    fi
  fi


第二步:安装libevent-2.0.19-stable.tar.gz
1.解压 libevent-2.0.19-stable.tar.gz==>libevent-2.0.19-stable
2.进入libevent-2.0.19-stable 安装
./configure --prefix=/usr/local/libevent
make
make install


3. 添加软连接
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /lib/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/local/lib64/libevent-2.0.so.5
ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/local/lib/libevent-2.0.so.5


第三步:安装FastDFS
./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib
./make.sh install


第四步:如果/usr/local/fastdfs/conf没有fdfs_trackerd和fdfs_storaged这两个文件,就从 /FastDFS/tracker 和FastDFS/storage/目录下复制过去


第五步:修改配置
mkdir -p /home/softinstall/data/tracker
1. 修改 tracker.conf


base_path=/home/softinstall/data/tracker
bind_addr=192.168.9.169
1.1 修改storage_ids.conf
100001   group1  192.168.9.169
2. 启动tracker
./fdfs_trackerd ../conf/tracker.conf 
查看22122端口是否启动起来


第六步:配置storage
mkdir -p /home/softinstall/data/store
mkdir -p /home/softinstall/data/store/store0
mkdir -p /home/softinstall/data/store/store1
mkdir -p /home/softinstall/data/store/store2
1.修改storage.conf
base_path=/home/softinstall/data/store


store_path_count=3
store_path0=/home/softinstall/data/store/store0
store_path1=/home/softinstall/data/store/store1
store_path2=/home/softinstall/data/store/store2
tracker_server=192.168.9.169:22122
#限6*6=36个目录 默认256*256
subdir_count_per_path=6
2. 启动storage
./fdfs_storaged ../conf/storage.conf 
查看23000端口是否启动


第七步:安装nginx+fastdfs模块
1. 安装pcre-8.32 
进入pcre-8.32
./configure
make
make install
安装如果有问题缺省某些包,可以执行:
yum groupinstall "Development Tools" 


第八步:解压fastdfs-nginx-module_v1.15.tar.gz和 nginx-1.4.2.tar.gz
1.进入 fastdfs-nginx-module_v1.15/src
vim fastdfs-nginx-module_v1.15/src/config
修改成以下内容
ngx_addon_name=ngx_http_fastdfs_module
HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
CORE_INCS="$CORE_INCS /usr/local/fdfs/include/fastdfs /usr/local/fdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/local/fdfs/lib -lfastcommon -lfdfsclient"
CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/usr/local/fdfs/conf/mod_fastdfs.conf\"'"


2. 安装
进入nginx-1.4.2目录
./configure --prefix=/home/softinstall/nginx/nginx-fastdfs-install --with-pcre=/home/softinstall/nginx/pcre-8.32 --add-module=/home/softinstall/nginx/fastdfs-nginx-module/src




安装中如果有问题
可以执行安装以下包:yum -y install gcc gcc-c++ zlib-devel openssl-devel


3.配置nginx.conf
进入nginx-fastdfs-install/conf
vim nginx.conf 配置以下内容
      location /M00 {
root /home/softinstall/data/store/store0/data;
ngx_fastdfs_module;
}


location /M01 {
root /home/softinstall/data/store/store1/data;
ngx_fastdfs_module;
}
location /M02 {
root /home/softinstall/data/store/store2/data;
ngx_fastdfs_module;
}


4.配置mod_fastdfs.conf
mkdir -p /home/softinstall/data/nginx_mod
进入 /usr/local/fdfs/conf目录
vim mod_fastdfs.conf


base_path=/home/softinstall/data/nginx_mod
tracker_server=192.168.9.169:22122
store_path_count=3
store_path0=/home/softinstall/data/store/store0
store_path1=/home/softinstall/data/store/store1
store_path2=/home/softinstall/data/store/store2
5. 启动nginx
进入 /home/softinstall/nginx/nginx-fastdfs-install/sbin
./nginx


如果启动找不到
error while loading shared libraries: libfdfsclient.so: cannot open shared object file: No such file or directory
error while loading shared libraries: libfastcommon.so: cannot open shared object file: No such file or directory
请使用以下软连接
ln -s /usr/local/fdfs/lib/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/local/fdfs/lib/libfastcommon.so /usr/lib64/libfastcommon.so
ln -s /usr/local/fdfs/lib/libfdfsclient.so /usr/lib64/libfdfsclient.so
ln -s /usr/local/fdfs/lib/libfdfsclient.so /usr/lib/libfdfsclient.so








==========================fastDHT================================
【第一步:】安装 Berkley DB
【1.】 tar -zxvf db-4.7.25.tar.gz
进入 db-4.7.25/build_unix
../dist/configure --prefix=/usr


【第二步:】安装FastDHT
mkdir -p /usr/local/fdht
mkdir -p /usr/local/fdht/conf
1. tar -zxvf  FastDHT_v1.23.tar.gz
进入 FastDHT_v1.23
vim make.sh
修改
TARGET_PREFIX=/usr/local/fdht
TARGET_CONF_PATH=/usr/local/fdht/conf


if [ "$1" = "install" ]; then
  cd ..
  cp -f restart.sh $TARGET_PREFIX/bin
  cp -f stop.sh $TARGET_PREFIX/bin


  if [ "$uname" = "Linux" ]; then
    if [ "$WITH_LINUX_SERVICE" = "1" ]; then
      if [ ! -d $TARGET_CONF_PATH ]; then
        mkdir -p $TARGET_CONF_PATH
        cp -f conf/fdhtd.conf $TARGET_CONF_PATH
        cp -f conf/fdht_servers.conf $TARGET_CONF_PATH
        cp -f conf/fdht_client.conf $TARGET_CONF_PATH
      fi


      cp -f init.d/fdhtd /etc/rc.d/init.d/
      /sbin/chkconfig --add fdhtd
    fi
  fi
fi


【2.】 安装
./make.sh
------------------------------------------------------------------------------
如果出现 global.h:18:19: error: event.h: No such file or directory
进入/home/softinstall/fastdfs/libevent-2.0.19-stable然后执行
./configure --prefix=/usr
make
make install
---------------------------------------------------------------------------------
./make.sh install


【3.】 配置fdht
【3.1】 vim /usr/local/fdht/conf/fdhtd.conf
port=11411
bash_path=/home/softinstall/data/fastdht
cache_size = 32MB
store_sub_keys=true
use_storage_id=true
#include /usr/local/fdht/conf/fdht_servers.conf (本行前有#表示打开,如果想关闭此选项,则应该为##开头)
 
【3.2】 vim /usr/local/fdht/conf/fdht_server.conf
group_count = 1
group0 = 192.168.9.165:11411


【3.3】 vim /usr/local/fdht/conf/fdht_client.conf
keep_alive=1 (本选项关联 storaged.conf文件)
base_path=/home/softinstall/data/fastdht
#include /usr/local/fdht/conf/fdht_servers.conf


【3.4】 配置FastDFS 的 storaged.conf文件
vi storaged.conf (默认位置: /usr/local/fdfs/conf/storaged.conf)
check_file_duplicate=1
本配置项解释: 是否检测上传文件已经存在。如果已经存在,则不存在文件内容,建立一个索引链接以节省磁盘空间
key_namespace=FastDFS
本配置项解释: 当上个参数设定为1时 , 在FastDHT中的命名空间
keep_alive=1
本配置项解释: 长连接配置选项,如果为0则为短连接 1为长连接
#include /usr/local/fdht/conf/fdht_servers.conf
本配置项解释: 可以通过 #include filename 方式来加载 FastDHT servers 的配置
 
【3.5】 
===========================总体启动流程======================================
   
   启动tracker    /usr/local/fdfs/bin/fdfs_trackerd /usr/local/fdfs/conf/tracker.conf 
   停止tracker    /usr/local/fdfs/bin/stop.sh /usr/local/fdfs/conf/tracker.conf 


   启动storage   /usr/local/fdfs/bin/fdfs_storaged /usr/local/fdfs/conf/storage.conf 
   停止storage   /usr/local/fdfs/bin/stop.sh /usr/local/fdfs/conf/storage.conf 


   启动nginx    /home/softinstall/nginx/nginx-fastdfs-install/sbin/nginx




启动
/usr/local/fdht/bin/fdhtd /usr/local/fdht/conf/fdhtd.conf
停止
/usr/local/fdht/bin/stop.sh  /usr/local/fdht/conf/fdhtd.conf


测试 是否有错误:
/usr/local/fdht/bin/fdht_test /usr/local/fdht/conf/fdht_client.conf
=================================================================
展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
21 收藏
2
分享
返回顶部
顶部