FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储、文件同步、文件访问(文件上传、文件下载)等,解决了大容量存储和负载均衡的问题。特别适合以文件为载体的在线服务,如相册网站、视频网站等等。
FastDFS的安装和使用
(1)安装准备软件
yum install gcc-c++ perl
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
yum install libevent
(2)下载安装包
Nginx-1.5.1
libfastcommon-1.0.38.tar.gz
fastdfs-5.11.tar.gz
fastdfs-nginx-module-1.20.tar.gz
(3)解压nginx安装包
tar -zxvf nginx-1.5.1.tar.gz
(4)创建和tracker和storage目录
mkdir /usr/local/nginx/tracker
mkdir /usr/local/nginx/storage
(5)解压libfastcommon安装包
tar -zxvf libfastcommon-1.0.38.tar.gz
(6)编译并安装libfastcommon
# 进入nginx-1.7.4目录
cd libfastcommon-1.0.38
./make.sh
./make.sh install
(7)解压fastdfs安装包
tar -zxvf fastdfs-5.11.tar.gz
(8)编译并安装fastdfs
# 进入nginx-1.7.4目录
cd fastdfs-5.11
./make.sh
./make.sh install
(9)验证是否安装成功
ll /etc/init.d/ | grep fdfs
# 出现以下内容说明安装成功
-rwxr-xr-x. 1 root root 961 Apr 28 09:59 fdfs_storaged
-rwxr-xr-x. 1 root root 963 Apr 28 09:59 fdfs_trackerd
[root@localhost fastdfs-5.11]# cd /etc/fdfs/
[root@localhost fdfs]# cp tracker.conf.sample tracker.conf
[root@localhost fdfs]# cp storage.conf.sample storage.conf
(10)复制配置文件模板
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
(11)配置fdfs_trackerd
vi /etc/fdfs/tracker.conf
# the base path to store data and log files
base_path=/usr/local/nginx/tracker
(12)启动fdfs_trackerd
service fdfs_trackerd start
ps -ef | grep fdfs_trackerd
(13)设置开机自启动fdfs_trackerd
chkconfig fdfs_trackerd on
(14)配置fdfs_storaged
vi /etc/fdfs/storage.conf
# the base path to store data and log files
base_path=/usr/local/nginx/storage
store_path0=/usr/local/nginx/storage
tracker_server=192.168.0.208:22122
(15)启动fdfs_storaged
service fdfs_storaged start
ps -ef | grep fdfs_storaged
(16)设置开机自启动fdfs_storaged
chkconfig fdfs_storaged on
(17)开放防火墙相关端口
firewall-cmd --add-port=22122/tcp --permanent
firewall-cmd --add-port=23000/tcp --permanent
firewall-cmd --reload
(18)解压fastdfs-nginx-module安装包
tar -xzvf fastdfs-nginx-module-1.20.tar.gz
cd fastdfs-nginx-module-1.20/src
(19)配置fastdfs-nginx-module
vi config
#
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/"
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
(20)配置nginx与FastDFS关联
cp mod_fastdfs.conf /etc/fdfs/
vi /etc/fdfs/mod_fastdfs.conf
# 修改以下内容
connect_timeout=20
tracker_server=192.168.0.208:22122
url_have_group_name=true
store_path0=/usr/local/nginx/storage
(21)拷贝相关配置文件
cd /root/FastDFS/fastdfs-5.11/conf
cp http.conf mime.types /etc/fdfs/
(22)编译nginx
cd /root/nginx-1.16.1
./configure --add-module=/root/FastDFS/fastdfs-nginx-module-1.20/src/
make
make install
(23)配置nginx
vi nginx.conf
# 添加下面的内容
location ~/group([0-9])/ {
ngx_fastdfs_module;
}
(24)重启nginx
./nginx -s stop
./nginx
(25)nginx自启动
chmod 777 /etc/init.d/nginx
chkconfig --add /etc/init.d/nginx
chkconfig nginx on
以上就是极悦小编介绍的"FastDFS安装和使用",希望对大家有帮助,如有疑问,请在线咨询,有专业老师随时为您服务。
你适合学Java吗?4大专业测评方法
代码逻辑 吸收能力 技术学习能力 综合素质
先测评确定适合在学习