1.storage.conf 配置好的tracker的ip才是关联storage和tracker的关键,任意的client只要配置好tracker并且进行上传
上传指令为
[root@localhost bin]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/3.jpg
group1/M00/00/00/wKhVgViapJ6AWYZHAAEVF9BsFgE750.jpg
使用的指令是有关client.conf
所以client tracker storage的关联是
client.conf中会配置tracker的ip和端口,所以会定位到tracker
tracker不做配置
storage.conf会根据配置的tracker的ip和端口,如果有文件通过tracker,有多少台storage配置了这个tracker就会保存到多少台服务器上
2.当建立storage好之后,第一次使用命令
/etc/init.d/fdfs_storaged start
再使用命令
/fastdfs/storage/
查看当前的log和data发现没有data的时候,手动创建一个data就可以了,当然,这个原因目前感觉应该是防火墙的问题,如果不进行设置将直接导致client使用命令上传会报错
错误1
ERROR - file: tracker_proto.c, line: 48, server: 192.168.85.128:22122, response status 2 != 0
tracker_query_storage fail, error no: 2, error info: No such file or directory
查看storage的配置tracker是否正确
双向关闭防火墙(如果可以,永久关闭)
错误2
ERROR - file: ../client/client_func.c, line: 402, load conf file "/etc/fdfs/storage.conf" fail, ret code: 2
双向关闭防火墙(报错类型不同是因为有一个storage没有关闭防火墙,而目前tracker已经关闭防火墙)
$
注:防火墙的基本操作命令:
查询防火墙状态:
[root@localhost ~]# service iptables status
停止防火墙:
[root@localhost ~]# service iptables stop
启动防火墙:
[root@localhost ~]# service iptables start
重启防火墙:
[root@localhost ~]# service iptables restart
永久关闭防火墙:
[root@localhost ~]# chkconfig iptables off
永久关闭后启用:
[root@localhost ~]# chkconfig iptables on
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
3.集成Nginx
需要上传并解压Nginx
1 : wget下载: http://nginx.org/download/nginx-1.4.2.tar.gz
2 : 进行安装: tar -zxvf nginx-1.6.2.tar.gz
3 : 下载锁需要的依赖库文件:
yum install pcre
yum install pcre-devel
yum install zlib
yum install zlib-devel
复制配置文件到fdfs的文件夹
opy命令:cp /usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
修改这个配置文件对应到tracker
4.集群部署
传递指令
scp -r software/ 192.168.85.132:/usr/local/
缺少的指令
scp -r software/ 192.168.85.132:/usr/local/
cp tracker.conf.sample tracker.conf
scp tracker.conf 192.168.85.132:/etc/fdfs/
storage.conf配置
两两一组
disabled=false #启用配置文件
group_name=group1 #组名 第一组为group1 第二组为group2
port=23000 #storage端口号 同一组的端口号必须相同
base_path=/fastdfs/storage
store_path_count=1 #存储路径个数,必须和store_path个数匹配
store_path0=/fastdfs/storage #设置存储路径
tracker_server=192.168.85.131:22122
tracker_server=192.168.85.132:22122
Http.server_port=8888端口号
scp storage.conf 192.168.85.134:/etc/fdfs/
tail -f /fastdfs/storage/logs/storaged.log
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/3.jpg
cd /usr/local/fast/fastdfs-nginx-module/src/
tar -zxvf /usr/local/software/fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/fast/
复制配置文件mod_fastdfs.conf
cd /usr/local/fast/fastdfs-nginx-module/src
cp /usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
需要修改的部分
connect_timeout=10
tracker_server=192.168.85.131:22122
tracker_server=192.168.85.132:22122
storage_server_port=23000
url_have_group_name=true
store_path0=/fastdfs/storage
group_name=group1 #不同组不同
group_count=2
最后加入
[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/fastdfs/storage
[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/fastdfs/storage
5.tracker(nginx)反向代理配置
**************************************
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_cache_path /fastdfs/cache/nginx/proxy_cache levels=1:2;
keys_zone=http-cache:200m max_size=1g inactive=30d;
proxy_temp_path /fastdfs/cache/nginx/proxy_cache/tmp;
upstream fdfs_group1 {
server 192.168.85.133:8888 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.85.134:8888 weight=1 max_fails=2 fail_timeout=30s;
}
upstream fdfs_group2 {
server 192.168.85.135:8888 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.85.136:8888 weight=1 max_fails=2 fail_timeout=30s;
}
server{
listen 8000;
location /group1/M00{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache http-cache;
proxy_cache_vaild 200 304 12h;
proxy_cache_key $uri$is_args$args;
proxy_pass http://fdfs_group1;
expires 30d;
}
location /group2/M00{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_cache http-cache;
proxy_cache_vaild 200 304 12h;
proxy_cache_key $uri$is_args$args;
proxy_pass http://fdfs_group1;
expires 30d;
}
}
tail -f /fastdfs/storage/logs/storaged.log
查看命令
ps -ef | grep fdfs
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf
存储路径
cd /fastdfs/storage/data/