当前位置:   article > 正文

fastdfs双节点集群部署_双tracker双storage

双tracker双storage

fastdfs双节点集群部署

部署主机

方案采用双tracker双storage的架构

IP部署内容创建目录
1.1.1.15tracker,storage/data/fastdfs/tracker
1.1.1.16tracker,storage/data/fastdfs/storage
/data/fastdfs/storage/data

编译安装libfastcommon-1.0.47

cd /usr/local/src
tar -zxf libfastcommon-1.0.47.tar.gz
cd libfastcommon-1.0.47
./make.sh
./make.sh install
  • 1
  • 2
  • 3
  • 4
  • 5

编译安装fastdfs

cd /usr/local/src
tar -zxf fastdfs-6.07.tar.gz
cd fastdfs-6.07
./make.sh
./make.sh install


cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf #tracker节点
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf #storage节点
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf #客户端文件,测试用
cp /usr/local/src/FastDFS/fastdfs-6.07/conf/http.conf /etc/fdfs/ #供nginx访问使用
cp /usr/local/src/FastDFS/fastdfs-6.07/conf/mime.types /etc/fdfs/ #供nginx访问使用
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

tracker配置

#修改tracker.conf文件
$ vim /etc/fdfs/tracker.conf
port = 22122
base_path = /data/fastdfs/tracker
max_connections = 10000
accept_threads = 100
work_threads = 8

#配置启动文件
$vim /usr/lib/systemd/system/fastdfs-tracker.service
[Unit]
Description=The FastDFS File server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
ExecRestart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

[Install]
WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
systemctl daemon-reload
systemctl enable fastdfs-tracker.service
systemctl start fastdfs-tracker.service
netstat -apn|grep 22122
  • 1
  • 2
  • 3
  • 4

storage配置

#修改如下配置
$ vim /etc/fdfs/storage.conf
port = 23000
base_path = /data/fastdfs/storage
store_path0 = /data/fastdfs/storage/data
max_connections = 10000
accept_threads = 100
work_threads = 8
tracker_server=1.1.1.15:22122
tracker_server=1.1.1.16:22122

$ vim /usr/lib/systemd/system/fastdfs-storage.service

[Unit]
Description=The FastDFS File server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
ExecRestart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

[Install]
WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
systemctl daemon-reload
systemctl enable fastdfs-storage.service
systemctl start fastdfs-storage.service
netstat -tulnp|grep 23000 #查看服务是否启动,端口是否打开
  • 1
  • 2
  • 3
  • 4

查看集群状态

$ fdfs_monitor /etc/fdfs/storage.conf list
[2022-11-22 15:15:12] DEBUG - base_path=/data/fastdfs/storage, connect_timeout=5, network_timeout=60, tracker_server_count=2, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=1, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

server_count=2, server_index=1

tracker server is 1.1.1.16:22122

group count: 1

Group 1:
group name = group1
disk total space = 8,902 MB
disk free space = 7,132 MB
trunk free space = 0 MB
storage server count = 2
active server count = 2
storage server port = 23000
...
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

client配置

#修改如下配置
$ vim /etc/fdfs/client.conf
base_path = /data/fastdfs
tracker_server = 1.1.1.15:22122
tracker_server = 1.1.1.16:22122

#测试上传文件,有返回存储地址表示成功
$ fdfs_upload_file /etc/fdfs/client.conf apr-1.5.2.tar.gz
group1/M00/00/00/AQEBEGN8eDaAMRwAAA-9vdbUCG4.tar.gz
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

nginx配置

yum -y install zlib zlib-devel openssl-devel
cd /usr/local/src/FastDFS
tar -zxf fastdfs-nginx-module-1.22.tar.gz
cd fastdfs-nginx-module-1.22
#修改fastdfs-nginx-module-1.22/src/config文件,修改如下: 
ngx_module_incs="/usr/include/fastdfs /usr/include/fastcommon/" 
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

cp -prf /usr/local/src/FastDFS/fastdfs-nginx-module-1.22 /etc/fdfs/
cd /usr/local/src
tar -zxf nginx-1.22.0.tar.gz
cd nginx-1.22.0
./configure --prefix=/usr/local/nginx --user=webadm --group=webadm --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-stream --add-module=/etc/fdfs/fastdfs-nginx-module-1.22/src
make && make install


#修改mod_fastdfs.conf
cp -p /etc/fdfs/fastdfs-nginx-module-1.22/src/mod_fastdfs.conf /etc/fdfs/
$ vim /etc/fdfs/mod_fastdfs.conf
url_have_group_name=true
base_path=/data/fastdfs
store_path0=/data/fastdfs/storage/data
tracker_server=1.1.1.15:22122
tracker_server=1.1.1.16:22122


#修改nginx配置文件
$ vim /usr/local/nginx/conf/nginx.conf
...
include /usr/local/nginx/conf/conf.d/*.conf
...

$ vim /usr/local/nginx/conf/conf.d/fdfs.conf
upstream fdfs_group1 {
    server 1.1.1.15:8888 weight=1 max_fails=2 fail_timeout=30s;
    server 1.1.1.16:8888 weight=1 max_fails=2 fail_timeout=30s;
}
server {
    listen 80;
    server_name localhost 1.1.1.15;
    location /group1 {
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_pass http://fdfs_group1;
    }
}
server {
        listen 8888; ## 该端口为storage.conf中的http.server_port相同
        server_name 1.1.1.15;
        location ~/group1 {
            root /data/fastdfs/storage/data;
            ngx_fastdfs_module;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }



  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

Keepalived配置

略。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/169987
推荐阅读
相关标签
  

闽ICP备14008679号