专注Java教育14年 全国咨询/投诉热线:444-1124-454
赢咖4LOGO图
始于2009,口口相传的Java黄埔军校
首页 hot资讯 FastDFS安装配置详解

FastDFS安装配置详解

更新时间:2021-12-13 11:01:24 来源:赢咖4 浏览1718次

安装 libfastcommon 依赖环境

tar - zxvf libfastcommon.tar.gz
cd libfastcommon - 1.0 . 7 / 
。/ make.sh
. / make.sh安装
cp /usr/lib64/libfastcommon.so /usr/lib

安装 FastDFS

tar -zxvf FastDFS_v5. 05 .tar.gz
cd FastDFS / 
. / make.sh
. / make.sh安装

启动跟踪器

安装tracker,因为tracker运行程序是fasfdfs,可以直接用配置文件运行

cd / etc / fdfs
cp tracker.conf.sample tracker.conf
cp storage.conf.sample storage.conf
vi tracker.conf
修改以下数据
 # Tracker Data和日志目录地址(此目录必须存在,子目录会自动创建)
base_path =/opt/fastdfs/跟踪器
 # HTTP 服务端口
http.server_port = 80
 创建上面的目录
mkdir /opt/fastdfs/跟踪器
 启动 
systemctl start fdfs_trackerd设置启动chkconfig fdfs_trackerd on

开始错误记录:

[ root@ VM_176_134_centos fdfs] # systemctl start fdfs_trackerd
工作的fdfs_trackerd.service失败,因为控制过程,错误代码退出。请参见“ systemctl状态fdfs_trackerd.service ”和“ journalctl -xe ” 的详细信息。
[ root @ VM _176_134_centos fdfs] # journalctl - xe
12月的28  12:02:22 VM_176_134_centos systemd [ 1 ]:fdfs_trackerd.service:控制处理退出,代码=退出状态= 2 
12月的28  12:02:22 VM_176_134_centos systemd [ 1 ]:未能启动LSB:FastDFS跟踪服务器。
-主题:单位fdfs_trackerd.service失败
- Defined-者:systemd
 -支持:HTTP:// lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
