科技常识:nginx的FastDFS分布式存储模块测试方法

2021-04-10 02:40:28
导读今天小编跟大家讲解下有关科技常识:nginx的FastDFS分布式存储模块测试方法,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关科

今天小编跟大家讲解下有关科技常识:nginx的FastDFS分布式存储模块测试方法,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关科技常识:nginx的FastDFS分布式存储模块测试方法的相关资料,希望小伙伴会喜欢也能够帮助大家。

再回过头来看FastDFS更新很快,还看到fastdfs-nginx-module_v1.01.tar.gz nginx模块,所以今天在一台测试机上测试了・测试几天看稳定不稳定,在考虑换掉浪费资源的 lustre !

环境:

storage1:192.168.6.100storage2:192.168.6.101tracker:192.168.6.102

1. 在每个机器上,下载安装 FastDFS

nginx $> wget http://fastdfs.googlecode.com/files/FastDFS_v2.04.tar.gz# 解压nginx $> tar zxvf FastDFS_v2.04.tar.gznginx $> cd FastDFS# 因为我是给nginx添加fastdfs模块,所以不需要fastdfs支持 http 所以我就不需要去掉 #WITH_HTTPD=1 前的注释了,直接编译nginx $> ./make.shnginx $> ./make.sh install

2.修改tracker 和 storage 的配置文件# tracker 的修改

tracker $> vim /etc/fdfs/tracker.confdisabled=false#配置是否生效bind_addr=192.168.6.102#绑定IPport=22122#服务端口connect_timeout=30#连接超时时间network_timeout=60# tracker server的网络超时,单位为秒。base_path=/home/yangzi#目录地址,里面会创建data(存放存储服务器信息)、logs,日志文件max_connections=256#系统提供服务最大连接数work_threads=4#线程数,通常设置CPU数store_lookup=2上传组(卷) 的方式 0:轮询方式 1: 指定组 2: 平衡负载(选择最大剩余空间的组(卷)上传)这里如果在应用层指定了上传到一个固定组,那么这个参数被绕过store_group=group1当上一个参数设定为1 时 (store_lookup=1,即指定组名时),必须设置本参数为系统中存在的一个组名。如果选择其他的上传方式,这个参数就没有效了store_server=0选择哪个storage server 进行上传操作(一个文件被上传后,这个storage server就相当于这个文件的storage server源,会对同组的storage server推送这个文件达到同步效果)# 0: 轮询方式# 1: 根据ip 地址进行排序选择第一个服务器(IP地址最小者)# 2: 根据优先级进行排序(上传优先级由storage server来设置,参数名为upload_priority)store_path=0选择storage server 中的哪个目录进行上传。storage server可以有多个存放文件的base path(可以理解为多个磁盘)。# 0: 轮流方式,多个目录依次存放文件# 2: 选择剩余空间最大的目录存放文件(注意:剩余磁盘空间是动态的,因此存储到的目录或磁盘可能也是变化的)download_server=0 选择哪个 storage server 作为下载服务器# 0: 轮询方式,可以下载当前文件的任一storage server# 1: 哪个为源storage server 就用哪一个 (前面说过了这个storage server源 是怎样产生的) 就是之前上传到哪个storage server服务器就是哪个了reserved_storage_space = 4GBstorage server 上保留的空间,保证系统或其他应用需求空间(指出 如果同组的服务器的硬盘大小一样,以最小的为准,也就是只要同组中有一台服务器达到这个标准了,这个标准就生效,原因就是因为他们进行备份)log_level=info#选择日志级别run_by_group=#操作系统运行FastDFS的用户组run_by_user=#操作系统运行FastDFS的用户allow_hosts=*#可以连接到此 tracker server 的ip范围(对所有类型的连接都有影响,包括客户端,storage server)sync_log_buff_interval = 10# 同步或刷新日志信息到硬盘的时间间隔,单位为秒# 注意:tracker server 的日志不是时时写硬盘的,而是先写内存。check_active_interval = 120# 检测 storage server 存活的时间隔,单位为秒。# storage server定期向tracker server 发心跳,如果tracker server在一个check_active_interval内还没有收到storage server的一次心跳,那边将认为该storage server已经下线。所以本参数值必须大于storage server配置的心跳时间间隔。通常配置为storage server心跳时间间隔的2倍或3倍。thread_stack_size = 64KB# 线程栈的大小。FastDFS server端采用了线程方式。更正一下,tracker server线程栈不应小于64KB,不是512KB。# 线程栈越大,一个线程占用的系统资源就越多。如果要启动更多的线程(V1.x对应的参数为max_connections,V2.0为work_threads),可以适当降低本参数值。storage_ip_changed_auto_adjust = true# 这个参数控制当storage server IP地址改变时,集群是否自动调整。注:只有在storage server进程重启时才完成自动调整。storage_sync_file_max_delay = 86400# V2.0引入的参数。存储服务器之间同步文件的最大延迟时间,缺省为1天。根据实际情况进行调整storage_sync_file_max_time = 300# V2.0引入的参数。存储服务器同步一个文件需要消耗的最大时间,缺省为300s,即5分钟。http.disabled=true# HTTP服务是否不生效 当然编译的时候我已经把 with_httpd宏去掉了,http.server_port=80# HTTP服务端口# 下列参数只有 开启http服务才有用http.check_alive_interval=30http.check_alive_type=tcphttp.check_alive_uri=/status.htmlhttp.need_find_content_type=true

