Centos7单节点快速安装fastdfs
针对 CentOS 7的环境,这是 FastDFS 的部署步骤:
-
安装所需的依赖
在安装 FastDFS 之前,确保已经安装了以下软件包:
sudo yum update -y sudo yum install -y gcc make git
-
安装 libfastcommon
tar -zxvf libfastcommonV1.0.7.tar.gz cd libfastcommon-1.0.7/ ./make.sh sudo ./make.sh install
-
安装 FastDFS
tar -zxvf FastDFS_v5.05.tar.gz cd FastDFS/ ./make.sh sudo ./make.sh install
-
配置 FastDFS
-
修改 Tracker 的配置:
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
在
/etc/fdfs/tracker.conf
里面,主要修改以下内容:base_path=/data/fastdfs/tracker http.server_port=80
确保 base_path 所指的目录存在并有适当的权限。
-
修改 Storage 的配置:
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
在
/etc/fdfs/storage.conf
里面,主要修改以下内容:base_path=/data/fastdfs/storage store_path0=/data/fastdfs/storage_data tracker_server=[YOUR_SERVER_IP]:22122 http.server_port=80
同样,确保目录存在并有适当的权限。注意这里YOUR_SERVER_IP不可以写127.0.0.1
-
-
启动 FastDFS
-
启动 Tracker:
sudo fdfs_trackerd /etc/fdfs/tracker.conf
-
启动 Storage:
sudo fdfs_storaged /etc/fdfs/storage.conf
-
-
设置开机自启
-
为 Tracker 创建 systemd 服务文件:
sudo nano /usr/lib/systemd/system/fdfs_trackerd.service
并添加以下内容:
[Unit] Description=FastDFS Tracker Server After=network.target [Service] ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop Restart=on-failure RestartSec=10s [Install] WantedBy=multi-user.target
-
为 Storage 创建 systemd 服务文件:
sudo nano /usr/lib/systemd/system/fdfs_storaged.service
并添加以下内容:
[Unit] Description=FastDFS Storage Server After=network.target [Service] ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop Restart=on-failure RestartSec=10s [Install] WantedBy=multi-user.target
-
使 systemd 重新加载配置并设置自启动:
sudo systemctl daemon-reload sudo systemctl enable fdfs_trackerd sudo systemctl enable fdfs_storaged
-
完成以上步骤后,FastDFS 应该已经成功部署在您的 CentOS 7.8 服务器上,并设置为开机自启动。当然,实际部署中,还可能需要进行一些额外的网络或防火墙配置,确保 FastDFS 服务可以被外部访问。