Centos 7下分布式文件系统FastDFS安装教程
2020-02-10 本文已影响0人
天生小包
1、安装libfastcommon
wget https://github.com/happyfish100/libfastcommon/archive/V1.0.38.tar.gz
tar -zxvf V1.0.38.tar.gz
cd libfastcommon-1.0.38
./make.sh & ./make.sh install
注意:可能遇到的问题
-bash: make: command not found
-bash: gcc: command not found
解决方法:
yum -y install gcc make
2、安装FastDFS
//下载安装包
wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz
//解压
tar -zxvf V5.11.tar.gz
cd fastdfs-5.11
//执行编译
./make.sh & ./make.sh install
//执行查看命令
ls -la /usr/bin/fdfs*

3、配置Tracker服务
-
打开/etc/fdfs目录,有三个.sample后缀的文件,通过cp命令拷贝tracker.conf.sample,删除.sample后缀作为正式文件:
image.png
-
编辑tracker.conf:vi tracker.conf,修改相关参数
#tracker存储data和log的跟路径,必须提前创建好 base_path=/home/domain/fastdfs/tracker port=23000 #tracker默认23000 http.server_port=80 #http端口,需要和nginx相同` </pre>
-
启动tracker(支持start|stop|restart):
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
4.查看tracker启动日志
tail -f trackerd.log

5、查看端口情况
netstat -apn|grep fdfs

4、配置Storage服务
1、打开/etc/fdfs目录,有cp命令拷贝storage.conf.sample,删除.sample后缀作为正式文件
vi storage.conf
ase_path=/home/mm/fastdfs/storage #storage存储data和log的跟路径,必须提前创建好
port=23000 #storge默认23000,同一个组的storage端口号必须一致
group_name=group1 #默认组名,根据实际情况修改
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/home/domain/fastdfs/tracker/storage/ #如果为空,则使用base_path
tracker_server=192.168.0.107:22122 #配置该storage监听的tracker的ip和port
2、启动storage(支持start|stop|restart)
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
3、查看启动日志
tail -f storaged.log

4、查看端口情况
netstat -apn|grep fdfs

5、通过monitor来查看storage绑定状态
/usr/bin/fdfs_monitor /etc/fdfs/storage.conf

6、安装Nginx和fastdfs-nginx-module模块
1、下载Nginx安装包
wget http://nginx.org/download/nginx-1.15.2.tar.gz
tar -zxvf nginx-1.15.2.tar.gz
2、下载fastdfs-nginx-module安装包
wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.20.tar.gz
tar -xvf V1.20.tar.gz
3、添加fastdfs-nginx-module模块
#安装依赖
yum install pcre-devel zlib zlib-devel openssl openssl-devel
#添加fastdfs-nginx-module模块
./configure --add-module=/home/domain/fastdfs-nginx-module-1.20/src
#编译安装
make && make install
4、配置 nginx
vim /etc/fdfs/mod_fastdfs.conf
#需要修改的内容如下
tracker_server=192.168.52.1:22122 #tracker服务器IP和端口
url_have_group_name=true
store_path0=/home/dfs
#配置nginx.config
vim /usr/local/nginx/conf/nginx.conf
#添加如下配置
server {
listen 8888; ## 该端口为storage.conf中的http.server_port相同
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
7、FastDFS常用命令
1、打开/etc/fdfs目录,新建client.conf,修改client.conf相关配置:
vi client.conf
##文件内容如下
base_path=/home/domain/fastdfs/tracker //tracker服务器文件路径
tracker_server=192.168.0.107:22122 //tracker服务器IP地址和端口号
http.tracker_server_port=80 # tracker服务器的http端口号,必须和tracker的设置对应起来
2、新建测试文件
vi test.txt
## 内容如下
abcdefg
3、上传文件
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt
#执行后,返回如下信息
group1/M00/00/00/wKgAa15BQNSAEhTAAAAACCwX9Tg929.txt
组名:group1
磁盘:M00
目录:00/00
文件名称:wKgAa15BQNSAEhTAAAAACCwX9Tg929.txt
4、下载文件
/usr/bin/fdfs_download_file /etc/fdfs/client.conf wKgAa15BQNSAEhTAAAAACCwX9Tg929.txt 2.txt
5、删除文件
/usr/bin/fdfs_delete_file /etc/fdfs/client.conf wKgAa15BQNSAEhTAAAAACCwX9Tg929.txt 2.txt