服务器规划
IP | 服务 |
---|---|
192.168.174.22 | tracker_server1、storage_server1、nginx |
192.168.174 .23 | tracker_server2、storage_server2、nginx |
安装所需软件:
配置主机名
192.168.174.22
hostnamectl set-hostname fdfs22
hostname fdfs22
192.168.174 .23
hostnamectl set-hostname fdfs23
hostname fdfs23
以下操作安装部署操作都是两台服务器都要操作
关闭防火墙及SELINUX:
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i '/^SELINUX=/s/enforcing/disabled/' /etc/selinux/config
root@fdfs22和fdfs23上安装依赖:
yum -y install make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel autoconf
root@fdfs22和fdfs23上安装libfatscommon:
unzip libfastcommon-master.zip
cd libfastcommon-master/
./make.sh
./make.sh install
root@fdfs22和fdfs23上安装FastDFS:
cd ..
tar -zxf FastDFS_v5.08.tar.gz
cd FastDFS/
./make.sh
./make.sh install
root@fdfs22和fdfs23上配置tracker服务器:
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
vi tracker.conf
#修改内容如下:
base_path=/fastdfs/tracker #存储日志和数据的根目录
创建存储日志和数据的根目录:
mkdir -p /fastdfs/tracker
启动tracker服务:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
配置storage服务器:
cp storage.conf.sample storage.conf
vi storage.conf
#修改内容如下:
base_path=/fastdfs/storage #数据和日志文件存储根目录
store_path0=/fastdfs/storage #第一个存储目录
tracker_server=192.168.174.22:22122 #tracker服务器IP和端口
tracker_server=192.168.174.23:22122
创建数据和日志文件存储根目录:
mkdir /fastdfs/storage
启动storage服务:
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
集群信息查看
fdfs_monitor /etc/fdfs/storage.conf
文件上传测试:
cp client.conf.sample client.conf
vi client.conf
#修改内容如下:
base_path=/fastdfs/tracker
tracker_server=192.168.174.22:22122
tracker_server=192.168.174.23:22122
fdfs_upload_file /etc/fdfs/client.conf test.jpeg
tar -zxf fastdfs-nginx-module_v1.16.tar.gz
cd fastdfs-nginx-module/src/
vi config
修改config文件:
把该行的两个“local”去掉
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
修改为:
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
cp /root/fastdfs/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
修改内容如下:
connect_timeout=10
tracker_server=192.168.174.22:22122
tracker_server=192.168.174.23:22122
url_have_group_name = true
store_path0=/fastdfs/storage
拷贝文件
cp /root/fastdfs/FastDFS/conf/mime.types /etc/fdfs/
cp /root/fastdfs/FastDFS/conf/http.conf /etc/fdfs/
安装Nginx
tar -zxf nginx-1.18.0.tar.gz
cd nginx-1.18.0/
./configure --add-module=/root/fastdfs/fastdfs-nginx-module/src/
make && make install
vi /usr/local/nginx/conf/nginx.conf
Nginx.conf添加配置如下:
server {
listen 8888;
server_name localhost;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
测试:
fdfs_upload_file /etc/fdfs/client.conf test.jpeg
fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/wKiuF2F2YDWAEwoqAAHLrivtGMI16.jpeg