--单元 fdfs_trackerd.service 失败。
——
-结果是失败。
12月的28  12:02:22 VM_176_134_centos systemd [ 1 ]:单位fdfs_trackerd.service进入故障状态。
12月的28  12:02:22 VM_176_134_centos systemd [ 1 ]:fdfs_trackerd.service失败。
12月的28  12:02:22 VM_176_134_centos polkitd [ 1584 ]:未注册验证代理用于UNIX的过程:3685:66989990(系统总线名称:1.25092,对象路径/组织/的freedesktop / PolicyKit1 / AuthenticationA
12月的28  12:02:40 VM_176_134_centos sshd的[ 3703 ]:无效用户UBNT从 206.189。225.113 
12月的28  12:02:40 VM_176_134_centos sshd的[ 3703 ]:input_userauth_request:无效用户UBNT [预认证]
12月的28  12:02:40 VM_176_134_centos sshd的[ 3703 ]:了pam_unix(sshd的:AUTH):检查通; 用户未知
12月的28  12:02:40 VM_176_134_centos sshd的[ 3703 ]:了pam_unix(sshd的:AUTH):认证失败; 日志名= uid= 0 euid= 0 tty=ssh ruser = rhost = 206.189。225.113 
12月的28  12:02:42 VM_176_134_centos sshd的[ 3703 ]:无法密码为无效的用户UBNT从 206.189。225.113端口36530 ssh2
12月的28  12:02:42 VM_176_134_centos sshd的[ 3703 ]:收到断开从 206.189。225.113 : 11 : 再见 [preauth]
12月的28  12:02:51 VM_176_134_centos sshd的[ 3712 ]:无效用户管理从 206.189。225.113 
12月的28  12:02:51 VM_176_134_centos sshd的[ 3712 ]:input_userauth_request:无效的用户管理[预认证]
12月的28  12:02:51 VM_176_134_centos sshd的[ 3712 ]:了pam_unix(sshd的:AUTH):检查通; 用户未知
12月的28  12:02:51 VM_176_134_centos sshd的[ 3712 ]:了pam_unix(sshd的:AUTH):认证失败; 日志名= uid= 0 euid= 0 tty=ssh ruser = rhost = 206.189。225.113 
12月的28  12:02:52 VM_176_134_centos sshd的[ 3712 ]:无法密码为无效的用户管理从 206.189。225.113端口43716 ssh2
12月的28  12:02:52 VM_176_134_centos sshd的[ 3712 ]:连接关闭由206.189。225.113 [预认证]
12月的28  12:03:01 VM_176_134_centos systemd [ 1 ]:开始会话12492用户根。
-主题:单位会话级12492 .scope已完成投入运行起来
- Defined-者:systemd
 -支持:HTTP:// lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- 单元会话- 12492 .scope 已完成启动。
——
-该启动结果被完成。
12月的28  12:03:01 VM_176_134_centos crond的[ 3730 ]:(根)CMD(/usr/local/qcloud/stargate/admin/start.sh>的/ dev /空 2 >&1&)
12月的28  12:03:10 VM_176_134_centos sshd的[ 3750 ]:无效用户EO从 106.37。75.74 
12月的28  12:03:10 VM_176_134_centos sshd的[ 3750 ]:input_userauth_request:无效用户EO [预认证]
12月的28  12:03:10 VM_176_134_centos sshd的[ 3750 ]:了pam_unix(sshd的:AUTH):检查通; 用户未知
12月的28  12:03:10 VM_176_134_centos sshd的[ 3750 ]:了pam_unix(sshd的:AUTH):认证失败; 日志名= uid= 0 euid= 0 tty=ssh ruser= rhost = 106.37。75.74 
12月的28  12:03:12 VM_176_134_centos sshd的[ 3750 ]:无法密码为无效的用户EO从 106.37。75.74端口56156 ssh2
12月的28  12:03:12 VM_176_134_centos sshd的[ 3750 ]:收到断开从 106.37。75.74 : 11 : 再见 [preauth]
 查看代码

解析记录:

可以发现上面的错误日志文件/usr/local/bin/fdfs_trackerd不存在!
 查找:查找/-名称fdfs_trackerd
 得到答案: 
/etc/rc.d/init.d/ fdfs_trackerd
的/ usr /斌/ fdfs_trackerd
 /root/FastDFS/init.d/ fdfs_trackerd
 /根/ FastDFS器/跟踪器/ fdfs_trackerd
 查看trackerd.conf,这个路径没有指定,是不是在环境变量里?不用管,复制就行了,其他不能的文件也一样
cp /usr/bin/fdfs_trackerd/usr/local/bin/ fdfs_trackerd
cp /usr/bin/stop.sh /usr/local/bin/stop.sh
cp /usr/bin/restart.sh /usr/local/bin/restart.sh
 查看代码

开始存储

由于 storage 和 tracker 运行的是 fastDFS 程序,所以每台服务器都部署了一个 fasfDFS,一台服务器是 tracker,另一台是 storage。到

cd / etc / fdfs
cp storage.conf.sample storage.conf
vi 存储.conf
 修改如下 
base_path =/opt/fastdfs/存储
store_path0 =/opt/fastdfs/文件tracker_server=10.0.0.111:22122
 创建上面的文件夹
mkdir /opt/fastdfs/存储
mkdir /opt/fastdfs/文件
 启动systemctl start fdfs_storaged
设置启动chkconfig fdfs_storaged on

内部文件上传测试

更改目录:cd /etc/fdfs/

复制配置:cp client.conf.sample client.conf

修改配置:vi client.conf

base_path=/opt/fastdfs/client

tracker_server=10.200.67.5:22122

生成文件夹:mkdir /opt/fastdfs/client

生成测试文件:echo hello>>test.txt

上传文件:/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.txt

上传结果:group1/M00/00/00/CshDBVwvEheAMjRsAAAABncc3SA527.txt

[ root@localhost fdfs]#ls
anti - steal.jpg client.conf.sample http.conf mime.types mod_fastdfs.conf storage.conf storage.conf.sample tracker.conf tracker.conf.sample
[ root@localhost fdfs]# cp client.conf.sample client.conf
[ root@localhost fdfs]#vi client.conf
[ root@localhost fdfs]# hello >> test.txt
 - bash: hello: command not found
[ root@localhost fdfs]# echo hello >> test.txt
[ root@localhost fdfs]# /usr/bin/fdfs_upload_file/etc/fdfs/ client.conf test.txt
[ 2019 - 01 - 04  15:57:20 ]错误-文件:../client/client_func.c,线:257,“ /选择/ fastdfs /客户端”可以“吨被访问,误差信息:没有这样的文件或目录
[ root@localhost fdfs]# mkdir /opt/fastdfs/客户端
[ root@localhost fdfs]# /usr/bin/fdfs_upload_file/etc/fdfs/ client.conf test.txt
group1 /M00/ 00 / 00 /CshDBVwvEheAMjRsAAAABncc3SA527.txt

您可以在/opt/fastdfs/file/data/00/00 中找到刚刚上传的文件

[ root@localhost fdfs]#cd/opt/fastdfs/ 
[ root@localhostfastdfs ]#ls
客户端文件存储跟踪器
[ root@localhost fastdfs]# cd 文件/ 
[ root@localhost文件]# ls
数据
[根@本地文件]#CD数据/ 
[根@本地数据]#LS
 00   06   0C   12   18   1E   24   2A   30   36   3C   42   48   4E   54   5A   60   66   6C   72   78   7E   84   8A   90   96   9C A2 A8 AE B4 BA C0 C6 CC D2 D8 DE E4 EA F0 F6 FC
 01   07    0D   13 19   1F   25   2B   31 37   3D   4349   4F   55   5B   61 67   6D   73 79   7F             85   8B   91   97   9D A3 A9 AF B5 BB C1 C7 CD D3 D9 DF E5 EB F1 F7 FD
 02   08   0E   14   1A   20   26   2C   32   38   3E   44   4A   50   56   5C   62   68   6E   74   7A   80   86   8C   92   98   9E A4 AA B0 B6 BC C2 C8 CE D4 DA E0 E6 EC F2 F8 FE
 03   09   0F   15   1B   21   27   2D   33   39   3F   45   4B   51   57   5D   63   69   6F   75   7B   81   87   8D   93  99   9F A5 AB B1 B7 BD C3 C9 CF D5 DB E1 E7 ED F3 F9 FF
 04   0A   10   16   1C   22   28   2E   34   3A   40   46   4C     8E   94   9A A0 A6 EE 4 AC B2 CA D FA 2 D BE C F 4
 05   0B   11 17   1D   23 29   2F   35   3B   41 47   4D   53 59   5F   65   6B   52   58   5E   64   6A   70   76   7C   82   88         71   77   7D   83   89   8F   95   9B A1 A7 AD B3 B9 BF C5 CB D1 D7 DD E3 E9 EF F5 FB
[ root@localhost数据]# cd 0 
00 / 01 / 02 / 03 / 04 / 05 / 06 / 07 / 08 / 09 / 0A/ 0B/ 0C/ 0D/ 0E/ 0F/  
[ root@localhost数据]# cd 00 
[ root@localhost  00 ]# ls
 00   06   0C   12   18   1E   24   2A   30   36   3C   42   48   4E   54   5A   60   66   6C   72   78   7E   84   8A   90   96  图9C A2 A8 AE B4 BA C0 C6 CC D2 D8 DE E4 EA F0 F6 FC
 01   07   0D   13   19   1F   25   2B   31   37   3D   43   49   4F   55   5B   61   67   6D   73   79   7F   85   8B   91   97   9D A3 A9 AF B5 BB C1 C7 CD D3 D9 DF E5 EB F1 F7 FD
 32 38   3E   44   4A   50 56   5C   62 68   6E   74   7A   80 86   8C   02   08   0E   14   1A   20   26   2C          92   98   9E A4 AA B0 B6 BC C2 C8 CE D4 DA E0 E6 EC F2 F8 FE 03   09   0F 15   1B   21   27   2D   33   39   3F   45   4B   51   57   5D   63   69    6F   75   7B   81 87   8D   93 99  BD B D 317 E6 E6 C F8
 03 09 0F   19 ED F3 F9 FF
 04   0A   10 16   1C   22 28   2E   34   3A   40 46   4C   52 58   5E   64   6A   70 76   7C   82                88   8E   94   9A A0 A6 AC B2 B8 BE C4 CA D0 D6 DC E2 E8 EE F4 FA
 05   0B   11   17   1D   23   29   2F     6B   71 35   3B   41   47   4D   53   59   5F   65   77   7D   83   89   8F   95   9B A1 A7 AD B3 B9 BF C5 CB D1 D7 DD E3 E9 EF F5 FB
[根@本地主机  00 ]# cd 00 
[ root@localhost  00 ]# ls
CshDBVwvEheAMjRsAAAABncc3SA527.txt
[ root@localhost  00 ]# pwd
 /opt/fastdfs/file/data/ 00 / 00

理论上只要通过nginx映射这个路径就可以了,不需要安装modules

换句话说,nignx.conf 将以下代码添加到服务器:

        位置 /group1/ M00 {
            #ngx_fastdfs_module;
            别名/opt/fastdfs/file/数据;
        }

安装 fastdfs-nginx-module 模块

下载文件:wget https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

这里可能会出现下载文件没有后缀:mv 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

解压:解压5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip

重命名:mv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 fastdfs-nginx-module-master

安装 nginx

上传安装包:放入 E:\yz_index\installPackage\nginx- 1.14。0 .tar.gz
 解压: tar -zxvf nginx- 1.14。0 .tar.gz
 更改目录: cd nginx - 1.14。0
 安装时添加以上模块: ./configure --add-module=../fastdfs-nginx-module-master/src
编译:请安装:make安装启动:在/ usr /本地/ nginx的/ sbin目录/ nginx的设置开机:VIM在/ etc / rc.local中添加一行,内容如下:在/ usr /本地/ nginx的/ sbin目录/ nginx的给权限命令:chmod 755的/ etc / rc.local中查看已安装的模块:在/ usr /本地/ nginx的/ sbin目录/ nginx的-V

切换到fastdfs-nginx-module-master目录

将配置文件复制到fdfs目录下:cp src/mod_fastdfs.conf /etc/fdfs/

复制 fastdfs 并解压一些文件到 /etc/fdfs

cd /root/FastDFS/conf/

cp anti-steal.jpg http.conf mime.types /etc/fdfs/

nginx启用模块

在80端口下添加fastdfs-nginx模块

位置 /group1/ M00 {
    ngx_fastdfs_module;
}

listen 80 的端口值必须与/etc/fdfs/storage.conf 中的http.server_port=80 (之前改为 80 )对应。如果更改为其他端口,则需要在防火墙中统一开放该端口。

提交申请后,顾问老师会电话与您沟通安排学习

免费课程推荐 >>
技术文档推荐 >>