FastDFS 5安装

1.FastDFS最少安装需要三台机器,1台tracker,2台storage,下面将安装基本的FastDFS环境,并增加Nginx模块 
要出发实验室 > FastDFS安装 > FastDFS.png

2.安装之前设置好防火墙,三台机器执行相同操作 

vi /etc/sysconfig/iptables
#增加两条规则:
#对内网开放所有端口
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -s 192.168.10.0/24 -j ACCEPT
编辑完了之后,重启防火墙

3.下载软件包 
最新的FastDFS已经无需依赖libevent,改成依赖 libfastcommon

源码包位置:/data/src

3.1 安装libfastcommon(三台机器相同) 

cd /data/src
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon
./make.sh
./make.sh install
#可参看INSTALL文件 https://github.com/happyfish100/libfastcommon/blob/master/INSTALL
3.2安装FastDFS 

cd /data/src
git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs
./make.sh
./make.sh install

#可参看INSTALL文件 https://github.com/happyfish100/fastdfs/blob/master/INSTALL
4.配置 
4.1配置Tracker服务器(192.168.10.244) 

cp vim /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
mkdir -p /tracker 
vim /etc/fdfs/tracker.conf文件,修改如下内容
base_path=/tracker

然后执行命令 
/sbin/service fdfs_trackerd start

4.2 配置Storage服务器(192.168.10.243,192.168.10.242) 

cp vim /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
mkdir -p /storage 
vim /etc/fdfs/storage.conf
group_name=group1
base_path=/storage
store_path0=/storage
tracker_server=192.168.10.244:22122

然后执行命令 
/sbin/service fdfs_storaged start

4.3 执行测试 
修改Tracker服务器192.168.10.244的配置文件/etc/fdfs/client.conf 

cp vim /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
tracker_server=192.168.10.244:22122
base_path=/storage

执行命令

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /data/src/libfastcommon/INSTALL
如果返回
group1/M00/00/00/wKgBHlQvrQGARrS6AAU9tcFAzok
说明安装成功
5.安装nginx和FastDFS模块 
下载nginx和fastdfs-nginx-module

#nginx 1.8:
cd  /data/src
wget http://nginx.org/download/nginx-1.8.0.tar.gz
#fastdfs-nginx-module:
git clone https://github.com/happyfish100/fastdfs-nginx-module.git
安装:

#基础包
yum -y install gcc automake autoconf libtool make gcc-c++ pcre* zlib openssl openssl-devel
 
#nginx
./configure \
–prefix=/opt/nginx \
–with-http_ssl_module \
–add-module=/data/src/fastdfs-nginx-module/src
 
复制fastdfs-nginx-module源码中的配置文件到/etc/fdfs
cp /data/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
修改该配置文件
group_name=group1
tracker_server=192.168.10.244:22122
store_path0=/storage
base_path=/storage

复制FastDFS的配置到/etc/fdfs
cd /data/src/fastdfs/conf
cp http.conf mime.types /etc/fdfs

重启nginx
———————————————————————————————————— 
nginx(两台storage)配置:
        location ~ /group([0-9])/M00 {
            alias /storage;
            ngx_fastdfs_module;
        }
 
 
负载均衡nginx,为了方便,负载均衡nginx放tracker(192.168.10.244)
    upstream fdfs_group1 {
        server 192.168.10.242:80 weight=1 max_fails=2 fail_timeout=30s;
        server 192.168.10.243:80 weight=1 max_fails=2 fail_timeout=30s;
    }
    location /group1/M00 {
            proxy_next_upstream http_502 http_504 error timeout invalid_header;  
            proxy_cache http-cache;  
            proxy_cache_valid 200 304 12h;  
            proxy_cache_key $uri$is_args$args;  
            proxy_pass http://fdfs_group1;  
            expires 30d;
    }
———————————————————————————————————–
6.监控集群状态 
进入其中一台storage机器,配置好/etc/fdfs/client.conf文件,执行命令:

/usr/bin/fdfs_monitor /etc/fdfs/client.conf

发表评论

邮箱地址不会被公开。 必填项已用*标注