CleverCode在自己的虚拟机中准备搭建一下分布式架构。
1 架构图
2 安装与配置tracker(192.168.101.135:22122)
2.1 安装tracker
安装详解参考:http://blog.csdn.net/clevercode/article/details/52244358。
2.2 配置tracker
a) 首次安装
# vi /etc/fdfs/tracker.conf
base_path=/data0/fastdfs/tracker
# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
# service iptables stop
b)非首次安装
1 停止tracker
# /usr/local/bin/stop.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
2 需要清除tracker缓存配置文件,如果不清除,会报错,同步异常等等,最好清除。
# rm /data0/fastdfs/tracker/* -rf
3 关闭防火墙
# service iptables stop
4 配置
# vi /etc/fdfs/tracker.conf
base_path=/data0/fastdfs/tracker
5 启动
# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
2.3 配置client.conf查看监控,已经有0个storage。
# vi /etc/fdfs/client.conf
base_path=/tmp
tracker_server=192.168.101.135:22122
http.tracker_server_port=80
# # /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
3 安装与配置storage(192.168.101.132:23000)
3.1 安装
安装详解参考:http://blog.csdn.net/clevercode/article/details/52244358。
3.2 配置
a)首次安装
# mkdir -p /data0/fastdfs/storage/storage0
# vi /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=192.168.101.135:22122
# service iptables stop
# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
b)非首次安装
1 关闭storage
# /usr/local/bin/stop.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
2 清除storage缓存配置数据,如果不清除,会报错,同步异常等等,最好清除。
# rm /data0/fastdfs/data -rf
# rm /data0/fastdfs/logs -rf
3 关闭防火墙
# service iptables stop
4 配置文件(storage.conf)
# vi /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=192.168.101.135:22122
5 启动storage
# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
3.3 查看监控,已经有1个storage。
# /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
4 安装与配置storage(192.168.101.133:23000)
4.1 安装
安装详解参考:http://blog.csdn.net/clevercode/article/details/52244358。
4.2 配置
a)首次安装
# mkdir -p /data0/fastdfs/storage/storage0
# vi /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=192.168.101.135:22122
# service iptables stop
# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
b)非首次安装
1 关闭storage
# /usr/local/bin/stop.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
2 清除storage缓存配置数据,如果不清除,会报错,同步异常等等,最好清除。
# rm /data0/fastdfs/data -rf
# rm /data0/fastdfs/logs -rf
3 关闭防火墙
# service iptables stop
4 配置文件(storage.conf)
# vi /etc/fdfs/storage.conf
http.server_port=80
group_name=group1
base_path=/data0/fastdfs
store_path0=/data0/fastdfs/storage/storage0
tracker_server=192.168.101.135:22122
5 启动storage
# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
5.3 查看监控,已经有两个storage。
# /usr/local/bin/fdfs_monitor /etc/fdfs/client.conf
5 测试
5.1 上传测试,可以看到被轮询到132和133两台机器上了。
# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload install.log
5.2 下载,也轮询到了132与133两台机器上。
# /usr/local/bin/fdfs_test /etc/fdfs/client.conf download group1 00/00/wKhlhVe5toqAQbX_AAE2PTXrYOA819.png
6 本次配置文件下载
本次安装配置文件下载:http://download.csdn.net/detail/clevercode/9608861。