版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、fastDFS 安装部署文档fastDFS下载地址:libevent官网: /系统环境:fastdfs_tracker centos6.5_64 ip:0fastdfs_storage_s1 centos6.5_64 ip:1fastdfs_storage_s2 centos6.5_64 ip:2fastdfs_client centos6.5_64 ip:4selinux关闭,iptables关闭。配置tracker:先装libevent,后fastdfs1234567
2、8rootcentos-6.5-x64 #yum install -y gcc gcc-c+rootcentos-6.5-x64 #tar zxvf libevent-2.0.21-stablerootcentos-6.5-x64 #tar zxvf FastDFS_v4.06.tar.gzrootcentos-6.5-x64 #cd libevent-2.0.21-stablerootcentos-6.5-x64 libevent-2.0.21-stable#./configure & make & make installrootcentos-6.5-x64 libevent-2.0.21
3、-stable# cdrootcentos-6.5-x64 #cd FastDFSrootcentos-6.5-x64 FastDFS#sh make.sh & sh make.sh installfastdfs的配置文件路径默认在 /etc/fdfs/rootcentos-6.5-x64 #cd /etc/fdfs/rootcentos-6.5-x64 fdfs#ll总用量 56-rw-rr 1 root root 1463 4月 23 04:10 client.conf-rw-rr 1 root root 858 4月 23 04:10 http.conf-rw-rr 1 root roo
4、t 31172 4月 23 04:10 mime.types-rw-rr 1 root root 7460 4月 23 04:10 storage.conf-rw-rr 1 root root 6621 4月 23 04:10 tracker.confclient.conf 客户端上传配置文件storage.conf 文件存储服务器配置文件tracker.conf 负责均衡调度服务器配置文件http.conf http服务器配置文件(可忽略不用)跟fastdfs相关的命令都在 /usr/local/bin/ 下编辑tracker配置文件:rootcentos-6.5-x64 fdfs#grep
5、 -v “#” tracker.conf | grep -v “$”#tracker.conf 配置文件是否生效,false是生效,true是屏蔽。disabled=false#程序的监听地址,如果不设定则监听所有地址bind_addr=#tracker监听的端口port=22122#连接超时时间connect_timeout=30#tracker在通过网络发送接收数据的超时时间network_timeout=60#数据和日志的存放地点base_path=/home/yuqing/fastdfs#最大连接数max_connections=256#工作线程数一般为cpu个数work_thread
6、s=4#在存储文件时选择group的策略,0:轮训策略 1:指定某一个组 2:负载均衡,选择空闲空间最大的group.store_lookup=2#如果上面的store_lookup选择了1,则这里需要指定一个groupstore_group=group2#在group中的哪台storage做主storage,当一个文件上传到主storage后,就由这台机器同步文件到group内的其他storage上,0:轮训策略 1:根据ip地址排序,第一个 2:根据优先级排序,第一个store_server=0#选择文件上传到storage中的哪个(目录/挂载点),storage可以有多个存放文件的bas
7、e path 0:轮训策略 2:负载均衡,选择空闲空间最大的store_path=0#选择那个storage作为主下载服务器,0:轮训策略 1:主上传storage作为主下载服务器download_server=0#系统预留空间,当一个group中的任何storage的剩余空间小于定义的值,整个group就不能上传文件了reserved_storage_space = 10%#日志信息级别log_level=info#进程以那个用户/用户组运行,不指定默认是当前用户run_by_group=run_by_user=#允许那些机器连接tracker默认是所有机器allow_hosts=*#设置日
8、志信息刷新到disk的频率,默认10ssync_log_buff_interval = 10#检测storage服务器的间隔时间,storage定期主动向tracker发送心跳,如果在指定的时间没收到信号,tracker人为storage故障,默认120scheck_active_interval = 120#线程栈的大小,最小64Kthread_stack_size = 64KB#storage的ip改变后服务端是否自动调整,storage进程重启时才自动调整storage_ip_changed_auto_adjust = true#storage之间同步文件的最大延迟,默认1天storag
9、e_sync_file_max_delay = 86400#同步一个文件所花费的最大时间storage_sync_file_max_time = 300#是否用一个trunk文件存储多个小文件use_trunk_file = false#最小的solt大小,应该小于4KB,默认256bytesslot_min_size = 256#最大的solt大小,如果上传的文件小于默认值,则上传文件被放入trunk文件中slot_max_size = 16MB#trunk文件的默认大小,应该大于4Mtrunk_file_size = 64MBtrunk_create_file_advance = fals
10、etrunk_create_file_time_base = 02:00trunk_create_file_interval = 86400trunk_create_file_space_threshold = 20Gtrunk_init_check_occupying = falsetrunk_init_reload_from_binlog = falseuse_storage_id = falsestorage_ids_filename = storage_ids.confid_type_in_filename = ipstore_slave_file_use_link = falsero
11、tate_error_log = falseerror_log_rotate_time=00:00rotate_error_log_size = 0use_connection_pool = falseconnection_pool_max_idle_time = 3600#http服务是否生效,默认不生效,此项可能在4.0版本后剔除。不起作用且没有此行。http.disabled=false#http服务端口http.server_port=8080#检测storage上http服务的时间间隔, index.htmlrootcentos-6.5-x64 #/usr/local/bin/fdf
12、s_upload_file /etc/fdfs/client.conf index.htmlgroup1/M00/00/00/wKgBM1NW5JmAO_BCAAAAFhSwOfU49.html这个是在storage服务器下的物理路径。在storage_s1服务器查看:rootcentos-6.5-x64 #cd /mnt/fastdfs_storage_data/data/00/00rootcentos-6.5-x64 00#ll总用量 20-rw-rr 1 root root 22 4月 23 05:52 wKgBM1NW5JmAO_BCAAAAFhSwOfU49.html在storage
13、_s2服务器此目录下也会有这个文件,表明上传文件没问题。现在我们需要通过web方式去访问这个文件。在每台storage server上部署web server,直接对外提供HTTP服务,tracker server上不需要部署web server。如果请求文件在当前storage上不存在,通过文件ID反解出源storage,直接请求源storage。我这里用apache来实现访问fastdfs的文件,并且apache为yum安装。想达到访问目的需要在apache中加载fastdfs-apache-module模块。fastdfs-apache-module模块默认不在apache中,需要自己手
14、动编译,加载。在storage_s1和storage_s2中都进行如下配置:12345678910111213141516171819rootcentos-6.5-x64 #wget -c 在编译fastdfs-apache-module时需要apache的某些源文件,需要安装httpd-devel开发工具包。rootcentos-6.5-x64 #yum install -y httpd-develrootcentos-6.5-x64 #tar zxvf fastdfs-apache-module_v1.15.tar.gzrootcentos-6.5-x64 #cd fastdfs-apac
15、he-modulerootcentos-6.5-x64 fastdfs-apache-module#ll总用量 12-rw-rw-r- 1 root root 1726 1月 13 2013 HISTORY-rw-rw-r- 1 root root 1725 5月 22 2011 INSTALLdrwxrwxr-x 2 root root 4096 2月 19 2013 srcrootcentos-6.5-x64 fastdfs-apache-module#cd src/rootcentos-6.5-x64 src#ll总用量 56-rw-rw-r- 1 root root 32266 1月
16、13 2013 common.c-rw-rw-r- 1 root root 3479 1月 3 2012 common.h-rw-rw-r- 1 root root 1350 11月 4 2010 Makefile-rw-rw-r- 1 root root 5039 1月 3 2012 mod_fastdfs.c-rw-rw-r- 1 root root 3869 1月 13 2013 mod_fastdfs.conf-rw-rw-r- 1 root root 160 9月 5 2010 modules.mk这里需要修改Makefile文件:APACHE_BASE_PATH=/usr/loca
17、l/apache2include $(APACHE_BASE_PATH)/build/special.mkAPXS=$(APACHE_BASE_PATH)/bin/apxsAPACHECTL=$(APACHE_BASE_PATH)/bin/apachectl改为:APACHE_BASE_PATH=/etc/httpd #apache安装根目录,根据实际情况修改include /usr/lib64/httpd/build/special.mkAPXS=/usr/sbin/apxsAPACHECTL=/usr/sbin/apachectlspecial.mk文件路径可以通过find查找,apxs和
18、apachectl可通过whereis查找。rootcentos-6.5-x64 src#make/usr/lib64/httpd/build/special.mk:27: /etc/httpd/build/rules.mk: 没有那个文件或目录make: * 没有规则可以创建目标“/etc/httpd/build/rules.mk”。 停止。rootcentos-6.5-x64 src#报错解决方法:rootcentos-6.5-x64 src#mkdir /etc/httpd/buildrootcentos-6.5-x64 src#cp /usr/lib64/httpd/build/*.m
19、k /etc/httpd/build/rootcentos-6.5-x64 src#make/usr/lib64/apr-1/build/libtool silent mode=compile gcc -pthread -Wall -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE=256*1024 -DFDFS_MOD_CONF_FILENAME=”/etc/fdfs/mod_fastdfs.conf” -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -I/usr/local/include/fastdfs -I/usr/
20、local/include/fastcommon/ -I/usr/include/httpd -I. -I/usr/include/apr-1 -prefer-pic -c mod_fastdfs.c & touch mod_fastdfs.slo/usr/lib64/apr-1/build/libtool silent mode=link gcc -pthread -Wall -Wl,-z,relro -lfastcommon -lfdfsclient -o mod_fastdfs.la -rpath /usr/lib64/httpd/modules -module -avoid-versi
21、on mod_fastdfs.lomake通过,然后make installrootcentos-6.5-x64 src#make install/bin/sh: line 1: /etc/httpd/build/instdso.sh: 没有那个文件或目录make: * install-modules-yes 错误 127rootcentos-6.5-x64 src#报错解决方法:rootcentos-6.5-x64 src#cp /usr/lib64/httpd/build/instdso.sh /etc/httpd/build/rootcentos-6.5-x64 src#make ins
22、tall通过。rootcentos-6.5-x64 src#cd /etc/httpd/modules/rootcentos-6.5-x64 modules#ll mod_fastdfs.so-rwxr-xr-x 1 root root 37564 4月 22 21:34 mod_fastdfs.somod_fastdfs.so模块编译完成。编辑mod_fastdfs模块的配置文件:rootcentos-6.5-x64 #vi /etc/fdfs/mod_fastdfs.conftracker_server=0:22122 #修改为tracker server信息url_
23、have_group_name = true #改为truestore_path0=/mnt/fastdfs_storage_data #改为数据存储路径,和storage.conf一样。编辑apache主配置文件:rootcentos-6.5-x64 #vi /etc/httpd/conf/httpd.conf添加两行:LoadModule fastdfs_module modules/mod_fastdfs.so #加载模块alias /group1/M00 /mnt/fastdfs_storage_data/data #虚拟目录映射 #访问/group1/M00时交给fastdfs模块处
24、理sethandler fastdfs重启httpd服务加到开机启动。现在通过浏览器去访问storage服务器:1/group1/M00/00/00/wKgBM1NW5JmAO_BCAAAAFhSwOfU49.html会看到通过echo重定向的内容。再去配置storage_s2,过程跟s1一样,完成后把ip改为2,后面内容不变,一样可以访问到文件。现在我们停掉storage_s2的storaged服务,删掉此文件再去访问2/group1/M00/00/00/wKgBM1NW5JmAO_BCAAAAFhSw
25、OfU49.html发现依旧可以访问到文件,这就是fastdfs模块起到了作用。这个功能就是防止因为数据同步延迟导致无法访问。而去源storage服务器查找文件。到这里配置接近尾声,now,我把fastdfs的tracker和storage管理脚本加到系统中,方便用service管理。进入fastdfs源码包:rootcentos-6.5-x64 #cd FastDFS/init.d/rootcentos-6.5-x64 init.d#ll总用量 8-rwxrwxr-x 1 500 500 1186 8月 15 2010 fdfs_storaged-rwxrwxr-x 1 500 500 11
26、86 8月 15 2010 fdfs_trackerd不用说也能看明白。一个storaged脚本一个trackerd脚本。无需修改即可使用。把各自脚本拷贝到/etc/init.d/下即可。然后就可以通过service fdfs_storaged/fdfs_trackerd start/stop/status管理了。再回到我们的fastdfs_client客户端,为php添加模块:因为fastdfs是基于应用的分布式存储,不像moosefs可以挂载为本地磁盘。fastdfs提供一个api接口实现文件操作。所以要安装php扩展让Fastdfs支持php,在FastDFS的源码包解压后里面有个php
27、_client目录,进入此目录,参照README进行安装:安装此模块需要phpize命令,此命令由php-devel包提供,没有的话安装即可。rootcentos-6.5-x64 php_client#phpizeConfiguring for:PHP Api Version: 20090626Zend Module Api No: 20090626Zend Extension Api No: 220090626rootcentos-6.5-x64 php_client#./configure & make & make installInstalling shared extensions:
28、 /usr/lib64/php/modules/ #提示模块安装到的路径。重定向配置文件到/etc/php.ini:rootcentos-6.5-x64 php_client#cat fastdfs_client.ini /etc/php.ini重启apache。rootcentos-6.5-x64 #php -m | grep fastfastdfs_client看到php加载模块成功。测试:创建一个php文件,代码如下:12345rootcentos-6.5-x64 html#cat test.php然后执行:12345678910111213rootcentos-6.5-x64 html
29、#php test.phparray(5) source_id=int(0)create_timestamp=int(1398203545)file_size=int(22)source_ip_addr=string(12) 1crc32=int(347093493)得到文件信息。完成!接着上次的配置环境,现在将apache改为nginx。在两台storage服务器上配置nginx和fastdfs-nginx模块:storage_s1:下载pcre、nginx、fastdfs的nginx模块,编译:12345678910111213rootcentos-6.5-x64 #
30、wget -c rootcentos-6.5-x64 #tar zxvf fastdfs-nginx-module_v1.15.tar.gzrootcentos-6.5-x64 #tar zxvf pcre-8.12.tar.gzrootcentos-6.5-x64 #tar zxvf nginx-1.5.10.tar.gzrootcentos-6.5-x64 #cd pcre-8.12rootcentos-6.5-x64 pcre-8.12#./configure -prefix=/usr/rootcentos-6.5-x64 pcre-8.12#make & make installroo
31、tcentos-6.5-x64 pcre-8.12#cd .rootcentos-6.5-x64 #cd nginx-1.5.10rootcentos-6.5-x64 nginx-1.5.10#useradd www -s /sbin/nologinrootcentos-6.5-x64 nginx-1.5.10#yum install zlib zlib-devel -yrootcentos-6.5-x64 nginx-1.5.10#./configure -prefix=/usr/local/nginx -user=www -group=www -add-module=./fastdfs-n
32、ginx-module/src/rootcentos-6.5-x64 nginx-1.5.10#make & make install配置nginx:rootcentos-6.5-x64 #vi /usr/local/nginx/conf/nginx.conf在server段中添加:1234location /group1/M00 root /mnt/fastdfs_storage_data/data;ngx_fastdfs_module;配置etc/fdfs/mod_fastdfs.conf配置文件(编译时会自动拷贝过去):rootcentos-6.5-x64 fdfs#grep -v “#” mod_fastdfs.conf | grep -v “$”connect_timeout=2network_timeout=30base_path=/tmpload_fdfs_parameters_from_tracker=truestorage_
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 32575-2026发电工程数据移交
- 护理工作中的护理评价课件
- 护理技术与患者沟通技巧
- 2025年家庭健康管理师 床垫周期数据的个性化指导服务
- 护理评估中的重症监护
- 压缩机装配调试工诚信道德考核试卷含答案
- 油气管道保护工达标知识考核试卷含答案
- 办公设备与耗材再制造工岗前风险评估与管理考核试卷含答案
- 2026年新科教版高中高一历史上册第一单元先秦政治制度特征卷含答案
- 摊商岗前安全专项考核试卷含答案
- JJG 688-2025汽车排放气体测试仪检定规程
- 【15万吨日供水量水厂设计中反应沉淀池设计计算过程案例2300字】
- 《铁路线路养护与维修》课件 2.1.5垫板修正作业
- T/CNCA 014-2022改性镁渣基胶凝材料
- 2025年安徽铜陵港航投资建设有限责任公司招聘笔试参考题库附带答案详解
- TCTBA 001-2019 非招标方式采购代理服务规范
- 1完整版本.5kw机器人专用谐波减速器设计
- 2024版学校师生接送车合作合同版B版
- CYC指标(指南针成本均线)使用详解
- 《国家电网公司电力安全工作规程(火电厂动力部分、水电厂动力部分)》
- 【MOOC】健康传播:基础与应用-暨南大学 中国大学慕课MOOC答案
评论
0/150
提交评论