#两台 storage.conf的修改

storage $> vim /etc/fdfs/storage.confdisabled=false#配置是否生效group_name=group1#storage所在组(卷)bind_addr=192.168.6.100# 绑定IP,另一太 storage IP为 192.168.6.101client_bind=true#bind_addr通常是针对server的。当指定bind_addr时,本参数才有效。port=23000# 是storage 服务端口connect_timeout=30# 连接超时时间,针对socket套接字函数connectnetwork_timeout=60# storage server 网络超时时间,单位为秒。heart_beat_interval=30# 心跳间隔时间,单位为秒stat_report_interval=60# storage server向tracker server报告磁盘剩余空间的时间间隔,单位为秒。base_path=/home/eric# base_path 目录地址,根目录必须存在 子目录会自动生成# 会产生data(数据存储地方)、 logs日志文件max_connections=256# 最大连接数buff_size = 256KB# 设置队列结点的buffer大小。work_threads=4# 工作线程数disk_rw_separated = true# 磁盘IO读写是否分离,缺省是分离的。disk_reader_threads = 1# 针对单个存储路径的读线程数,缺省值为1disk_writer_threads = 1# 针对单个存储路径的写线程数,缺省值为1sync_wait_msec=200# 同步文件时,如果从binlog中没有读到要同步的文件,休眠N毫秒后重新读取,0表示不休眠,立即再次尝试读取。sync_interval=0# 同步上一个文件后,再同步下一个文件的时间间隔,单位为毫秒,0表示不休眠,直接同步下一个文件。sync_start_time=00:00sync_end_time=23:59# 允许系统同步的时间段 (默认是全天) 。一般用于避免高峰同步产生一些问题而设定,相信sa都会明白。write_mark_file_freq=500# 把storage的mark文件定期同步到磁盘的时间间隔,单位为秒store_path_count=1# 存放文件时storage server支持多个路径(例如磁盘)。这里配置存放文件的基路径数目,通常只配一个目录。store_path0=/home/eric# 逐一配置store_path个路径,索引号基于0。注意配置方法后面有0,1,2 ......,需要配置0到store_path - 1。# 如果不配置base_path0,那边它就和base_path对应的路径一样。subdir_count_per_path=32# FastDFS存储文件时,采用了两级目录。这里配置存放文件的目录个数tracker_server=192.168.6.188:22122# tracker_server 的列表 要写端口的哦log_level=info# 日志级别run_by_group=# 运行storage 用户组run_by_user=# 运行storage 用户allow_hosts=*# 允许连接IP列表file_distribute_path_mode=0# 文件在data目录下分散存储策略。# 0: 轮流存放# 1: 随机存储file_distribute_rotate_count=100# 当上面的参数file_distribute_path_mode配置为0(轮流存放方式)时,本参数有效。#当一个目录下的文件存放的文件数达到本参数值时,后续上传的文件存储到下一个目录中fsync_after_written_bytes=0# 当写入大文件时,每写入N个字节,调用一次系统函数fsync将内容强行同步到硬盘。0表示从不调用fsyncsync_log_buff_interval=10# 同步或刷新日志信息到硬盘的时间间隔,单位为秒sync_binlog_buff_interval=60# 同步binglog(更新操作日志)到硬盘的时间间隔,单位为秒sync_stat_file_interval=300# 把storage的stat文件同步到磁盘的时间间隔,单位为秒。thread_stack_size=512KB# 线程栈的大小。FastDFS server端采用了线程方式。# 线程栈越大,一个线程占用的系统资源就越多。upload_priority=10本storage server作为源服务器,上传文件的优先级,可以为负数。值越小,优先级越高。这里就和 tracker.conf 中store_server= 2时的配置相对应了if_alias_prefix=check_file_duplicate=0# 是否检测上传文件已经存在。如果已经存在,则不存在文件内容,建立一个符号链接以节省磁盘空间。 结合 fastdfh使用的。 1是检测,0是不检测,我们不使用fastdfh 当然 0 key_namespace=FastDFS# 当上个参数设定为1 或 yes时 (true/on也是可以的) , 在FastDHT中的命名空间keep_alive=0# 与FastDHT servers 的连接方式 (是否为持久连接) # 下面是http的配置了就不多说了http.disabled=truehttp.domain_name=http.server_port=80http.trunk_size=256KBhttp.need_find_content_type=true

