搭建FastDFS分布式文件系统参考下面这篇博客:
分布式:搭建FastDFS分布式文件系统 安装fastdfs-nginx-module
安装fastdfs-nginx-module也是只在storage上进行,先解压fastdfs-nginx-module。
[root@storage 00]# cd /usr/local/FastDFS [root@storage FastDFS]# ll 总用量 1020 drwxr-xr-x. 2 root root 6 1月 9 10:31 client drwxrwxr-x. 12 root root 4096 12月 31 11:18 fastdfs-6.07 -rw-r--r--. 1 root root 809381 1月 8 23:30 fastdfs-6.07.tar.gz -rw-r--r--. 1 root root 19952 1月 8 23:30 fastdfs-nginx-module-1.22.tar.gz drwxrwxr-x. 5 root root 168 1月 8 23:40 libfastcommon-1.0.45 -rw-r--r--. 1 root root 206348 1月 8 23:30 libfastcommon-1.0.45.tar.gz drwxr-xr-x. 4 root root 30 1月 9 09:32 storage_base drwxr-xr-x. 3 root root 18 1月 9 10:34 storage_store drwxr-xr-x. 2 root root 21 1月 9 10:25 test [root@storage FastDFS]# tar -zxvf fastdfs-nginx-module-1.22.tar.gz fastdfs-nginx-module-1.22/ fastdfs-nginx-module-1.22/HISTORY fastdfs-nginx-module-1.22/INSTALL fastdfs-nginx-module-1.22/src/ fastdfs-nginx-module-1.22/src/common.c fastdfs-nginx-module-1.22/src/common.h fastdfs-nginx-module-1.22/src/config fastdfs-nginx-module-1.22/src/mod_fastdfs.conf fastdfs-nginx-module-1.22/src/ngx_http_fastdfs_module.c
修改配置文件config。
[root@storage FastDFS]# cd fastdfs-nginx-module-1.22 [root@storage fastdfs-nginx-module-1.22]# ll 总用量 8 -rw-rw-r--. 1 root root 3036 11月 19 2019 HISTORY -rw-rw-r--. 1 root root 2001 11月 19 2019 INSTALL drwxrwxr-x. 2 root root 109 11月 19 2019 src [root@storage fastdfs-nginx-module-1.22]# cd src [root@storage src]# ll 总用量 84 -rw-rw-r--. 1 root root 43507 11月 19 2019 common.c -rw-rw-r--. 1 root root 3995 11月 19 2019 common.h -rw-rw-r--. 1 root root 848 11月 19 2019 config -rw-rw-r--. 1 root root 3725 11月 19 2019 mod_fastdfs.conf -rw-rw-r--. 1 root root 28668 11月 19 2019 ngx_http_fastdfs_module.c [root@storage src]# vi config
修改如下(就是将两个这路径/usr/local/include都修改成/usr/include):
修改配置文件mod_fastdfs.conf。
[root@storage src]# vi mod_fastdfs.conf
修改base_path,用于存储日志文件。
修改tracker服务地址。
修改组名,与之前的配置保持一致即可,并且将url_have_group_name设置为true,即url中会出现组名。
修改store_path0,设置和storage配置文件中的store_path0一样即可。
创建base_path。
[root@storage src]# mkdir /usr/local/FastDFS/tmp
copy这个配置文件到/etc/fdfs/下供Nginx结合fastdfs-nginx-module访问使用。
[root@storage src]# cp /usr/local/FastDFS/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/安装Nginx
只需要在storage上安装Nginx即可,因为文件都是存储在storage上,Nginx下载地址:
Nginx
下载稳定版(Linux操作系统)。
下载好后,使用Xftp将该压缩文件放到storage虚拟机中。
/usr/local/FastDFS/fastdfs-nginx-module-1.22/src,该路径是有用的,大家也输出一下,不然又得cd过去查。
[root@storage src]# pwd /usr/local/FastDFS/fastdfs-nginx-module-1.22/src [root@storage src]# cd /usr/local [root@storage local]# ll 总用量 1016 drwxr-xr-x. 2 root root 6 4月 11 2018 bin drwxr-xr-x. 2 root root 6 4月 11 2018 etc drwxr-xr-x. 2 root root 6 4月 11 2018 games drwxr-xr-x. 2 root root 6 4月 11 2018 include drwxr-xr-x. 2 root root 6 4月 11 2018 lib drwxr-xr-x. 2 root root 6 4月 11 2018 lib64 drwxr-xr-x. 2 root root 6 4月 11 2018 libexec -rw-r--r--. 1 root root 1039530 1月 7 16:08 nginx-1.18.0.tar.gz drwxr-xr-x. 2 root root 6 4月 11 2018 sbin drwxr-xr-x. 5 root root 49 1月 7 15:44 share drwxr-xr-x. 2 root root 6 4月 11 2018 src [root@storage local]# tar -zxvf nginx-1.18.0.tar.gz编译和安装Nginx
[root@storage local]# cd nginx-1.18.0 [root@storage nginx-1.18.0]# ll 总用量 764 drwxr-xr-x. 6 1001 1001 4096 1月 7 16:24 auto -rw-r--r--. 1 1001 1001 302863 4月 21 2020 CHANGES -rw-r--r--. 1 1001 1001 462213 4月 21 2020 CHANGES.ru drwxr-xr-x. 2 1001 1001 168 1月 7 16:24 conf -rwxr-xr-x. 1 1001 1001 2502 4月 21 2020 configure drwxr-xr-x. 4 1001 1001 72 1月 7 16:24 contrib drwxr-xr-x. 2 1001 1001 40 1月 7 16:24 html -rw-r--r--. 1 1001 1001 1397 4月 21 2020 LICENSE drwxr-xr-x. 2 1001 1001 21 1月 7 16:24 man -rw-r--r--. 1 1001 1001 49 4月 21 2020 README drwxr-xr-x. 9 1001 1001 91 1月 7 16:24 src
先进行配置,使用--add-module选项给Nginx添加module,其实就是将FastDFS(fastdfs-nginx-module)与Nginx进行结合。
[root@storage nginx-1.18.0]# ./configure --add-module=/usr/local/FastDFS/fastdfs-nginx-module-1.22/src
编译与安装。
[root@storage nginx-1.18.0]# make ... [root@storage nginx-1.18.0]# make install修改Nginx配置
[root@storage nginx-1.18.0]# cd /usr/local/nginx/conf [root@storage conf]# ll 总用量 68 -rw-r--r--. 1 root root 1077 1月 9 11:41 fastcgi.conf -rw-r--r--. 1 root root 1077 1月 9 11:41 fastcgi.conf.default -rw-r--r--. 1 root root 1007 1月 9 11:41 fastcgi_params -rw-r--r--. 1 root root 1007 1月 9 11:41 fastcgi_params.default -rw-r--r--. 1 root root 2837 1月 9 11:41 koi-utf -rw-r--r--. 1 root root 2223 1月 9 11:41 koi-win -rw-r--r--. 1 root root 5231 1月 9 11:41 mime.types -rw-r--r--. 1 root root 5231 1月 9 11:41 mime.types.default -rw-r--r--. 1 root root 2656 1月 9 11:41 nginx.conf -rw-r--r--. 1 root root 2656 1月 9 11:41 nginx.conf.default -rw-r--r--. 1 root root 636 1月 9 11:41 scgi_params -rw-r--r--. 1 root root 636 1月 9 11:41 scgi_params.default -rw-r--r--. 1 root root 664 1月 9 11:41 uwsgi_params -rw-r--r--. 1 root root 664 1月 9 11:41 uwsgi_params.default -rw-r--r--. 1 root root 3610 1月 9 11:41 win-utf [root@storage conf]# vi nginx.conf
添加一个serve,如下所示。
server {
listen 8888; ## 该端口要与storage.conf中的http.server_port相同
server_name localhost;
location /kaven1/M00 { ## 组名kaven1和M00是虚拟的路径,所以这里需要配置一下
ngx_fastdfs_module;
}
}
启动Nginx
检查Nginx配置文件是否符合要求,很显然是符合要求的。
[root@storage conf]# cd .. [root@storage nginx]# cd sbin [root@storage sbin]# ./nginx -t ngx_http_fastdfs_set pid=12499 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
启动Nginx,可以看到ngx_http_fastdfs_set进程也启动了。
[root@storage sbin]# ./nginx ngx_http_fastdfs_set pid=12508
现在就可以使用Nginx访问FastDFS上的文件了。
记得加上设置的端口8888。
http://192.168.1.106:8888/kaven1/M00/00/00/wKgBal_5FneAK_TfAAAOi5813CQ7747410
Nginx代理FastDFS实现访问服务就介绍到这里。写博客是博主记录自己的学习过程,如果有错误,请指正,谢谢!



