FastDfs v4.06 安装

原创 赤水  2016年4月18日 02:19 阅读 531 次
fastdfs是一个开源的,高性能的的分布式文件系统.
他主要的功能包括:
            文件存储,同步和访问,设计基于高可用和负载均衡,fastfd非常适用于基于文件服务的站点,例如图片分享和视频分享网站
fastfds有两个角色:
            跟踪服务和存储服务,跟踪服务控制,调度文件以负载均衡的方式访问;
            储服务包括:文件存储,文件同步,提供文件访问接口,同时以key value的方式管理文件的元数据
环境:
	centos 6.5
	fastdfs :v4.06
节点分布:
	tracker:172.16.1.11
	storage:172.16.1.200
# 1.安装基础环境,tracker 和 storage 节点都需要安装
yum -y install gcc-c++ 
cd /usr/src/ ; wget http://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz
wget http://down1.chinaunix.net/distfiles/libevent-2.0.20-stable.tar.gz
tar -zxvpf  libevent-2.0.20-stable.tar.gz ; cd libevent-2.0.20-stable   
./configure  && make && make install  && echo OK
ln -s /usr/local/lib/libevent* /lib/ ; ln -s /usr/local/lib/libevent* /lib64/


cd /usr/src/ ;   tar -zxvf FastDFS_v4.06.tar.gz ; cd FastDFS
sed -i '/WITH_LINUX_SERVICE/s/#//' make.sh  			#WITH_LINUX_SERVICE=1 
sed -i "s/TARGET_PREFIX=\/usr\/local/TARGET_PREFIX=\/usr\/local\/FastDfs/" make.sh  	#Fastdfs 安装目录
sed -i "s/TARGET_CONF_PATH=\/etc\/fdfs/TARGET_CONF_PATH=\/usr\/local\/FastDfs\/conf/" make.sh  	#配置文件
./make.sh &&  ./make.sh install  && echo OK || echo error

 

 

# ll /usr/local/FastDfs/conf/
client.conf  http.conf  mime.types  storage.conf  tracker.conf
client.conf    客户端上传配置文件
storage.conf   文件存储服务器配置文件 
tracker.conf   负责均衡调度服务器配置文件 
http.conf http 服务器配置文件
# 2:tracker 节点配置 (172.16.1.11)
cd /usr/local/FastDfs/conf/
mkdir /usr/local/FastDfs/conf/default ; cp /usr/local/FastDfs/conf/* /usr/local/FastDfs/conf/default/
# vim  /etc/fdfs/tracker.conf  /usr/local/FastDfs/conf/tracker.conf 
 8 bind_addr=172.16.1.11
22 base_path=/home/fastdfs    #上传文件存储路径
230 http.server_port=80       # 接受web 请求端口

# mkdir /home/fastdfs
启动tracker
/usr/local/FastDfs/bin/fdfs_trackerd /usr/local/FastDfs/conf/tracker.conf 
echo "/usr/local/FastDfs/bin/fdfs_trackerd /usr/local/FastDfs/conf/tracker.conf " >> /etc/rc.local 

#netstat -ntpul | grep fdfs
tcp        0      0 172.16.1.11:22122           0.0.0.0:*                   LISTEN      16722/fdfs_trackerd 
#3.storage配置 (172.16.1.200)
cd /usr/local/FastDfs/conf/
mkdir /usr/local/FastDfs/conf/default ; cp /usr/local/FastDfs/conf/* /usr/local/FastDfs/conf/default/
# vim /usr/local/FastDfs/conf/storage.conf  
7 group_name=group1            #此台storage1所属的服务器组名,同组内storage数据完全相同
11 bind_addr=172.16.1.200
37 base_path=/home/fastdfs     #放置data和log的目录
100 store_path0=/home/fastdfs  #放置文件的目录 
109 tracker_server=172.16.1.11:22122   #可以指定多个tracker_server,换行写即可
如:tracker_server=172.16.6.108:22122
    tracker_server=172.16.6.107:22122

#mkdir /home/fastdfs  	
#启动服务
/usr/local/FastDfs/bin/fdfs_storaged /usr/local/FastDfs/conf/storage.conf 	#第一次启动的时候会去上面配置文件指定的path里面创建目录,耐心等待一下
/usr/local/FastDfs/bin/fdfs_storaged /usr/local/FastDfs/conf/storage.conf  ; echo "/usr/local/FastDfs/bin/fdfs_storaged /usr/local/FastDfs/conf/storage.conf " >> /etc/rc.local 
data path: /home/wgl/fastdfs/data, mkdir sub dir...     # 在data文件夹下生产256个文件夹
mkdir data path: 00 ...
mkdir data path: 01 ...
mkdir data path: 02 ...
 ...

# 4.为 storage 添加nginx 访问接口,安装 Nginx 时 必须 添加fastdfs-nginx-module模块
egrep nginx /etc/passwd || useradd -M -s /sbin/nologin nginx
yum -y install gcc-c++   
yum -y install openssl-devel 
yum -y install pcre-devel  
cd /usr/src ; wget http://nginx.org/download/nginx-1.6.2.tar.gz 
cd /usr/src/ ; git clone https://github.com/happyfish100/fastdfs-nginx-module.git
sed -i 's/CORE_INCS.*/CORE_INCS=\"$CORE_INCS \/usr\/local\/FastDfs\/include\/fastdfs \/usr\/local\/FastDfs\/include\/fastcommon\"/'  /usr/src/fastdfs-nginx-qmodule/src/config
sed -i 's/CORE_INCS=.*/CORE_INCS=\"$CORE_INCS \/usr\/local\/FastDfs\/include\/fastdfs \/usr\/local\/FastDfs\/include\/fastcommon\"/'   /usr/src/fastdfs-nginx-module/src/config 
ln -s /usr/local/FastDfs/lib/libfastcommon.so /lib64/ 
 ln -s /usr/local/FastDfs/lib/libfdfsclient.so /lib64/
