龙空技术网

FastDfs-集群安装和配置

IT动力 349

前言:

此时大家对“nginxfastdfs安装”大约比较讲究,我们都需要分析一些“nginxfastdfs安装”的相关知识。那么小编在网上搜集了一些对于“nginxfastdfs安装””的相关文章,希望大家能喜欢,各位老铁们快快来学习一下吧!

1、环境准备

3台centos7虚拟机

跟踪服务器

存储服务器

nginx

192.168.244.128

192.168.244.128(group1)

192.168.244.128

192.168.244.129

192.168.244.129(group1)

192.168.244.129

192.168.244.130

192.168.244.130(group2)

192.168.244.130

参照单机方式安装

2、修改配置文件

tracker.conf

和单机版本一致

storage.conf

192.168.244.128(group1), 192.168.244.129(group1)两个配置文件

# 组名称group_name=group1# 基础路径,和单机保持一致base_path=/home/fastdfs# 磁盘或挂载点数量store_path_count=1# 磁盘路径store_path0=/home/fastdfs# tracker server集群地址,有几台服务器就使用几行配置tracker_server=192.168.244.128:22122tracker_server=192.168.244.129:22122tracker_server=192.168.244.130:22122# http访问端口http.server_port=8888

192.168.244.130(group2)

# 组名称 这里是另外一个groupgroup_name=group2# 基础路径,和单机保持一致base_path=/home/fastdfs# 磁盘或挂载点数量store_path_count=1# 磁盘路径store_path0=/home/fastdfs# tracker server集群地址,有几台服务器就使用几行配置tracker_server=192.168.244.128:22122tracker_server=192.168.244.129:22122tracker_server=192.168.244.130:22122# http访问端口http.server_port=8888

mod_fastdfs.conf

192.168.244.128(group1), 192.168.244.129(group1)两个配置文件

# 跟踪服务器集群地址tracker_server=192.168.244.128:22122tracker_server=192.168.244.129:22122tracker_server=192.168.244.130:22122# storage服务器端口storage_server_port=23000# 组名称,自己本地的storage属于哪个组,就配置那个组的名称group_name=group1# 磁盘或挂载点数量store_path_count=1# 磁盘路径store_path0=/home/fastdfs

192.168.244.130(group2)

# 跟踪服务器集群地址tracker_server=192.168.244.128:22122tracker_server=192.168.244.129:22122tracker_server=192.168.244.130:22122# storage服务器端口storage_server_port=23000# 组名称,自己本地的storage属于哪个组,就配置那个组的名称group_name=group2# 磁盘或挂载点数量store_path_count=1# 磁盘路径store_path0=/home/fastdfs

client.conf

三台机器一样

# 基础路径base_path = /home/fastdfs# 跟踪服务器集群地址tracker_server = 192.168.244.128:22122tracker_server = 192.168.244.129:22122tracker_server = 192.168.244.130:22122
3、重启tracker, storage, nginx

分别在三台机器执行

# 重启trackerfdfs_trackerd /etc/fdfs/tracker.conf restart# 重启storagefdfs_storaged /etc/fdfs/storage.conf restart# 重启nginx/usr/local/nginx/sbin/nginx -s reload
4、测试上传下载

使用client上传

[root@centos01 fdfs]# fdfs_upload_file /etc/fdfs/client.conf /opt/test/text.jpggroup1/M00/00/00/wKj0gGIm_qSAGrEKAABDhrJAkTU406.jpg[root@centos01 fdfs]# fdfs_upload_file /etc/fdfs/client.conf /opt/test/text.jpggroup2/M00/00/00/wKj0gmIm_qiAcjR_AABDhrJAkTU752.jpg

使用client查看文件信息

# 执行命令查看group1fdfs_file_info /etc/fdfs/client.conf group1/M00/00/00/wKj0gGIm_qSAGrEKAABDhrJAkTU406.jpg# 结果显示source storage id: 0source ip address: 192.168.244.128file create timestamp: 2022-03-08 14:58:44file size: 17286file crc32: 2990575925 (0xB2409135)# 执行命令查看group2fdfs_file_info /etc/fdfs/client.conf group2/M00/00/00/wKj0gmIm_qiAcjR_AABDhrJAkTU752.jpg# 结果显示source storage id: 0source ip address: 192.168.244.130file create timestamp: 2022-03-08 14:58:48file size: 17286file crc32: 2990575925 (0xB2409135)

使用nginx访问图片

5、FastDFS集群优化

1、最大连接数优化

在tracker.conf和storage.conf中均存在该配置项

# max concurrent connections this server support# you should set this parameter larger, eg. 10240# default value is 256# 默认值是256,表示一次性预分配这么多。到那时不能超过/etc/secerity/limits.conf中软硬件的限制max_connections = 1024

可以配置limits.conf

* soft nofile 65535* hard nofile 65535

2、工作线程数量配置

在tracker.conf和storage.conf中均存在该配置项

# work thread count# work threads to deal network io# default value is 4# since V2.00 一般和CPU的数量相等即可work_threads = 4

3、storage目录数设置

在storage.conf中存在该配置项

# subdir_count  * subdir_count directories will be auto created under each # store_path (disk), value can be 1 to 256, default value is 256。适当减小效率会更高subdir_count_per_path=256

4、storage磁盘读写线程

在storage.conf中存在该配置项

# if disk read / write separated##  false for mixed read and write##  true for separated read and write# default value is true# since V2.00# 读写分离是否开启,默认开启disk_rw_separated = true# disk reader thread count per store base path# for mixed read / write, this parameter can be 0# default value is 1# since V2.00# 单个磁盘读线程数量disk_reader_threads = 1# disk writer thread count per store base path# for mixed read / write, this parameter can be 0# default value is 1# since V2.00# 单个磁盘写线程数量disk_writer_threads = 1

如果机器性能好,可以适当增加读写线程的数量。

标签: #nginxfastdfs安装