测试环境:
Fedora 18 64位
tracker server 和 storage server 在同一台机器上
nginx 与 storage server 对接
1. tar.gz
1> libevent-2.0.21-stable.tar.gz
2> FastDFS_v4.06.tar.gz
3> nginx-1.3.8.tar.gz
4> fastdfs-nginx-module_v1.15.tar.gz
2. libevent-2.0.21-stable.tar.gz 安装
1> tar -xvf libevent-2.0.21-stable.tar.gz
2> ./configure --prefix=/usr/local/libevent-2.0.21
3> make
4> make install
3. FastDFS_v4.06.tar.gz 安装
1> tar -xvf FastDFS_v4.06.tar.gz
2> 进入 FastDFS 编辑 make.sh 文件
改为:
TARGET_PREFIX=/usr/local/FastDFS
TARGET_CONF_PATH=/etc/fdfs
WITH_LINUX_SERVICE=1
3> ./make.sh C_INCLUDE_PATH=/usr/local/libevent-2.0.21/include LIBRARY_PATH=/usr/local/libevent-2.0.21/lib
4> ./make.sh install
5> 设置软连接(否则编译nginx时会出错)
ln -sv /usr/local/FastDFS/include/fastcommon /usr/local/include/fastcommon
ln -sv /usr/local/FastDFS/include/fastdfs /usr/local/include/fastdfs
ln -sv /usr/local/FastDFS/lib/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -sv /usr/local/FastDFS/lib/libfastcommon.so.1 /usr/local/lib/libfastcommon.so.1
ln -sv /usr/local/FastDFS/lib/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -sv /usr/local/FastDFS/lib/libfdfsclient.so.1 /usr/local/lib/libfdfsclient.so.1
4. nginx-1.3.8.tar.gz + fastdfs-nginx-module_v1.15.tar.gz 安装
1> tar -xvf nginx-1.3.8.tar.gz
2> tar -xvf fastdfs-nginx-module_v1.15.tar.gz
3> cd nginx-1.3.8
4> ./configure --prefix=/usr/local/nginx --add-module=/路径/fastdfs-nginx-module/src
5> make
6> make install
注意:安装nginx 确保系统有 gcc、 openssl-devel、 pcre-devel和zlib-devel软件库
5. tracker server
1> vim /etc/fdfs/tracker.conf
bind_addr=192.168.100.250
base_path=/home/tracker/fastdfs
2> 启动 tracker
/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf
3> netstat -ntpl | grep fdfs
tcp 0 0 192.168.100.250:22122 0.0.0.0:* LISTEN /fdfs_trackerd
6. storage server
1> vim /etc/fdfs/storage.conf
group_name=group1
bind_addr=192.168.100.250
base_path=/home/storage1/fastdfs
store_path0=/home/storage1/fastdfs
tracker_server=192.168.100.250:22122
http.server.port=80
2> cp /路径/fastdfs-nginx-module/src/mod_fastdfs.conf 至 /etc/fdfs/
3> vim /etc/fdfs/mod_fastdfs.conf
base_path=/home/storage1/fastdfs
group_name=group1
url_have_group_name=true
store_path0=/home/stroage1/fastdfs
tracker_server=192.168.100.250:22122
4> vim /usr/local/nginx/conf/nginx.conflocation /group1/M00 {
root /home/storage1/fastdfs/data;
ngx_fastdfs_module;
}
5> 启动 storage
/usr/local/FastDFS/bin/fdfs_storaged /etc/fdfs/storage.conf
6> ln -s /home/storage1/fastdfs/data /home/storage1/fastdfs/data/M00
7> 启动 nginx
/usr/local/nginx/sbin/nginx
8> netstat -ntl
此时应该有3个监听端口,分别是:
80 -> nginx
22122 -> tracker server
23000 -> storage server
7. 测试
1> vim /etc/fdfs/client.conf
base_path=/home/storage1/fastdfs
tracker_server=192.168.100.250:22122
2> /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /etc/passwd
This is FastDFS client test program v4.06Copyright (C) 2008, Happy Fish / YuQingFastDFS 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.[2013-04-10 18:38:14] DEBUG - base_path=/home/storage2/fastdfs, 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.100.250, port=23000
group_name=group1, ip_addr=192.168.100.250, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKhk-lFlQRaAbBW2AAAIgT4zZMk1153107
source ip address: 192.168.100.250
file timestamp=2013-04-10 18:38:14
file size=2177
file crc32=1043555529
file url: http://192.168.100.250/group1/M00/00/00/wKhk-lFlQRaAbBW2AAAIgT4zZMk1153107
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKhk-lFlQRaAbBW2AAAIgT4zZMk1153107_big
source ip address: 192.168.100.250
file timestamp=2013-04-10 18:38:14
file size=2177
file crc32=1043555529
file url: http://192.168.100.250/group1/M00/00/00/wKhk-lFlQRaAbBW2AAAIgT4zZMk1153107_big
游览器输入:
http://192.168.100.250/group1/M00/00/00/wKhk-lFlQRaAbBW2AAAIgT4zZMk1153107_big
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
省略...
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
nm-openconnect:x:993:993:NetworkManager user for OpenConnect:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
pulse:x:992:992:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
qemu:x:107:107:qemu user:/:/sbin/nologin
lightdm:x:991:989::/var/log/lightdm:/sbin/nologin
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
oprofile:x:16:16:Special user account to be used by OProfile:/var/lib/oprofile:/sbin/nologin
1、tracker
A、启动命令 :/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf(tracker的配置文件路径)
B、重启命令:/usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /usr/local/config/tracker.conf (tracker的配置文件路径)
2、storage
A、启动命令:/usr/local/bin/fdfs_storaged /etc/fdfs/storage_p1.conf (storage配置文件路径)
B、重启命令:/usr/local/bin/restart.sh :/usr/local/bin/fdfs_storaged /etc/fdfs/storage_p1.conf (storage配置文件路径)