nginx|nginx + FastDFS分布式文件服务器搭建及配置
1、安装libevent
Java代码
- yum install libevent
2、下载FastDFS程序包
https://code.google.com/p/fastdfs/downloads/list?q=label:Featured
wget http://fastdfs.googlecode.com/files/FastDFS_v3.05.tar.gz
3、解压安装
Java代码
- tar zxvf FastDFS_v3.05.tar.gz2
- cd FastDFS/
- ./make.sh
- ./make.sh install
4、安装完成后,fastdfs默认的配置文件被放置在/etc/fdfs 目录下面,包含了client.confhttp.confmime.typesstorage.conftracker.conf五个文件,fastdfs进程的启动是以加载的配置文件区分的。源码包中都包含了这三个配置文件。
5、修改tracker.conf 配置文件
base_path=/opt/fdfs
http.server_port=80
启动tracker进程
Java代码
- fdfs_trackerd /etc/fdfs/tracker.conf
检测状态
Java代码
- netstat -tupln|grep tracker
6、修改storage.conf配置文件
base_path=/opt/fdfs
store_path0=/opt/fdfs
tracker_server=192.168.1.103:22122 (IP改为你指定的IP)
http.server_port=80
启动storage进程
Java代码
- fdfs_storaged /etc/fdfs/storage.conf
检测监听
Java代码
- netstat -tupln | grep storage
如果23000被监听说明启动成功
四、安装Nginx和fastdfs-nginx-module
wget http://nginx.org/download/nginx-1.6.0.tar.gz
wget http://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz
将安装包文件上传到/usr/local中执行以下操作:
1.进入文件目录:
cd /usr/local
2.解压安装包:
tar -zxv -f nginx-1.6.0.tar.gz
tar -xvf fastdfs-nginx-module_v1.15.tar.gz
3.修改安装包目录名称:
mv nginx-1.6.0 nginx
4.进入安装包目录:
cd /usr/local/nginx
5.配置安装目录:
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf--add-module=/usr/local/fastdfs-nginx-module/src
6.安装Nginx:
make
make install
五、配置tracker server:
1. vi /etc/fdfs/tracker.conf
bind_addr=192.168.227.128
base_path=/home/tracker/fastdfs
2.配置防火墙:
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j
3.保存配置:
/etc/init.d/iptables save
4. 启动 tracker
/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf
在启动时报错:
/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
执行下面的命令即可正常启动:
echo '/usr/local/libevent-2.0.21/include/' >> /etc/ld.so.conf
echo '/usr/local/libevent-2.0.21/lib/' >> /etc/ld.so.conf
ldconfig
5. 查看监听程序:
netstat -ntpl | grep fdfs
6. 查看日志文件:
cat /home/tracker/fastdfs/logs/trackerd.log
7.添加开机启动命令行:
vim /etc/rc.d/rc.local
/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
六、配置storage server
1. vi /etc/fdfs/storage.conf
group_name=group1
bind_addr=192.168.227.130
base_path=/home/storage/fastdfs
store_path0=/home/storage/fastdfs
tracker_server=192.168.227.130:22122
http.server.port=80
2. cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
3. vi /etc/fdfs/mod_fastdfs.conf
base_path=/home/storage1/fastdfs
group_name=group1
store_path0=/home/stroage1/fastdfs
tracker_server=192.168.227.128:22122
url_have_group_name = true
group_count = 0
【nginx|nginx + FastDFS分布式文件服务器搭建及配置】 4. vi /usr/local/nginx/conf/nginx.conf
location /group1/M00 {
root /home/storage1/fastdfs/data;
ngx_fastdfs_module;
}
推荐阅读
- 深入浅出谈一下有关分布式消息技术(Kafka)
- 监控nginx
- KubeDL HostNetwork(加速分布式训练通信效率)
- Linux|Linux 服务器nginx相关命令
- 实操Redission|实操Redission 分布式服务
- 分布式|《Python3网络爬虫开发实战(第二版)》内容介绍
- Nginx|Nginx Tomcat 构造https服务应对苹果要求
- Nginx详细教程
- Nginx进阶(1)——nginx本地代理配置访问node服务
- linux操作集-配置keepalived+nginx实现双机热备