CentOS 下 FastDFS _ V4.06 安装部署
CentOS 下 FastDFS _ V4.06 安装部署CentOS系统64位x86_64 GNU/Linux
软件准备
libevent-1.4.14b-stable.tar.gz
FastDFS_v4.06.tar.gz
nginx-1.3.9.tar.gzfastdfs-nginx-module_v1.15.tar.gz
安装libevent
下载并安装#cd /usr/srcwget https://github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz#tar zxvf libevent-1.4.14b-stable.tar.gz# cd libevent-1.4.14b-stable# ./configure --prefix=/usr# make && make install
安装FastDFS这里我们选择的FDFS新版本,这里的FASTDFS 本身没有了http server的功能。#cd /usr/src#wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz#tar zxvfFastDFS_v4.06.tar.gz# cd FastDFS/由于一些库文件的存放位置,和编译脚本中的不一致,需要根据系统的实际情况进行调整。#vi make.sh查找:if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /lib64/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /lib64/libpthread.a ] || [ -f /usr/lib64/libpthread.a ] ;then保存退出
#vi /usr/src/FastDFS/client/fdfs_link_library.sh.in (64 bit 需要修改)查找:ln -fs $TARGET_LIB/libfastcommon.so.1 /usr/lib64/libfastcommon.soln -fs $TARGET_LIB/libfdfsclient.so.1 /usr/lib64/libfdfsclient.so保存退出./make.sh./make.sh install#cpinit.d/* /etc/init.d/
配置tracker server安装完成后,在默认cd /etc/fdfs下#vi tracker.confport=22122base_path=/www/book_tracker保存退出#mkdir /www/book_tracker# /etc/init.d/fdfs_trackerd start#启动过程中出现的错误(成功安装libevent 就不会出现这个问题)
#./fdfs_trackerd: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory
#解决办法
ln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf检查tracker server #netstat -antpul |grep 22122 tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 23275/fdfs_trackerd
配置及启动Storage Servermkdir -p /www/book_storage#/www/book_storage#vi /etc/fdfs/storage.conf# port=23000base_path=/www/book_storage#base_path,指定data和log所在目录,根目录必须存在,子目录会自动创建store_path0=/www/book_storage #文件的存储位置,在一台Storage Server上可以指定多个存储位置group_name=group1tracker_server=192.168.0.22:22122#tracker_server 的ip保存退出启动storage server#/etc/init.d/fdfs_storagedstart#netstat -antpul |grep 23000查看进程。可以查看相关日志排错#tail -f /www/book_storage/logs/storaged.log验证验证上传下载首先配置好客户端#mkdir /www/book_client#base_path=/www/book_clienttracker_server=192.168.0.22:22122保存设置 测试上传fdfs_test /etc/fdfs/client.conf upload /etc/fstabThis is FastDFS client test program v4.06FastDFS may be copied only under the terms of the GNU GeneralPublic License V3, which may be found in the FastDFS source kit.Please visit the FastDFS Home Page http://www.csource.org/ for more detail. DEBUG - base_path=/www/book_client, 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.0.22, port=23000group_name=group1, ip_addr=192.168.0.22, port=23000storage_upload_by_filenamegroup_name=group1, remote_filename=M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157source ip address: 192.168.0.22file timestamp=2013-06-03 15:45:41file size=1012file crc32=3455471064file url: http://192.168.0.22/group1/M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157storage_upload_slave_by_filenamegroup_name=group1, remote_filename=M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_bigsource ip address: 192.168.0.22file timestamp=2013-06-03 15:45:42file size=1012file crc32=3455471064file url: http://192.168.0.22/group1/M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_big下载#cd /usr/src查看# fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_bigsource storage id: 0source ip address: 192.168.0.22file create timestamp: 2013-06-03 15:45:42file size: 1012file crc32: 3455471064 (0xCDF64DD8) # fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_big-rw-r--r-- 1 root root1012 Jun3 15:59 AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_big删除fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/AQEBjFGsSaWAOjeUAAAD9M32Tdg9524157_big---------------------------------------------------------------------------------------- Fdfs 和 Nginx的整合因为FastDFS默认自带的http服务器性能不好,所以一般建议用外置的apache或者nginx来解决http下载,以应付大并发的情况.#cd/usr/src/#wget http://fastdfs-nginx-module.googlecode.com/files/ fastdfs-nginx-module_v1.15.tar.gz#wget http://nginx.org/download/nginx-1.3.9.tar.gz#tar zxvf fastdfs-nginx-module_v1.15.tar.gz#tar zxvf nginx-1.3.9.tar.gz# cd nginx-1.3.9/#./configure --prefix=/usr/local/nginx --with-http_gzip_static_module --add-module=/root/fastdfs-nginx-module/src/
安装Nginx时报错
./configure: error: the HTTP rewrite module requires the PCRE library.
安装pcre-devel解决问题
yum -y install pcre-devel
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解决办法:
yum -y install openssl openssl-devel
#make && make install修改相关配置文件修改nginx扩展模块的配置文件#cd ../root/fastdfs-nginx-module/src#cp mod_fastdfs.conf /etc/fdfs/#vi /etc/fdfs/mod_fastdfs.conf base_path=/www/logs#存放log的路径 tracker_server=192.168.0.22:22122#指定tracker服务器及端口 url_have_group_name = true#这个很重要,在URL中包含group名称 store_path0=/www/book_storage#存储文件的路径 storage_server_port=23000#与storage的配置端口保持一致保存后退出
!!!!!查看/www/logs目录是否存在做M00的链接sudo ln -s /www/book_storage/data/www/book_storage/data/M00修改nginx的配置文件#vim /usr/local/nginx/conf/nginx.confserver { listen 8888; server_namelocalhost; #charset koi8-r; #access_loglogs/host.access.logmain; location / { root /www/book_storage/data; indexindex.html index.htm; } location /group1/M00 { root /www/book_storage/data; ngx_fastdfs_module; }保存退出#cp /usr/local/nginx/sbin/nginx /etc/init.d/nginx#/etc/init.d/nginx -tngx_http_fastdfs_set pid=23580nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful检查配置文件语法#/etc/init.d/nginx ##启动nginx 检查端口 # lsof -i:8888COMMANDPID USER FD TYPE DEVICE SIZE/OFF NODE NAMEnginx 3770 root 6uIPv411231 0t0TCP *:8888 (LISTEN)nginx 3771 nobody 6uIPv411231 0t0TCP *:8888 (LISTEN) # netstat -antpul |grep tcptcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 23275/fdfs_trackerdtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22917/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2117/sshd tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 23325/fdfs_storagedtcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN 22917/nginx tcp 0 0 192.168.0.22:22122 192.168.0.22:48515 ESTABLISHED 23275/fdfs_trackerdtcp 0 0 192.168.0.22:22 1.1.1.24:1558 ESTABLISHED 16381/sshd: boo tcp 0 0 192.168.0.22:48515 192.168.0.22:22122 ESTABLISHED 23325/fdfs_storagedtcp6 0 0 :::22 :::* LISTEN 2117/sshd测试上传和下载 #fdfs_test /etc/fdfs/client.conf upload /etc/fstab #cd /usr/src#wget http://192.168.0.22:8888/group1/M00/00/00/AQEBjFGsVESARdlrAAAD9M32Tdg0763076_big--2013-06-03 16:32:40--http://192.168.0.22:8888/group1/M00/00/00/AQEBjFGsVESARdlrAAAD9M32Tdg0763076_bigConnecting to 192.168.0.22:8888... connected.HTTP request sent, awaiting response... 200 OKLength: 1012Saving to: `AQEBjFGsVESARdlrAAAD9M32Tdg0763076_big' 100%[======================================================================================>] 1,012 --.-K/s in 0s
测试成功
页:
[1]