单机单个tracker多个storage搭建:
1、首先参照之前的文档创建好单机的环境
cd /etc/fdfs/storage.conf
2、复制一份storage.conf并重命名为storage_02.conf
cp -r storage.conf storage_02.conf
3、打开这个新复制的文件然后修改里面的内容
vi storage_02.conf
storage_group0.conf 参数配置
group_name=group1
#根据当前环境制定目录,别和已经存在的storage重复即可
base_path=/usr/local/fastdfs/fdfs_storage_group1
#(重要)存储目录,根据当前环境制定目录,别和已经存在的storage重复即可
store_path0=/usr/local/fastdfs/fdfs_storage_group1
4、启动新配置的storage(先测试是否能正常启动,全部调试好之后,将所有storage,tracker、nginx全部关闭,然后按启动步骤启动,先起tracker,然后storage,再然后nginx)
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
看启动状态 :是否有两个storage线程
ps aux|grep storage
5、nginx配置调整
vi usr/local/nginx/conf/nginx.conf
server {
listen 8888;
server_name 192.168.0.164,;
location /group0/(M00|M01){
root /usr/local/fastdfs/fdfs_storage_group1/data;
ngx_fastdfs_module;
}
6、nginx_tracker总入口配置调整
vi usr/local/nginx_tracker/conf/nginx.conf
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
# 192.168.0.164 storage group1
upstream fdfs_group1 {
server 192.168.0.164:8888 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 8070;
server_name localhost,192.168.0.171;
location / {
root html;
max_ranges 1;
index index.html index.htm;
}
location ~* /group1/(M00|M01) {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://fdfs_group1_164; expires 30d;
}
}
7、按顺序重新启动tracker、 两个storage 、 nginx
启动 tracker 服务:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
重启 tracker 服务:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
查看是否有 tracker 进程:
ps aux | grep tracker
启动 storage 服务:
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf,首次启动会很慢,因为它在创建预设存储文件的目录
重启 storage 服务:
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
查看是否有 storage 进程:
ps aux | grep storage
查看是否注册到tracker里面:
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf