系统环境:
操作系统:Centos6.5X86_64 fastdfs版本: FastDFS_v5.02.tar
Fastdfs_tracker IP:172.16.4.30
Fastdfs_storage_s1 IP:172.16.4.31
Fastdfs_storage_s1 IP:172.16.4.32
Fastdfs_client IP:172.16.4.33
一.fastdfs和libevent的下载
地址: http://sourceforge.net/projects/fastdfs/files/FastDFS%20Server%20Source%20Code/
二.安装tracker
[root@fastdfs1 ~]# yum install gcc gcc-c++
[root@fastdfs1 ~]# yum install gettext gettext-devel libXft libXft-devel libXpm libXpm-devel autoconf libxtst-devel zlib-devel libpng-devel glib-devel
[root@fastdfs1 beauty]# tar -zxvf libevent-1.4.13-stable.tar.gz
[root@fastdfs1 beauty]# cd libevent-1.4.13-stable
[root@fastdfs1 libevent-1.4.13-stable]# ./configure && make && make install
2安装tracker
[root@fastdfs1 beauty]# tar -zxvf FastDFS_v5.02.tar.gz
[root@fastdfs1 beauty]# cd FastDFS
[root@fastdfs1 FastDFS]# ./make.sh
[root@fastdfs1 FastDFS]# ./make.sh install
3.配置tracker
[root@fastdfs1 FastDFS]# cd /etc/fdfs/
root@fastdfs1 fdfs]# ls
client.conf http.conf mime.types storage.conf tracker.conf
解释这几个配置文件:client.conf 客户端上传配置文件
http.conf http 服务器配置文件
storage.conf 文件存储服务器配置文件
tracker.conf 负责均衡调度服务器配置文件
[root@fastdfs1 ~]# vi /etc/fdfs/tracker.conf
base_path=/home/yuqing/fastdfs把这个路径改为自己的路径
base_path=/var/fastdfs_tracker 修改后的路径
[root@fastdfs1 ~]# mkdir /var/fastdfs_tracker 创建fastdfs_tracker目录
启动tracker:
[root@fastdfs1 fdfs]# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
[root@fastdfs1 fdfs]# lsof -i:22122 #检查是否成功,显示下面说明成功
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_trac 8747 root 5u IPv4 30747 0t0 TCP *:22122 (LISTEN)
三.安装storage_s1
1.先安装依赖包
[root@fastdfs1 ~]# yum install gcc gcc-c++
[root@fastdfs1 ~]# yum install gettext gettext-devel libXft libXft-devel libXpm libXpm-devel autoconf libxtst-devel zlib-devel libpng-devel glib-devel
[root@fastdfs1 beauty]# tar -zxvf libevent-1.4.13-stable.tar.gz
[root@fastdfs1 beauty]# cd libevent-1.4.13-stable
[root@fastdfs1 libevent-1.4.13-stable]# ./configure && make && make install
2安装storage
[root@fastdfs1 beauty]# tar -zxvf FastDFS_v5.02.tar.gz
[root@fastdfs1 beauty]# cd FastDFS
[root@fastdfs1 FastDFS]# ./make.sh
[root@fastdfs1 FastDFS]# ./make.sh install
3.配置storage_s1
[root@fastdfs1 ~]# vi /etc/fdfs/storage.conf
group_name=group1 #组名,根据情况修改
port=23000 #端口号设置
base_path= /var/fastdfs_storage_log #日志目录(需创建)
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/var/fastdfs_storage_data #存储路径
tracker_server=172.16.4.30:22122 #tracker服务器的IP地址和端口号
[root@fastdfs1 ~]# mkdir /var/fastdfs_storage_log #创建fastdfs_storage_log目录
[root@fastdfs1 ~]# mkdir /var/fastdfs_storage_data #创建fastdfs_storage_data目录
4.启动storages:
[root@fastdfs1 ~]# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
root@fastdfs1 ~]# lsof -i:23000 #显示下面说明启动成功
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_stor 8674 root 5u IPv4 96323 0t0 TCP *:inovaport1 (LISTEN)
四.安装storage_s2
1.先安装依赖包
[root@fastdfs2~]# yum install gcc gcc-c++
[root@fastdfs2 ~]# yum install gettext gettext-devel libXft libXft-devel libXpm libXpm-devel autoconf libxtst-devel zlib-devel libpng-devel glib-devel
[root@fastdfs2beauty]# tar -zxvf libevent-1.4.13-stable.tar.gz
[root@fastdfs2 beauty]# cd libevent-1.4.13-stable
[root@fastdfs2 libevent-1.4.13-stable]# ./configure && make && make install
2安装storage
[root@fastdfs2 beauty]# tar -zxvf FastDFS_v5.02.tar.gz
[root@fastdfs2 beauty]# cd FastDFS
[root@fastdfs2 FastDFS]# ./make.sh
[root@fastdfs2 FastDFS]# ./make.sh install
3.配置storage_s1
[root@fastdfs2~]# vi /etc/fdfs/storage.conf
group_name=group1 #组名,根据情况修改
port=23000 #端口号设置
base_path= /var/fastdfs_storage_log #日志目录(需创建)
store_path_count=1 #存储路径个数,需要和store_path个数匹配
store_path0=/var/fastdfs_storage_data #存储路径
tracker_server=172.16.4.30:22122 #tracker服务器的IP地址和端口号
[root@fastdfs2 ~]# mkdir /var/fastdfs_storage_log #创建fastdfs_storage_log目录
[root@fastdfs2 ~]# mkdir /var/fastdfs_storage_data #创建fastdfs_storage_data目录
4.启动storages:
[root@fastdfs2 ~]# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
root@fastdfs2 ~]# lsof -i:23000 #显示下面说明启动成功
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_stor 8674 root 5u IPv4 96323 0t0 TCP *:inovaport1 (LISTEN
root@fastdfs3 FastDFS]# lsof -i:23000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
fdfs_stor 8935 root 5u IPv4 96766 0t0 TCP *:inovaport1 (LISTEN)
fdfs_stor 8935 root 20u IPv4 96778 0t0 TCP 172.16.4.32:41725->172.16.4.31:inovaport1 (ESTABLISHED)
fdfs_stor 8935 root 23u IPv4 96781 0t0 TCP 172.16.4.32:inovaport1->172.16.4.31:60826 (ESTABLISHED)
[root@fastdfs3 FastDFS]# netstat -anlp | grep ESTABLISHED
tcp 0 0 172.16.4.32:51884 172.16.4.30:22122 ESTABLISHED 8935/fdfs_storaged
tcp 0 0 172.16.4.32:41725 172.16.4.31:23000 ESTABLISHED 8935/fdfs_storaged
tcp 0 52 172.16.4.32:22 172.16.4.53:55122 ESTABLISHED 1437/sshd
tcp 0 0 172.16.4.32:23000 172.16.4.31:60826 ESTABLISHED 8935/fdfs_storaged
五.安装fastdfs_client:
1.先安装依赖包
[root@client~]# yum install gcc gcc-c++
[root@client~]# yum install gettext gettext-devel libXft libXft-devel libXpm libXpm-devel autoconf libxtst-devel zlib-devel libpng-devel glib-devel
[root@ client beauty]# tar -zxvf libevent-1.4.13-stable.tar.gz
[root@ client beauty]# cd libevent-1.4.13-stable
[root@ client libevent-1.4.13-stable]# ./configure && make && make install
2安装fastdfs_client
[root@ client beauty]# tar -zxvf FastDFS_v5.02.tar.gz
[root@ client beauty]# cd FastDFS
[root@ client FastDFS]# ./make.sh
[root@ client FastDFS]# ./make.sh install
3.配置fastdfs_client
[root@ client ~]# vi /etc/fdfs/client.conf
base_path=/var/fastdfs_client_log
tracker_server=172.16.4.30:22122
[root@fastdfsclient FastDFS]# mkdir /var/fastdfs_client_log
3.在client上传文件测试:
root@fastdfsclient FastDFS]# echo "my fastdfs" > index.html
[root@fastdfsclient FastDFS]# /usr/local/bin/fdfs_upload_file /etc/fdfs/client.conf index.html
group1/M00/00/00/rBAEIFS_zxGANHoPAAAAC095TMA39.html (这是storage服务器下的物理路径)
到storage_s1服务器查看文件:
root@fastdfs1 ~]# cd /var/fastdfs_storage_data/data/00/00
[root@fastdfs1 00]# ls
rBAEH1S_zpmAAVzjAAAAG17eryY68.html rBAEIFS_zxGANHoPAAAAC095TMA39.html (文件传上来了)
再到storage_s2服务器查看文件:
[root@fastdfs2 FastDFS]# cd /var/fastdfs_storage_data/data/00/00/
[root@fastdfs2 00]# ls
rBAEH1S_zpmAAVzjAAAAG17eryY68.html rBAEIFS_zxGANHoPAAAAC095TMA39.htm
4.安装成功
原文地址:http://vqiao.blog.51cto.com/9368913/1606845