码迷,mamicode.com
首页 > 其他好文 > 详细

FastDFS集群搭建

时间:2018-08-25 14:19:09      阅读:453      评论:0      收藏:0      [点我收藏+]

标签:启动   efi   info   oca   dir   搭建   查看   trunk   count   

所需软件包

https://github.com/happyfish100/libfastcommon
https://github.com/happyfish100/fastdfs
https://github.com/happyfish100/fastdfs-nginx-module
https://nginx.org/en/
yum install -y libevent gcc pcre-devel zlib-devel

1.安装libfastcommon

unzip libfastcommon*
cd libfastcommon*
./make.sh
./make.sh install

2.安装fastdfs

unzip fastdfs*
cd fastdfs*
./make.sh
./make.sh install
cp init.d/* /etc/init.d/
cp conf/*  /etc/fdfs/

3.安装fastdfs-nginx-module & nginx

unzip fastdfs-nginx-module*
cd fastdfs-nginx-module/src
cp mod_fastdfs.conf /etc/fdfs
tar zcvf nginx*
cd nginx*
./configure --add-module=../fastdfs-nginx-module/src/ --prefix=/usr/local/nginx
make && make install

tracker配置

mkdir -p /home/fastdfs/tracker
vi /etc/fdfs/tracker.conf

base_path=/home/fastdfs/tracker

其他参数根据业务需求调整

storage配置

mkdir -p /home/fastdfs/storage
vi /etc/fdfs/storage

group_name=group1
base_path=/home/fastdfs/storage
store_path_count=2         
store_path0=/storage1
store_path1=/storage2
tracker_server=192.168.1.103:22122
tracker_server=192.168.1.104:22122

client配置

vi /etc/fdfs/client.conf

base_path=/home/fastdfs/client
tracker_server=192.168.1.103:22122
tracker_server=192.168.1.104:22122

fastdfs-nginx-module配置

mkdir -p /home/fastdfs/mod_fastdfs
vi /etc/fdfs/mod_fastdfs.conf

base_path=/home/fastdfs/mod_fastdfs
tracker_server=192.168.1.103:22122
tracker_server=192.168.1.104:22122
group_name=group1
url_have_group_name = true
store_path_count = 2
store_path0=/storage1
store_path1=/storage2
group_count = 1
[group1]
group_name=group1
storage_server_port=23000
store_path_count=2
store_path0=/storage1
store_path1=/storage2

nginx 配置
    server {
        listen 8080;
        server_name 192.168.1.103;
        location ~/group([0-9])/M00{
                ngx_fastdfs_module;
        }

        location ~/group([0-9])/M01{
                ngx_fastdfs_module;
        }

    }

启动服务

/etc/init.d/fdfs_tracker start
/etc/init.d/fdfs_storage start

检查服务启动状态

ss -tnlp | grep fdfs

上传文件测试:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload test.jpg
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf test.jpg

查看文件同步状态:

cd /home/fastdfs/stroage/data/sync
cat 192.168.1.104_23000.mark

binlog_index=0      #对应于哪个binlog
binlog_offset=1952  #偏移量,同步机器如果当前是文件同步完成状态,这里的值是一样的
need_sync_old=0     #是否需要同步旧文件给对方
sync_old_done=0     #若需要同步旧文件,那么旧文件是否同步完成
until_timestamp=0   #上次同步时间结点
scan_row_count=32   #总记录数
sync_row_count=32   #已同步记录数


binlog记录:
cat binlog.000

fastdfs常用命令:

上传文件:
fdfs_upload_appender <config_file> <local_filename>
fdfs_upload_file <config_file> <local_filename> [storage_ip:port] [store_path_index]
查看文件信息:
fdfs_file_info <config_file> <file_id>
文件删除:
fdfs_delete_file <config_file> <file_id>
下载文件:
fdfs_download_file <config_file> <file_id> [local_filename] [<download_offset> <download_bytes>]
运行状态及操作:
fdfs_monitor <config_file> [-h <tracker_server>] [list|delete|set_trunk_server <group_name> [storage_id]]

fastDFS磁盘恢复
1.停止fastdfs服务
2.更换硬盘,格式化,重新挂载
3.启动fastdfs服务

FastDFS集群搭建

标签:启动   efi   info   oca   dir   搭建   查看   trunk   count   

原文地址:https://www.cnblogs.com/erdancry/p/9533104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!