3.建立tracker 和 storage 的根目录

# trackertracker $> mkdir -p /home/eric# storagestorage $> mkdir -p /home/yangzi

4.在 一台storage上下载,比如我在 192.168.6.100上下载 nginx 和 fastdfs-nginx-module 模块

storage $> wget http://www.nginx.org/download/nginx-0.8.53.tar.gzstorage $> svn export http://fastdfs-nginx-module.googlecode.com/svn/trunk/ fastdfs-nginx-module-read-only

5.编译安装 nginx 附带 fastdfs-nginx-module 模块

storage $> tar zxvf nginx-0.8.53.tar.gzstorage $> cd nginx-0.8.53storage $> ./configure --prefix=/usr/local/nginx --add-module=/root/fastdfs-nginx-module-read-only/srcstorage $> makestorage $> make install# 拷贝mod_fastdfs.conf 到/etc/fdfs/storage $> cp /root/fastdfs-nginx-module-read-only/src/mod_fastdfs.conf /etc/fdfs/

6.修改 nginx 配置文件增加

storage $> vim /usr/local/nginx/conf/nginx.conf

# 增加一下location /M00 {alias /home/eric/data;ngx_fastdfs_module;}

7. 给 storage 的存储目录做一个软连接

storage $> ln -s /home/yangzi/data /home/yangzi/data/M00

8. 启动两台 storage 和tracker nginx

# 启动 trackertracker $> /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf# 启动 storagestorage $> /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf# 启动 storage2storage2 $> /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf#在 storage启动 nginxstorage $> /usr/local/nginx/sbin/nginx

9、上传文件测试。# 修改客户端配置文件

storage $> vim /etc/fdfs/client.confconnect_timeout=30network_timeout=60base_path=/home/yangzitracker_server=192.168.6.102:22122log_level=info#下面参数无所谓了反正没有用到http 服务http.tracker_server_port=80storage $> vim a.htmltest FastDFS!storage $> /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload a.htmlThis is FastDFS client test program v2.04Copyright (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.base_path=/home/yangzi, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0tracker_query_storage_store_list_without_group: server 1. group_name=group1, ip_addr=192.168.6.100, port=23000group_name=group1, ip_addr=192.168.6.100, port=23000storage_upload_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgGvEz3Y9MAAAAAAAAADigvbpc73.htmlsource ip address: 192.168.6.100file timestamp=2010-12-02 17:16:03file size=14file crc32=674197143file url: http://192.168.6.100/group1/M00/00/00/wKgGvEz3Y9MAAAAAAAAADigvbpc73.htmlstorage_upload_slave_by_filenamegroup_name=group1, remote_filename=M00/00/00/wKgGvEz3Y9MAAAAAAAAADigvbpc73_big.htmlsource ip address: 192.168.6.100file timestamp=2010-12-02 17:16:03file size=14file crc32=674197143file url: http://192.168.6.100/group1/M00/00/00/wKgGvEz3Y9MAAAAAAAAADigvbpc73_big.html

打开IE浏览器访问:本文出自 “linuxer” 博客,请务必保留此出处http://deidara.blog.51cto.com/400447/440175

来源:爱蒂网

免责声明:本文由用户上传,如有侵权请联系删除!

猜你喜欢

最新文章