@H_403_1@ 参考:http://blog.csdn.net/xll233xx/article/details/50619170@H_403_1@ http://blog.csdn.net/gaofuqi/article/details/27052155
http://blog.csdn.net/pzw_0612/article/details/52573756@H_403_1@ 启动防火墙@H_403_1@ systemctl start firewalld.service@H_403_1@ CENTOS 7防火墙相关操作:http://www.cnblogs.com/handongyu/p/6260213.html@H_403_1@ 来自:@H_403_1@ http://blog.csdn.net/gaofuqi/article/details/27052155
// 单台机器配置@H_403_1@ 一、在安装FastDFS之前必须先安装libevent,安装libevent步骤如下:@H_403_1@ 1.下载libevent:@H_403_1@ wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz@H_403_1@ 2.解压libevent:@H_403_1@ tar -zxvpf libevent-2.0.21-stable.tar.gz@H_403_1@ 3.进入解压目录:@H_403_1@ cd libevent-2.0.21-stable@H_403_1@ 4.指定安装目录:@H_403_1@ ./configure --prefix=/usr/local/libevent-2.0.21@H_403_1@ 5.安装libevent:@H_403_1@ make@H_403_1@ make install@H_403_1@ 二、安装FastDFS步骤如下:@H_403_1@ 1.下载FastDFS:@H_403_1@ wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
无法下载FASTDFS时可以:
https://code.google.com/archive/p/fastdfs/downloads
@H_403_1@ 2.解压FastDFS:@H_403_1@ tar xvf FastDFS_v4.06.tar.gz@H_403_1@ 3.进入解压目录:@H_403_1@ cd FastDFS@H_403_1@ 4.修改FastDFS的安装文件:@H_403_1@ vi make.sh@H_403_1@ TARGET_PREFIX=/usr/local/FastDFS ---安装路径 @H_403_1@ TARGET_CONF_PATH=/etc/fdfs ---配置文件路径 @H_403_1@ WITH_LINUX_SERVICE=1 ---是否为Linux服务 @H_403_1@ 5.指定libevent的lib目录:@H_403_1@ ./make.sh C_INCLUDE_PATH=/usr/local/libevent-2.0.21/include LIBRARY_PATH=/usr/local/libevent-2.0.21/lib@H_403_1@ 6.安装FastDFS:@H_403_1@ ./make.sh install@H_403_1@ 7.设置软连接(否则编译Nginx时会出错,64位系统 /usr/local/lib64与 32位系统/usr/local/lib的区别)@H_403_1@ ln -sv /usr/local/FastDFS/include/fastcommon /usr/local/include/fastcommon@H_403_1@ ln -sv /usr/local/FastDFS/include/fastdfs /usr/local/include/fastdfs@H_403_1@ ln -sv /usr/local/FastDFS/lib/libfastcommon.so /usr/local/lib/libfastcommon.so@H_403_1@ ln -sv /usr/local/FastDFS/lib/libfastcommon.so.1 /usr/local/lib/libfastcommon.so.1@H_403_1@ ln -sv /usr/local/FastDFS/lib/libfdfsclient.so /usr/local/lib/libfdfsclient.so@H_403_1@ ln -sv /usr/local/FastDFS/lib/libfdfsclient.so.1 /usr/local/lib/libfdfsclient.so.1@H_403_1@ @H_403_1@ 三、在安装Nginx之前,需要安装gcc、 openssl-devel、 pcre-devel和zlib-devel软件库,具体如下:@H_403_1@ yum install gcc-c++@H_403_1@ yum install openssl-devel@H_403_1@ yum install pcre-devel@H_403_1@ yum install zlib-devel@H_403_1@ @H_403_1@ 四、安装Nginx和fastdfs-Nginx-module@H_403_1@ wget http://Nginx.org/download/Nginx-1.6.0.tar.gz@H_403_1@ wget http://fastdfs.googlecode.com/files/fastdfs-Nginx-module_v1.15.tar.gz
/////////////////////////////////////////////////////////////////////////////////////////////////
(fastdfs-Nginx-module,GOOGLE无法下载,可到这里下载:@H_403_1@ https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/)
/////////////////////////////////////////////////////////////////////////////////////////////@H_403_1@ 将安装包文件上传到/usr/local中执行以下操作:@H_403_1@ 1.进入文件目录:@H_403_1@ cd /usr/local@H_403_1@ 2.解压安装包:@H_403_1@ tar -zxv -f Nginx-1.6.0.tar.gz@H_403_1@ tar -xvf fastdfs-Nginx-module_v1.15.tar.gz@H_403_1@ 3.修改安装包目录名称:@H_403_1@ mv Nginx-1.6.0 Nginx@H_403_1@ 4.进入安装包目录:@H_403_1@ cd /usr/local/Nginx@H_403_1@ 5.配置安装目录:@H_403_1@ ./configure --prefix=/usr/local/Nginx --conf-path=/usr/local/Nginx/Nginx.conf --add-module=/usr/local/fastdfs-Nginx-module/src@H_403_1@ 6.安装Nginx:@H_403_1@ make@H_403_1@ make install@H_403_1@ 7.修改防火墙:@H_403_1@ vi + /etc/sysconfig/iptables@H_403_1@ 8.添加配置项@H_403_1@ -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT@H_403_1@ 9.重启防火墙:@H_403_1@ service iptables restart@H_403_1@ 10.将libfastcommon.so、libfastcommon.so.1、libfdfsclient.so、libfdfsclient.so.1复制到/usr/lib,(64位系统 /usr/lib64与 32位系统/usr/lib的区别)@H_403_1@ 否则Nginx启动会报错。@H_403_1@ Nginx的操作:@H_403_1@ 启动:@H_403_1@ /usr/local/Nginx/sbin/Nginx -c /usr/local/Nginx/conf/Nginx.conf@H_403_1@ 或者@H_403_1@ cd /usr/local/Nginx/sbin@H_403_1@ ./Nginx@H_403_1@ @H_403_1@ 停止服务:@H_403_1@ #查询Nginx主进程号@H_403_1@ ps -ef | grep Nginx@H_403_1@ #停止进程@H_403_1@ kill -QUIT 主进程号@H_403_1@ #快速停止@H_403_1@ kill -TERM 主进程号@H_403_1@ #强制停止@H_403_1@ pkill -9 Nginx@H_403_1@ @H_403_1@ 重启:@H_403_1@ /usr/local/Nginx/sbin/Nginx -s reload@H_403_1@ @H_403_1@ 五、配置tracker server:@H_403_1@ 1. vi /etc/fdfs/tracker.conf@H_403_1@ bind_addr=192.168.227.128@H_403_1@ base_path=/home/tracker/fastdfs@H_403_1@ 2.配置防火墙:@H_403_1@ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j@H_403_1@ 3.保存配置:@H_403_1@ /etc/init.d/iptables save@H_403_1@ 4. 启动 tracker@H_403_1@ /usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf@H_403_1@ 在启动时报错:@H_403_1@ /usr/local/bin/fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory@H_403_1@ 执行下面的命令即可正常启动:@H_403_1@ echo '/usr/local/libevent-2.0.21/include/' >> /etc/ld.so.conf@H_403_1@ echo '/usr/local/libevent-2.0.21/lib/' >> /etc/ld.so.conf@H_403_1@ ldconfig@H_403_1@ 5. 查看监听程序:@H_403_1@ netstat -ntpl | grep fdfs@H_403_1@ 6. 查看日志文件:@H_403_1@ cat /home/tracker/fastdfs/logs/trackerd.log@H_403_1@ 7.添加开机启动命令行:@H_403_1@ vim /etc/rc.d/rc.local@H_403_1@ /usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart@H_403_1@ @H_403_1@ 六、配置storage server@H_403_1@ 1. vi /etc/fdfs/storage.conf@H_403_1@ group_name=group1@H_403_1@ bind_addr=192.168.227.130@H_403_1@ base_path=/home/storage/fastdfs@H_403_1@ store_path0=/home/storage/fastdfs@H_403_1@ tracker_server=192.168.227.130:22122@H_403_1@ http.server.port=80@H_403_1@ 2. cp /usr/local/fastdfs-Nginx-module/src/mod_fastdfs.conf /etc/fdfs/@H_403_1@ 3. vi /etc/fdfs/mod_fastdfs.conf@H_403_1@ base_path=/home/storage/fastdfs@H_403_1@ group_name=group1@H_403_1@ store_path0=/home/storage/fastdfs@H_403_1@ tracker_server=192.168.227.128:22122@H_403_1@ url_have_group_name = true@H_403_1@ group_count = 0@H_403_1@ 4. vi /usr/local/Nginx/conf/Nginx.conf@H_403_1@ location /group1/M00 {@H_403_1@ root /home/storage/fastdfs/data; //这里的路径是 六、配置storage server 中的base_path 的子目录@H_403_1@ ngx_fastdfs_module;@H_403_1@ }@H_403_1@ 5.配置防火墙:
// CENTOS 7之前的版本是这样配置,之后的版本配置方法:http://www.cnblogs.com/handongyu/p/6260213.html@H_403_1@ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT
@H_403_1@ 6.保存配置:@H_403_1@ /etc/init.d/iptables save // CENTOS 7之前的版本是这样配置@H_403_1@ 7.启动 storage @H_403_1@ /usr/local/FastDFS/bin/fdfs_storaged /etc/fdfs/storage.conf@H_403_1@ 8. 查看监听程序:@H_403_1@ netstat -ntpl | grep fdfs@H_403_1@ 9. 查看日志文件:@H_403_1@ cat /home/storage/fastdfs/logs/storaged.log@H_403_1@ 10. vim /etc/fdfs/client.conf@H_403_1@ base_path=/home/client/fastdfs@H_403_1@ tracker_server=192.168.153.130:22122
http.tracker_server_port=80 // 这个有必要的话也要修改下,上传之后返回的URL端口
七、测试:@H_403_1@ /usr/local/FastDFS/bin/fdfs_test /etc/fdfs/client.conf upload /etc/passwd@H_403_1@ 结果如下:@H_403_1@ This is FastDFS client test program v4.06@H_403_1@ Copyright (C) 2008,Happy Fish / YuQing@H_403_1@ FastDFS may be copied only under the terms of the GNU General@H_403_1@ Public License V3,which may be found in the FastDFS source kit.@H_403_1@ Please visit the FastDFS Home Page http://www.csource.org/@H_403_1@ for more detail.@H_403_1@ [2014-06-03 20:26:21] DEBUG - base_path=/home/client/fastdfs,connect_timeout=30,network_timeout=60,tracker_server_count=1,anti_steal_token=0,anti_steal_secret_key length=0,use_connection_pool=0,g_connection_pool_max_idle_time=3600s,use_storage_id=0,storage server id count: 0@H_403_1@ tracker_query_storage_store_list_without_group:@H_403_1@ server 1. group_name=,ip_addr=192.168.227.130,port=23000@H_403_1@ group_name=group1,port=23000@H_403_1@ storage_upload_by_filename@H_403_1@ group_name=group1,remote_filename=M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851@H_403_1@ source ip address: 192.168.227.130@H_403_1@ file timestamp=2014-06-03 20:26:21@H_403_1@ file size=1438@H_403_1@ file crc32=218985275@H_403_1@ file url: http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851@H_403_1@ storage_upload_slave_by_filename@H_403_1@ group_name=group1,remote_filename=M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big@H_403_1@ source ip address: 192.168.227.130@H_403_1@ file timestamp=2014-06-03 20:26:21@H_403_1@ file size=1438@H_403_1@ file crc32=218985275@H_403_1@ file url: http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big@H_403_1@ @H_403_1@ 在浏览器上打开http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big@H_403_1@ 测试成功!!!@H_403_1@ // 测试接口
#上传 @H_403_1@ /usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/lily/a.txt @H_403_1@ #下载 @H_403_1@ /usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKiZglauvkmANC2wAAAAPpWmuhI171.txt@H_403_1@ #删除 @H_403_1@ /usr/bin/fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKiZglauvkmANC2wAAAAPpWmuhI171.txt@H_403_1@
@H_403_1@ 参考:http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html@H_403_1@ http://blog.csdn.net/yl_wh/article/details/8784569
@H_403_1@
// 2台机器主从配置@H_403_1@
搭建FastDFS分布式集群环境笔记:https://my.oschina.net/xiejunbo/blog/726192
//2台以上分布式集群配置@H_403_1@
FastDFS分布式文件系统集群安装与配置@H_403_1@
参考:http://www.2cto.com/kf/201611/560911.html