Centos7.2 FastDFS_V5.05 集群的安装与配置1

环境: Centos 7.2/64位  两台服务器 都为tracker 和 storage

10.100.0.1  storage tracker
10.100.0.2  storage tracker

1 和 2安装配置类似, 下面以一台为例

1, 安装依赖包,添加fastDFS运行用户

 yum install -y zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip
 useradd -s /sbin/nologin fastdfs



2,创建数据存储目录

mkdir -p /export/fastdfs/{storage,tracker}
[root@localhost src]# ll /export/fastdfs
total 0
drwxr-xr-x 2 root root 6 Dec 10 15:18 storage   #Storage目录保存运行日志及其data数据
drwxr-xr-x 2 root root 6 Dec 10 15:17 tracker   #tracker目录保存运行日志


3,安装libfastcommon
下载最新版本: libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/master.zip
unzip master.zip
cd libfastcommon-master/
./make.sh
./make.sh install


4, 安装Fastdfs
wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/FastDFS%20Server%20with%20PHP%20Extension%20Source%20Code%20V5.05/FastDFS_v5.05.tar.gz/download
tar zxf FastDFS_v5.05.tar.gz && cd FastDFS

./make.sh ./make.sh install
chown -R fastdfs: /export/fastdfs

5, 配置tracker 和 storage 配置文件, 对应修改(配置文件的路径:/etc/fdfs/)
vi storage.conf
group_name=group1
base_path=/export/fastdfs/storage
store_path0=/export/fastdfs/storage
tracker_server=192.168.0.205:22122
tracker_server=192.168.0.206:22122
http.server_port=80

vi tracker.conf
base_path=/export/fastdfs/tracker

vi client.conf tracker_server=192.168.0.205:22122 tracker_server=192.168.0.206:22122

6.安装fastdfs-nginx-module模块

cd /usr/local
wget http://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz/download
tar zxf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src

vi conf   #更改如下, 去掉local,并指定lib64(64系统) CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/" CORE_LIBS="$CORE_LIBS -L/usr/lib64 -lfastcommon -lfdfsclient"

vi mod_fastdfs.conf
group_name=group1
base_path=/export/fastdfs/storage
store_path0=/export/fastdfs/storage
tracker_server=192.168.0.205:22122
tracker_server=192.168.0.206:22122
url_have_group_name = true   #是true 不是ture


并且该文件修改完成以后复制到/etc/fdfs/目录
 
7.安装Nginx
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar zxf nginx-1.8.0.tar.gz 
useradd -s /sbin/nologin www

cd nginx-1.8.0

/configure --user=www --group=www --add-module=/usr/local/fastdfs-nginx-module/src/ --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
make
make install


8.配置Nginx
server {
       listen 80;
       server_name 192.168.0.205;
       root /webdata/fastdfs.com;
       index index.html index.htm;
    location / {
       if (!-e $request_filename) {
          rewrite ^(.*)$ /index.html last;
        }
 
   location /group1/M00 {
            root /export/fastdfs/storage/data/;
            ngx_fastdfs_module;
          }
       }
 
    access_log off;
}

9.开机启动脚本制作
cd /etc/rc.d/init.d
vim fdfs_trackerd(把/usr/local/bin 改成/usr/bin)
vim fdfs_storaged(把/usr/local/bin 改成/usr/bin)


并且
chmod 755 fdfs_trackerd
chmod 755 fdfs_storaged

chkconfig --add fdfs_trackerd(加入开机列表)

chkconfig fdfs_trackerd on (系统启动自动加载)

chkconfig --add fdfs_storaged

chkconfig fdfs_storaged on


10.Nginx启动脚本
cd /etc/rc.d/init.d
vim nginx
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
 
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
 
start() {
        echo -n $"Starting $prog: "
        mkdir -p /dev/shm/nginx_temp
        daemon $NGINX_SBIN -c $NGINX_CONF
        RETVAL=$?
        echo
        return $RETVAL
}
 
stop() {
        echo -n $"Stopping $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -TERM
        rm -rf /dev/shm/nginx_temp
        RETVAL=$?
        echo
        return $RETVAL
}
 
reload(){
        echo -n $"Reloading $prog: "
        killproc -p $NGINX_PID $NGINX_SBIN -HUP
        RETVAL=$?
        echo
        return $RETVAL
}
 
restart(){
        stop
        start
}
 
configtest(){
    $NGINX_SBIN -c $NGINX_CONF -t
    return 0
}
 
case "$1" in
  start)
      start
        ;;
  stop)
        stop
        ;;
  reload)
        reload
        ;;
  restart)
        restart
        ;;
  configtest)
        configtest
        ;;
  *)
        echo $"Usage: $0 {start|stop|reload|restart|configtest}"
        RETVAL=1
esac
exit $RETVAL




chmod 755 /etc/init.d/nginx
chkconfig --add nginx  //加入开机启动列表
chkconfig nginx on     //启动开机启动


10.测试fastdfs是否成功方法:
/usr/bin/fdfs_test /etc/fdfs/client.conf  upload /tmp/busu.txt

浏览器访问方法:http://172.18.112.102/group1/M00/00/00/rBJwZlfiGP2AfgLaAABocDvysUM611_big.png



ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
ln -s /export/fastdfs/storage/data /export/fastdfs/storage/data/M00  (配置文件中stoage存放数据的路径)


11.备注:
进入facdstdfs5.0.5的安装文件夹的conf目录下,将目录下面的http.conf和mime.types拷贝到/etc/fdfs/下,如果不执行这一步,后边在启动nginx时会报错。



posted @ 2016-09-22 21:09  北方乐逍遥  阅读(389)  评论(0编辑  收藏  举报