(3)DNS服务器
more /etc/resolv.conf
nameserver 192.168.100.10
nameserver 192.168.100.11
二、安装
所需要下载的压缩包有:
FastDFS_v5.01.tar.gz
nginx-1.8.0.tar.gz
pcre-8.32.tar.gz
zlib-1.2.8.tar.gz
openssl-1.0.1c.tar.gz
fastdfs-nginx-module_v1.15.tar.gz
simpl-ngx_devel_kit.tar.gz
lua-nginx-module-0.9.15.tar.gz
LuaJIT-2.0.2.tar.gz
echo-nginx-module.tar.gz
ngx_cache_purge-2.3.tar.gz
1.FastDFS的安装
cd /usr/local
tar zxvf FastDFS_v5.01.tar.gz
cd FastDFS
./make.sh
./make.sh install
2.nginx的安装(加入lua的目的是nginx能够有更好的扩展性)
(1).安装PCRE库
cd /usr/local/
tar -zxvf pcre-8.32.tar.gz
cd pcre-8.21
./configure --prefix=/usr/local/pcre
make
make install
(2).安装zlib库
cd /usr/local/
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure --prefix = /usr/local/zlib
make
make install
(3).安装openssl
cd /usr/local/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
./config --prefix = /usr/local/openssl
make
make install
(4).下载编译LuaJIT
wget -c http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar xzvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make install PREFIX=/usr/local/luajit
echo "/usr/local/luajit/lib" > /etc/ld.so.conf.d/usr_local_luajit_lib.conf
ldconfig
#注意环境变量!
export LUAJIT_LIB=/usr/local/luajit/lib
export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0
(5).解压如下软件
tar xzvf lua-nginx-module-0.9.15.tar.gz
tar xzvf echo-nginx-module.tar.gz
tar zxvf simpl-ngx_devel_kit.tar.gz
tar zxvf ngx_cache_purge-2.3.tar.gz
tar zxvf fastdfs-nginx-module_v1.15.tar.gz
7.测试文件是否可以上传下载:
(1)修改一台机器的client.conf配置文件:
base_path=/data1/tracker #日志存放路径
tracker_server=10.240.37.87:22122 #tracker服务器IP地址和端口号
http.tracker_server_port=8081 #tracker服务器的http端口号
(2)执行如下操作:
[iyunv@localhost fdfs]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /usr/local/test/2007119124413448_2.jpg
This is FastDFS client test program v5.01
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.
[2015-07-06 18:44:52] DEBUG - base_path=/tmp, 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=10.240.37.90, port=23000
group_name=G2, ip_addr=10.240.37.90, port=23000
storage_upload_by_filename
group_name=G2, remote_filename=M00/00/00/CvAlWlWaXCSAXfcKAAF3qJ0P44M093.jpg
source ip address: 10.240.37.90
file timestamp=2015-07-06 18:44:52
file size=96168
file crc32=2635064195
example file url: http://10.240.37.90:8081/G2/M00/00/00/CvAlWlWaXCSAXfcKAAF3qJ0P44M093.jpg
storage_upload_slave_by_filename
group_name=G2, remote_filename=M00/00/00/CvAlWlWaXCSAXfcKAAF3qJ0P44M093_big.jpg
source ip address: 10.240.37.90
file timestamp=2015-07-06 18:44:52
file size=96168
file crc32=2635064195
example file url: http://10.240.37.90:8081/G2/M00/00/00/CvAlWlWaXCSAXfcKAAF3qJ0P44M093_big.jpg
然后下载的话 把返回的80801改成8080即可访问,因为tracker的http端口如果不做负载均衡的话是不提供http服务的。
浏览器访问地址为:http://10.240.37.90:8080/G2/M00/00/00/CvAlWlWaXCSAXfcKAAF3qJ0P44M093_big.jpg
然后报400错误
400 Bad Request
Request Header Or Cookie Too Large
查看日志报错如下:
"/usr/local/nginx/html/favicon.ico" failed (2: No such file or directory)
解决方法,增大请求缓冲,编辑nginx.conf,修改下面两个配置项为:
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
重启即可。 备注:如果有多个tracker可配置nginx+keepalived做前端下载上传的负载均衡.