Linux 下 FastDFS v5.08 分布式文件系统的安装
时间:2017-01-26 17:22:54
收藏:0
阅读:1468
一、系统安装目录
源代码包目录 /data/wwwroot libevent安装目录 /usr/local/libevent FastDFS安装目录 /data/fastdfs nginx安装目录 /data/nmp/nginx
二、下载FastDFS安装包
https://sourceforge.net/projects/fastdfs/files/
https://sourceforge.net/projects/fastdfs/files/FastDFS%20Nginx%20Module%20Source%20Code/
如:fastdfs-nginx-module_v1.16.tar.gz
https://github.com/happyfish100/libfastcommon/archive/master.zip
如: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
> /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
> 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
> /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
> netstat -unltp | grep fdfs
> /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/
> 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
> make && make install
> 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
> 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; } }
> 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, ip_addr=192.168.9.10, 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
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
评论(0)