FastDFS安装

1、安装部署

    FastDFS_v5.05依赖libfastcommon,不再依赖libevent

1.1、libfastcommon安装

unzip libfastcommon-master.zip -d /usr/local
cd /usr/local/libfastcommon-master
./make.sh
./make.sh install

 libfastcommon.so默认安装到了/usr/lib64/libfastcommon.so,而FastDFS主程序设置的lib目录是/usr/local/lib,所以设置软连接

 ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
 ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
 ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
 ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

1.2、安装FastDFS

tar -zxvf FastDFS_v5.05.tar.gz -C /usr/local
cd /usr/local/FastDFS
./make.sh
./make.sh install

   过程中没有报错,并且打开 /etc/fdfs 这个目录发现有配置文件存在,就说明安装成功了。

2、配置tracker

   2.1、进入/etc/fdfs文件夹,执行命令: cp  tracker.conf.sample  tracker.conf。

   2.2、编辑tracker.conf,执行命令: vi  tracker.conf ,将以下几个选项进行编辑:

a. disabled=false            #启用配置文件
b. port=22122                #设置tracker的端口号,一般采用22122这个默认端口
c. base_path=/opt/fastdfs_tracker   #设置tracker的数据文件和日志目录(预先创建)
d. http.server_port=8080     #设置http端口号   
###注意,这个配置在fastdfs5.05这个版本中已经不用配置,不用管这个

  3.3、启动tracker,执行如下命令

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

   3.4、启动完毕后,可以通过以下两个方法查看tracker是否启动成功:

      a. netstat -unltp|grep fdfs,查看22122端口监听情况 

      b. 通过以下命令查看tracker的启动日志,看是否有错误:

            tail -100f  /opt/fastdfs_tracker/logs/trackerd.log

  3.5、如果启动没有问题,可以通过以下步骤,将tracker的启动添加到服务器的开机启动中:

          a. 打开文件 vi /etc/rc.d/rc.local

          b. 将如下命令添加到该文件中 /usr/bin/fdfs_trackerd  /etc/fdfs/tracker.conf  restart

3、配置storage:

      其实配置storage和配置tracker类似,只不过配置文件和配置内容不一样。我们以配置192.168.224.29配置storage为例。

      1. 进入/etc/fdfs文件夹,执行命令: cp  storage.conf.sample  storage.conf。

      2. 编辑storage.conf,执行命令: vi  storage.conf ,将以下几个选项进行编辑:

a. disabled=false #启用配置文件        
b. group_name=group2    #组名,根据实际情况修改
c. port=23001     #设置storage的端口号,默认是23000,同一个组的storage端口号必须一致
d. base_path=/opt/fastdfs_storage_info    #设置storage的日志目录(需预先创建)
e. store_path_count=1   #存储路径个数,需要和store_path个数匹配
f. store_path0=/opt/fastdfs_storage_data   #存储路径
g. tracker_server=192.168.224.20:22122   #tracker服务器的IP地址和端口号
h. http.server_port=8080     #设置http端口号  
### 注意,这个配置在fastdfs5.05这个版本中已经不用配置,不用管这个!

      3. 启动storage,执行如下命令: /usr/bin/fdfs_storage  /etc/fdfs/storage.conf  restart

      4. 启动完毕后,可以通过以下两个方法查看storage是否启动成功:

          a. netstat -unltp|grep fdfs,查看23001端口监听情况 

          b. 通过以下命令查看storage的启动日志,看是否有错误: tail -100f  /opt/fastdfs_storage_info/logs/storage.log

      5. 启动成功后,可以通过fdfs_monitor查看集群的情况,即storage是否已经注册到tracker服务器中

          /usr/bin/fdfs_monitor /etc/fdfs/storage.conf

          查看192.168.224.29:23001 是ACTIVE状态即可

      6. 如果启动没有问题,可以通过以下步骤,将storage的启动添加到服务器的开机启动中:

          a. 打开文件 vi /etc/rc.d/rc.local

          b. 将如下命令添加到该文件中 /usr/bin/fdfs_storage  /etc/fdfs/storage.conf  restart

3、通过java-client客户端上传图片

    参考:http://my.oschina.net/u/1757031/blog/467450

4、通过浏览器访问上传的图片

  4.1、下载fastdfs-nginx-module

    进入Nginx解压目录,执行如下命令:

          ./configure  --prefix=/usr/local/nginx  --add-module=/fastdfs-nginx-module/fastdfs-nginx-module/src 

  4.2、 执行完上述命令,如果没有报错的话,我们继续执行 make 命令,此时编译有可能会报错,那是因为我们忘了做一项重要的工作,我们可以参考下面这篇文章http://bbs.chinaunix.net/thread-4163021-1-1.html中的解答,其实汇总就是下面两个意思:

    a. 我们在解压缩fastdfs-nginx-module_v1.16.tar.gz之后,需要进入fastdfs-nginx-module/src目 录,编辑config文件,找到包含CORE_INCS这个一行,将路径中local全部去掉,变为CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

    b. 建立软连接,这个软连接我们在第五步安装libfastcommon时的最后一个操作就已经建立了,所以此处不用再建立了。

   4.3、 执行完3个步骤后,我们在重复执行2中的命令,然后再依次执行 make 和 make install 这两个命令,没有报错误就是安装成功了。

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

  4.5、修改mod_fastdfs.conf文件

#tracker_server的ip地址
tracker_server=192.168.40.128:22122

# the port of the local storage server
# the default value is 23000
storage_server_port=23000

# the group name of the local storage server
group_name=group1

# if the url / uri including the group name
# set to false when uri like /M00/00/00/xxx
# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
# default value is false
url_have_group_name = true

# path(disk or mount point) count, default value is 1
# must same as storage.conf
store_path_count=1

# store_path#, based 0, if store_path0 not exists, it's value is base_path
# the paths must be exist
# must same as storage.conf
store_path0=/home/fastdfs/storage_data

4.6、配置Nginx

server{
        listen 8090;
        location /group1/M00{
         root /home/fastdfs/storage_data;
         ngx_fastdfs_module;
        }
    }

4.7、启动Nginx,在浏览器地址输入

   http://192.168.40.128:8090/group1/M00/00/00/wKgogFYYBUWAFAbXAAGM7eIdTSc949.jpg


转载于:https://my.oschina.net/u/1425545/blog/514947

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值