Linux安装Tomcat-Nginx-FastDFS-Redis-Solr-集群——【第十一集之安装FastDFS】

1,安装FastDFS之前,先安装libevent工具包。

            yum -y install libevent

2,安装libfastcommonV1.0.7工具包。有可能找到新版本的zip压缩包:libfastcommon-master.zip

上传到linux后使用unzip命令就能解压。

解压之后有个make.sh的执行文件:执行./make.sh 和 ./make.sh install


如果是新版本的,就不会在/usr中生成lib64的目录,如果是旧版本的就会生成lib64的目录,那么将这个目录中的(/usr/lib64/libfastcommon.so)文件向/usr/lib/下复制一份。

3,上传fastdfs-5.11.tar.gz并安装tracker服务。

        1)解压缩

        2)./make.sh

        3)./make.sh install

            安装后在/usr/bin/目录下有以fdfs开头的文件都是编译出来的。

            配置文件都放到/etc/fdfs文件夹


        4)/root/FastDFS/conf目录下的所有的配置文件都复制到/etc/fdfs下。


        5)配置tracker服务。修改/etc/fdfs/tracker.conf文件。


        6)配置storage服务(安装报错-是fastdfs版本问题,同时注意libfastcommon版本要对

        如果是在不同的服务器安装,第四步的1)到4)需要重新执行。



如果有多个tracker_server,就增加ip


启动tracker/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

重启使用命令:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

启动storage服务。

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart


4,测试服务

配置客户端:



上传图片:

[root@localhost conf]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/apps/fastdfs/fastdfs-5.11/conf/anti-steal.jpg

再此注意将22122开放。/etc/sysconfig/iptables


5,搭建nginx提供http服务

可以使用官方提供的nginx插件。要使用nginx插件需要重新编译。

fastdfs-nginx-module_v1.16.tar.gz

解压插件压缩包

修改/root/fastdfs-nginx-module/src/config文件,把其中的local去掉。


旧版本:




nginx重新config

将以下配置拷贝到编辑器,去掉行间距,否则报:找不到目录的错误。

./configure \

--prefix=/usr/local/nginx \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/temp/nginx/client \

--http-proxy-temp-path=/var/temp/nginx/proxy \

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \

--http-scgi-temp-path=/var/temp/nginx/scgi \

--add-module=/root/apps/fastdfs/fastdfs-nginx-module-master/src

(刚才复制的src路径替换)

make

make install


/root/fastdfs-nginx-module/src/mod_fastdfs.conf文件复制到/etc/fdfs目录下


修改mod_fastdfs.conf,





nginx的配置/usr/local/nginx/conf/nginx.conf

nginx的配置文件中添加一个Server


如果libevent是旧版本会将一些文件生成后放到lib64,这里需要将

libfdfsclient.so放到/usr/lib中,新版本就没有这个问题。


启动nginx(unknown directive "ngx_fastdfs_module"报错:是因为nginx configuremake后没有make install)

注意:https://blog.csdn.net/crazzy0727/article/details/53610888需要将80端口监听才能访问nginx


启动之后查看进程:

ps -aux | grep nginx

发现:没有worker process,说明nginx没有启动成功。

同时在浏览器中输入:192.168.44.41也不能访问nginx。

通过反复查询,看博客。在这篇文章中找到灵感:https://blog.csdn.net/ricciozhang/article/details/49402273


通过查看nginx的日志([root@localhost nginx]# vim /var/log/nginx/error.log )还真发现了



去检查/etc/fdfs/mod_fastdfs.conf,那个tracker的ip没有设置。整了半天啊。

修改后重新加载:sbin/nginx -s reload

然后重新ps -aux | grep nginx


可以啦。在浏览器重新刷新,OKKKKKKKK。

将fastdfs测试的图片链接:http://192.168.44.41/group1/M00/00/00/wKgsKVsmyeGAa214AABdrZgsqUU698_big.jpg访问试试:



猜你喜欢

转载自blog.csdn.net/mark_lirenhe/article/details/80721018
今日推荐