FastDFS部署之踩坑.

FastDFS部署之踩坑.

开一台新的 centos 虚拟机.

  1. 安装 jdk1.8
yum install java-1.8.0-openjdk*

自己配置环境变量也可以,个人选择.


  1. 安装Nginx所需要的环境.(此案例自己下载nginx,自己编译.)
安装环境可参考【https://www.jianshu.com/p/780a0530ed8f】

  1. 安装libevent
yum -y install libevent

1.png

准备好安装包,并解压(没有包自己去官网下载)=-=.


  1. 安装libfastcommon

将libfastcommonV1.0.7.tar.gz拷贝至/usr/local/下
cd /usr/local
tar -zxvf libfastcommonV1.0.7.tar.gz
cd libfastcommon-1.0.7
./make.sh
./make.sh install

注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下。
要拷贝的文件【libfastcommon.so】

[root@192 lib64]# cp libfastcommon.so ../lib

2.png

  1. tracker编译安装

将FastDFS_v5.05.tar.gz拷贝至/usr/local/下
tar -zxvf FastDFS_v5.05.tar.gz
cd FastDFS
./make.sh
./make.sh install
安装成功将安装目录下的conf下的文件拷贝到/etc/fdfs/下。

3.png

  1. 配置
    6.1进入/etc/fdfs目录
拷贝一份新的tracker配置文件:
cp tracker.conf.sample tracker.conf
修改tracker.conf
vim tracker.conf
base_path=/home/yuqing/fastdfs
改为:
base_path=/home/fastdfs

6.2启动

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

4.png

error 意思就是没有 '/home/fastdfs' 这个目录,那就 mkdir -p 创建一下=。=.
然后在 启动.

5.png

6.3设置开机自动启动

vim /etc/rc.d/rc.loca
将命令添加到文件:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

然后 wq 保存=。=.

  1. FastDFS--storage安装(和 5.tracker编译安装)一模一样,不做解释.

7.1 配置
进入/etc/fdfs目录:

拷贝一份新的storage配置文件:
cp storage.conf.sample storage.conf
修改storage.conf
vim storage.conf
group_name=group1
base_path=/home/yuqing/fastdfs改为:base_path=/home/fastdfs
store_path0=/home/yuqing/fastdfs改为:store_path0=/home/fastdfs/fdfs_storage
#如果有多个挂载磁盘则定义多个store_path,如下
#store_path1=.....
#store_path2=......
tracker_server=192.168.101.3:22122 #配置tracker服务器:IP
#如果有多个则配置多个tracker
tracker_server=192.168.101.4:22122

7.2 启动

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

一样的 写到 【/etc/rc.d/rc.local】里面

vim /etc/rc.d/rc.local
将命令添加到文件:/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
  1. 修改/etc/fdfs/client.conf
vim /etc/fdfs/client.conf
base_path=/home/fastdfs
tracker_server=192.168.101.3:22122

6.png

  1. FastDFS安装成功可通过/usr/bin/fdfs_test测试上传、下载等操作。
使用格式:
/usr/bin/fdfs_test 客户端配置文件地址  upload  上传文件

比如将/root下的图片上传到FastDFS中:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/1.png

7.png


  1. FastDFS 和nginx整合
    一开始Nginx的环境已经安装好了,直接开始编译.

     

    8.png

     

    一个Nginx 一个 Fast模块

10.1 先处理下 fast-nginx-module

11.png

将FastDFS-nginx-module_v1.16.tar.gz传至/usr/local/下
cd /usr/local
tar -zxvf FastDFS-nginx-module_v1.16.tar.gz
cd FastDFS-nginx-module/src
修改config文件将/usr/local/路径改为/usr/

10.png

将FastDFS-nginx-module/src下的mod_fastdfs.conf拷贝至/etc/fdfs/下
cp mod_fastdfs.conf /etc/fdfs/
并修改mod_fastdfs.conf的内容:
vi /etc/fdfs/mod_fastdfs.conf
base_path=/home/fastdfs
tracker_server=192.168.101.3:22122
#tracker_server=192.168.101.4:22122(多个tracker配置多行)
url_have_group_name=true        #url中包含group名称
store_path0=/home/fastdfs   #指定文件存储路径
将libfdfsclient.so拷贝至/usr/lib下
cp /usr/lib64/libfdfsclient.so /usr/lib/
创建nginx/client目录
mkdir -p /var/temp/nginx/client

11.png

10.2 开始编译Nginx
进入 Nginx目录

12.png

./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=/usr/local/fastdfs-nginx-module/src

然后 make
然后 make install


切换目录配置 nginx.conf

cd /usr/local/nginx
vim nginx.conf

13.png

最后启动Nginx

14.png

再执行一下

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/1.png
[root@192 conf]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /root/1.png
This is FastDFS client test program v5.05

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.csource.org/ 
for more detail.

[2018-10-20 15:04:41] DEBUG - base_path=/home/fastdfs, connect_timeout=30, network_timeout=30, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
        server 1. group_name=, ip_addr=192.168.0.103, port=23000

group_name=group1, ip_addr=192.168.0.103, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgAZ1vLpnmAL9sKAACS3YKjgyI364.png
source ip address: 192.168.0.103
file timestamp=2018-10-20 15:04:41
file size=37597
file crc32=2191754018
example file url: http://192.168.0.103/group1/M00/00/00/wKgAZ1vLpnmAL9sKAACS3YKjgyI364.png
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgAZ1vLpnmAL9sKAACS3YKjgyI364_big.png
source ip address: 192.168.0.103
file timestamp=2018-10-20 15:04:41
file size=37597
file crc32=2191754018
example file url: http://192.168.0.103/group1/M00/00/00/wKgAZ1vLpnmAL9sKAACS3YKjgyI364_big.png
[root@192 conf]# 

访问:http://192.168.0.103/group1/M00/00/00/wKgAZ1vLpnmAL9sKAACS3YKjgyI364_big.png

15.png

发布了12 篇原创文章 · 获赞 2 · 访问量 1895

猜你喜欢

转载自blog.csdn.net/hyg0406/article/details/103275159
今日推荐