cd /usr/src ; tar -zxf nginx-1.6.2.tar.gz ; cd nginx-1.6.2
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/usr/src/fastdfs-nginx-module/src  && make && make install && echo OK

# mkdir /etc/fdfs/  ; cp /usr/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

# vim  /etc/fdfs/mod_fastdfs.conf 
10 base_path=/home/fastdfs/nginx		#存放log的路径
40 tracker_server=172.16.1.11:22122		#指定tracker服务器及端口
53 url_have_group_name = true			#这个很重要,在URL中包含group名称
62 store_path0=/home/fastdfs			#存储文件的路径
120 storage_server_port=23000
118 [group1]
119 group_name=group1
120 storage_server_port=23000
121 store_path_count=2
122 store_path0=/home/fastdfs
# 配置nginx
# cat /usr/local/nginx/conf/nginx.conf
server{
       listen       8888;
       location /group1/M00 {
           root /home/fastdfs/data;
           ngx_fastdfs_module;
       }
}

mkdir -p /home/fastdfs/nginx
/usr/local/nginx/sbin/nginx #启动nginx
#5. 测试,client上配置,上传文件
# vim /usr/local/FastDfs/conf/client.conf 
3 connect_timeout=30
7 network_timeout=60
10 base_path=/home/fastdfs
14 tracker_server=172.16.1.200:22122
25 log_level=info
29 http.tracker_server_port=8888     #此端口是生成url 访问的端口
 测试:
# echo 'this is fastdfs test' > /home/test2.txt
# /usr/local/FastDfs/bin/fdfs_test /usr/local/FastDfs/conf/client.conf upload /home/test2.txt 
This is FastDFS client test program v4.06

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-12 15:52:13] DEBUG - base_path=/home/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=172.16.1.200, port=23000

group_name=group1, ip_addr=172.16.1.200, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/rBAByFcMqS2AGfRXAAAAFdn28aQ693.txt
source ip address: 172.16.1.200
file timestamp=2016-04-12 15:52:13
file size=21
file crc32=3656839588
file url: http://172.16.1.11:8888/group1/M00/00/00/rBAByFcMqS2AGfRXAAAAFdn28aQ693.txt
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/rBAByFcMqS2AGfRXAAAAFdn28aQ693_big.txt
source ip address: 172.16.1.200
file timestamp=2016-04-12 15:52:13
file size=21
file crc32=3656839588
file url: http://172.16.1.11:8888/group1/M00/00/00/rBAByFcMqS2AGfRXAAAAFdn28aQ693_big.txt

#浏览器访问:http://172.16.1.200:8888/group1/M00/00/00/rBAByFcMqS2AGfRXAAAAFdn28aQ693_big.txt

 


 

本文地址: https://blog.lssin.com/readblog/96.html
版权声明:本文为原创文章,版权归  赤水 所有,欢迎分享本文,转载请保留出处!

发表评论


表情