linux dfs文件系统,Linux 下 FastDFS v5.08 分布式文件系统的安装

一、系统安装目录

源代码包目录

/data/wwwroot

libevent安装目录

/usr/local/libevent

FastDFS安装目录

/data/fastdfs

Nginx安装目录

/data/nmp/Nginx

二、下载FastDFS安装包

https://sourceforge.net/projects/fastdfs/files/

如:FastDFS_v5.08.tar.gz

https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/

下载FastDFS的Nginx模块源代码

如:fastdfs-Nginx-module_v1.16.tar.gz

https://github.com/happyfish100/libfastcommon/archive/master.zip

下载libfastcommon安装包

如:libfastcommon-master.zip

三、安装libfastcommon

> uzip libfastcommon-master.zip

> cd libfastcommon-master

> ./make.sh

> ./make.sh install

(*如果提示-bash: uzip: command not found则需要安装zip)

> yum install uzip zip

四、安装tracker

> tar zxf FastDFS_v5.08.tar.gz

> cd FastDFS

运行./make.sh,如果有错,可能缺少依赖的软件包

> ./make.sh

> ./make.sh install

安装成功后可执行文件在如下目录:

> ll /usr/bin/fdfs*

配置文件在:

> ll /etc/fdfs

五、配置tracker相关信息

我们创建tracker目录

> mkdir -m 777 /data/tracker

> cd /etc/fdfs

> cp tracker.conf.sample tracker.conf

> vi tracker.conf

复制一份tracker.conf配置文件,配置。

#启用配置文件

disabled=false

#设置tracker的端口号

port=22122

#设置tracker的数据文件和日志目录(需预先创建)

base_path=/data/tracker

#设置http端口号

http.server_port=8080

五、运行tracker

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

查看tracker启动是否成功

> netstat -unltp | grep fdfs

(*注意需要把防火墙中对应端口打开)

也可设置开机自启动

> vi /etc/rc.d/rc.local

把如下内容加进去:

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

五、配置storage

创建storage目录

> mkdir -m 777 /data/storage

> cd /etc/fdfs

> cp storage.conf.sample storage.conf

> vi storage.conf

#启用配置文件

disabled=false

#组名,根据实际情况修改

group_name=group1

#设置storage的端口号

port=23000

#设置storage的日志目录(需预先创建)

base_path=/data/storage

#存储路径个数,需要和store_path个数匹配

store_path_count=1

#存储路径

store_path0=/data/storage

#tracker服务器的IP地址和端口号

tracker_server=192.168.9.10:22122

#设置http端口号

http.server_port=8080

运行storage

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

查看是否成功

> netstat -unltp | grep fdfs

通过fdfs_monitor查看storage服务器是否已经登记到tracker服务器

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

六、安装Nginx的fastdfs模块

由于之前已经安装过Nginx,所以我们重新编译安装,查看Nginx安装的命令

> /data/nmp/Nginx/sbin/Nginx -V

configure arguments: --prefix=/data/nmp/Nginx --with-pcre=/usr/src/pcre-8.38

把fastdfs-Nginx-module解压并复制到/data/nmp下

> tar -zxf fastdfs-Nginx-module_v1.16.tar.gz

> cp -R fastdfs-Nginx-module /data/nmp/

然后我们找到原Nginx的源码包,如果找不到了,重新下一个。

> tar -zxf Nginx-1.8.1.tar.gz

> cd Nginx-1.8.1

> ./configure --prefix=/data/nmp/Nginx --with-pcre=/usr/src/pcre-8.38 --add-module=/data/nmp/fastdfs-Nginx-module/src

> make

(*注意这里千万不要make install,不然就覆盖安装了)

如果中间出现

make[1]: *** [objs/addon/src/ngx_http_fastdfs_module.o] 错误 1

请先进入到FastDFS/client目录下

> make && make install

如果还是不行,则修改config文件如下(去掉local)

> vi /data/nmp/fastdfs-Nginx-module/src/config

CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

再重新编译,应该就可以成功了。

> cp objs/Nginx /data/nmp/Nginx/sbin/Nginx

我们把模块src下的mod_fastdfs.conf文件拷贝到/etc/fdfs下

> cp /data/nmp/fastdfs-Nginx-module/src/mod_fastdfs.conf /etc/fdfs/

修改配置文件

#存放log目录

base_path=/data/storage

#tracker服务器IP和端口(可写多个)

tracker_server=192.168.9.10:22122

#storage所属的服务器组名

group_name=group1

#url中是否包含group名称

url_have_group_name = true

#放置文件目录(可写多个)

store_path0=/data/storage

修改完成后,启动Nginx发现有错误如下:

[2016-04-15 01:31:46] ERROR - file: ini_file_reader.c,line: 394,include file "http.conf" not exists,line: "#include http.conf"

[2016-04-15 01:31:46] ERROR - file: /data/nmp/fastdfs-Nginx-module/src/common.c,line: 155,load conf file "/etc/fdfs/mod_fastdfs.conf" fail,ret code: 2

把FastDFS安装包下的conf文件夹下的http.conf和mime.types复制到/etc/fdfs下

> cp /data/wwwroot/FastDFS/conf/http.conf /etc/fdfs/

> cp /data/wwwroot/FastDFS/conf/mime.types /etc/fdfs/

我们新建一个Nginx虚拟主机来测试,我的Nginx安装在/data/nmp/Nginx下,虚拟主机的配置文件放在/data/nmp/Nginx/conf/vhost/site.conf下(注意需要在Nginx.conf的http{}中加入include vhost/*.conf;)。

server {

#监听的端口号

listen 8080;

#虚拟主机名

server_name www.site.com;

location ~ /group[0-9]/M00 {

#路径

root /data/storage/data;

ngx_fastdfs_module;

}

}

建立M00到存储目录的符号链接

> ln -s /data/storage/data /data/storage/data/M00

我们来测试一下我们是否创建成功

在/etc/fdfs/下复制client.conf.sample一份为clien.conf

> cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf

修改如下:

base_path=/data/storage

tracker_server=192.168.9.10:22122

http.tracker_server_port=8080

创建test.html,使用/usr/bin/fdfs_test来测试上传

> echo "test..." > test.html

> /usr/bin/fdfs_test /etc/fdfs/client.conf upload test.html

成功后返回如下信息:

This is FastDFS client test program v5.08

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.

[2016-04-15 05:56:03] DEBUG - base_path=/data/storage,connect_timeout=30,network_timeout=60,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.9.10,port=23000

group_name=group1,port=23000

storage_upload_by_filename

group_name=group1,remote_filename=M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22.html

source ip address: 192.168.9.10

file timestamp=2016-04-15 05:56:04

file size=8

file crc32=3252589722

example file url: http://192.168.9.10:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22.html

storage_upload_slave_by_filename

group_name=group1,remote_filename=M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html

source ip address: 192.168.9.10

file timestamp=2016-04-15 05:56:04

file size=8

file crc32=3252589722

example file url: http://192.168.9.10:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html

通过访问如下网址,显示test...,说明上传成功

http://192.168.9.10:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html

当然我们也可以用如下地址访问。

http://www.site.com:8080/group1/M00/00/00/wKgJClcQEfSAAELFAAAACMHelJo22_big.html

总结

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

小编个人微信号 jb51ccc

喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值