美文网首页
Centos7下FastDFS集群搭建

Centos7下FastDFS集群搭建

作者: Panama_228b | 来源:发表于2020-03-25 16:23 被阅读0次

    1 安装包准备

    1. libfastcommon 需要在tracker,storage 节点分别安装。
    2. 在storage节点需要安装nginx,fastdfs-nginx-module(fastdfs之前内置了http server,现在如果需要直接通过http下载需要安装nginx,fastdfs-nginx-module)
    3. fastdfs-nginx-module group组中数据同步延迟问题,可以将请求重定向他其他节点。

    2 环境准备

    简易集群部署,我这里是最小环境安装,使用了2台机器 10.0.3.27,10.0.3.28 Centos7系统。

    实际环境中:可以单独部署tracker集群. 程序Client上传文件的时候sdk连接tracker集群,下载的时候,可以加几台机器部署一层Nginx+Keepalived ,将请求转发到 storage节点上的Nginx。
    我这里将tracker,storage部署到了一起。
    10.0.3.27 部署 tracker,storage(nginx,fastdfs-nginx-module)
    10.0.3.28 部署 tracker,storage(nginx,fastdfs-nginx-module)

    3 安装

    3.1 安装libfastcommon

    此lib库为基础lib在tracker,storage都依赖了。需要在10.0.3.27,10.0.3.28分别安装。解压下载下来的libfastcommon包.在解压目录执行./make.sh,执行完毕后执行./make.sh install.

    [root@sybj-int-26 libfastcommon-1.0.43]# ./make.sh install
    mkdir -p /usr/lib64
    mkdir -p /usr/lib
    mkdir -p /usr/include/fastcommon
    install -m 755 libfastcommon.so /usr/lib64
    install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h json_parser.h buffered_file_writer.h /usr/include/fastcommon
    if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi
    

    3.2 安装fastdfs

    3.2.1 编译fastdfs安装

    将下载下来的fastdfs解压,进入到解压目录执行./make.sh 然后执行./make.sh install

    [root@sybj-int-26 fastdfs-6.06]# ./make.sh install
    mkdir -p /usr/bin
    mkdir -p /etc/fdfs
    cp -f fdfs_trackerd /usr/bin
    if [ ! -f /etc/fdfs/tracker.conf.sample ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf.sample; fi
    if [ ! -f /etc/fdfs/storage_ids.conf.sample ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf.sample; fi
    mkdir -p /usr/bin
    mkdir -p /etc/fdfs
    cp -f fdfs_storaged  /usr/bin
    if [ ! -f /etc/fdfs/storage.conf.sample ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf.sample; fi
    mkdir -p /usr/bin
    mkdir -p /etc/fdfs
    mkdir -p /usr/lib64
    mkdir -p /usr/lib
    

    fastdfs的可执行文件安装到了:/usr/bin/ 目录 配置文件在 /etc/fdfs/目录

    3.2.1 配置Tracker
    # 进入配置文件目录
    cd /etc/fdfs
    # 拷贝出一个tracker.conf
    cp tracker.conf.sample tracker.conf
    # 修改配置
    vim tracker.conf
    

    \color{red}{配置项}

    # is this config file disabled
    # false for enabled 启用配置
    # true for disabled
    disabled = false
    
    # bind an address of this host
    # empty for bind all addresses of this host 将绑定到0.0.0.0
    bind_addr =
    
    # the tracker server port 默认端口
    port = 22122
    
    # connect timeout in seconds
    # default value is 30
    # Note: in the intranet network (LAN), 2 seconds is enough.
    connect_timeout = 5
    
    # network timeout in seconds for send and recv
    # default value is 30
    network_timeout = 60
    
    # 改变一下 tracker server 的工作目录和日志目录
    # 此目录需要提前创建好
    # the base path to store data and log files
    base_path = /opt/ylbzj/fastdfs_tracker_data
    # 最大连接数
    # max concurrent connections this server support
    # you should set this parameter larger, eg. 10240
    # default value is 256
    max_connections = 1024
    
    # 处理连接的accept线程数,可根据CPU核数而定
    # accept thread count
    # default value is 1 which is recommended
    # since V4.07
    accept_threads = 4
    
    # 工作线程数量 ,根据CPU数量而定
    # work thread count
    # work threads to deal network io
    # default value is 4
    # since V2.00
    work_threads = 64
    
    # tracker 选择storage group 时的策略
    # the method for selecting group to upload files
    # 0: round robin
    # 1: specify group
    # 2: load balance, select the max free space group to upload file
    store_lookup = 2
    
    # 如果指定store_lookup = 1 的时候,指定特殊组
    # which group to upload file
    # when store_lookup set to 1, must set store_group to the group name
    store_group = group2
    
    # 我理解的是同一个组内storage server的选择策略
    # which storage server to upload file
    # 0: round robin (default)
    # 1: the first server order by ip address
    # 2: the first server order by priority (the minimal)
    # Note: if use_trunk_file set to true, must set store_server to 1 or 2
    store_server = 0
    
    # 多磁盘配置,选择策略
    # which path (means disk or mount point) of the storage server to upload file
    # 0: round robin
    # 2: load balance, select the max free space path to upload file
    store_path = 0
    
    # which storage server to download file
    # 0: round robin (default)
    # 1: the source storage server which the current file uploaded to
    download_server = 0
    
    # storage server 能使用磁盘的 总磁盘 * (100-X) / 100 = 可使用磁盘
    # reserved storage space for system or other applications.
    # if the free(available) space of any stoarge server in 
    # a group <= reserved_storage_space, no file can be uploaded to this group.
    # bytes unit can be one of follows:
    ### G or g for gigabyte(GB)
    ### M or m for megabyte(MB)
    ### K or k for kilobyte(KB)
    ### no unit for byte(B)
    ### XX.XX% as ratio such as: reserved_storage_space = 10%
    reserved_storage_space = 20%
    

    没有列举全部配置,其他的配置都是默认配置。

    咱们目前在2台机器上安装tracker server,以上步骤在另一台10.0.3.28上同样执行一样,将本次修改好的配置文件同步到10.0.3.28. 确保base_path指定的目录已经创建了

         scp tracker.conf root@10.0.3.28:/etc/fdfs/
    

    分别在两台机器上启动tracker server

    /etc/init.d/fdfs_trackerd start
    

    查看是否启动成功

    root@sybj-int-27 ~]# ps aux|grep dfs
    root      79642  0.0  0.0 107000  5932 ?        Sl   14:23   0:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
    root      79763  0.0  0.0 112652   920 pts/0    S+   14:24   0:00 grep --color=auto dfs
    [root@sybj-int-27 ~]# 
    

    两台tracker server 安装完毕!

    3.2.2 配置Storage Server
    # 进入配置文件目录
    cd /etc/fdfs
    # 拷贝出一个storage.conf
    cp storage.conf.sample storage.conf
    # 修改配置
    vim storage.conf
    

    \color{red}{配置项}

    # 本地Storage server 的组
    # the name of the group this storage server belongs to
    # comment or remove this item for fetching from tracker server,
    # in this case, use_storage_id must set to true in tracker.conf,
    # and storage_ids.conf must be configured correctly.
    group_name = group1
    
    # bind an address of this host
    # empty for bind all addresses of this host
    bind_addr =
    
    # if bind an address of this host when connect to other servers 
    # (this storage server as a client)
    # true for binding the address configured by the above parameter: "bind_addr"
    # false for binding any address of this host
    client_bind = true
    
    # the storage server port 默认端口
    port = 23000
    
    # Storage server 的工作目录,存储日志,binlog等
    # the base path to store data and log files
    # NOTE: the binlog files maybe are large, make sure
    #       the base path has enough disk space,
    #       eg. the disk free space should > 50GB
    base_path = /opt/ylbzj/fastdfs_storge
    
    # accept thread count
    # default value is 1 which is recommended
    # since V4.07
    accept_threads = 4
    
    # work thread count
    # work threads to deal network io
    # default value is 4
    # since V2.00
    work_threads = 64
    
    # NOTE: 我就使用了一块磁盘,所以保持默认值
    # store path (disk or mount point) count, default value is 1
    store_path_count = 1
    
    # store_path#, based on 0, to configure the store paths to store files
    # if store_path0 not exists, it's value is base_path (NOT recommended)
    # the paths must be exist.
    #
    # IMPORTANT NOTE:
    #       the store paths' order is very important, don't mess up!!!
    #       the base_path should be independent (different) of the store paths
    # Storage Server的数据存储地址,这里配置和base_path不同的目录
    store_path0 = /opt/ylbzj/fastdfs_storge_data1
    # 如果多块磁盘指定多个路径
    #store_path1 = /home/yuqing/fastdfs2
    
    # 配置Tracker Server的地址
    tracker_server = 10.0.3.27:22122
    tracker_server = 10.0.3.28:22122
    
    

    以上Storage Server 步骤在另一台10.0.3.28上同样执行一样,将本次修改好的配置文件同步到10.0.3.28. 确保base_path,store_path0 指定的目录已经创建了

    将所有的Storage Server 启动,咱们这里是2台机器,分别启动

     /etc/init.d/fdfs_storaged start
    
    3.2.1 测试上传文件到fastdfs

    上边的步骤,已经将tracker,StorageServer 安装好了。接下来用fastdfs自带的client上传文件测试一下

    cd 到fastdfs的源码目录

    /opt/ylbzj/soft/fastdfs-6.06/conf
    [root@sybj-int-26 conf]# ll
    total 92
    -rw-r--r--. 1 root root 23981 Dec 31 07:36 anti-steal.jpg
    -rw-r--r--. 1 root root  1909 Dec 31 07:36 client.conf
    -rw-r--r--. 1 root root   965 Dec 31 07:36 http.conf
    -rw-r--r--. 1 root root 31172 Dec 31 07:36 mime.types
    -rw-r--r--. 1 root root 10246 Dec 31 07:36 storage.conf
    -rw-r--r--. 1 root root   620 Dec 31 07:36 storage_ids.conf
    -rw-r--r--. 1 root root  9138 Dec 31 07:36 tracker.conf
    [root@sybj-int-26 conf]# 
    

    将client.conf 拷贝到一台机器(任意一台测试即可)的 /etc/fdfs/目录下

    cp client.conf /etc/fdfs
    cd /etc/fdfs
    vim client.conf
    

    编辑配置一下client.conf

    # the base path to store log files
    # 根据自己地址指定一个即可
    base_path = /home/test
    
    # tracker_server can ocur more than once for multi tracker servers.
    # the value format of tracker_server is "HOST:PORT",
    #   the HOST can be hostname or ip address,
    #   and the HOST can be dual IPs or hostnames seperated by comma,
    #   the dual IPS must be an inner (intranet) IP and an outer (extranet) IP,
    #   or two different types of inner (intranet) IPs.
    #   for example: 192.168.2.100,122.244.141.46:22122
    #   another eg.: 192.168.1.10,172.17.4.21:22122
    #NOTE: 增加 tracker server地址
    tracker_server = 10.0.3.27:22122
    tracker_server = 10.0.3.28:22122
    

    上传文件

       [root@sybj-int-27 fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf client.conf
    group1/M00/00/00/CgADHF57AKaADvJdAAAHYyTJSr064.conf
    

    上传成功后返回了文件的组,磁盘,文件目录,文件名等信息group1/M00/00/00/CgADHF57AKaADvJdAAAHYyTJSr064.conf

    3.2.2 安装nginx,fastdfs-nginx-module
    • 上边已经能把文件传到fastdfs,还无法通过http 下载
    • 现在咱们2台机器都安装了,tracker,storage server。http下载的话需要在storage server 上安装nginx,fastdfs-nginx-module
    • 咱们2台机器都是storage server 所以都需要安装nginx
    3.2.2.1 从源码包安装nginx
    • 参考上文中安装nginx的步骤 nginx1.16离线安装文档
    • 别着急直接安装nginx,需要先add-module将fastdfs-nginx-module添加到nginx中。

    先解压fastdfs-nginx-module

    [root@sybj-int-26 soft]# tar -xvf fastdfs-nginx-module-1.22.zip 
    

    切换到nginx的源码目录执行

     [root@sybj-int-26 nginx]# cd nginx-1.16.1/
    [root@sybj-int-26 nginx-1.16.1]# ll
    total 756
    drwxr-xr-x. 6 1001 1001   4096 Mar 25 08:24 auto
    -rw-r--r--. 1 1001 1001 296463 Aug 13  2019 CHANGES
    -rw-r--r--. 1 1001 1001 452171 Aug 13  2019 CHANGES.ru
    drwxr-xr-x. 2 1001 1001    168 Mar 25 08:24 conf
    -rwxr-xr-x. 1 1001 1001   2502 Aug 13  2019 configure
    drwxr-xr-x. 4 1001 1001     72 Mar 25 08:24 contrib
    drwxr-xr-x. 2 1001 1001     40 Mar 25 08:24 html
    -rw-r--r--. 1 1001 1001   1397 Aug 13  2019 LICENSE
    -rw-r--r--. 1 root root    376 Mar 25 08:28 Makefile
    drwxr-xr-x. 2 1001 1001     21 Mar 25 08:24 man
    drwxr-xr-x. 4 root root    187 Mar 25 08:33 objs
    -rw-r--r--. 1 1001 1001     49 Aug 13  2019 README
    drwxr-xr-x. 9 1001 1001     91 Mar 25 08:24 src
    [root@sybj-int-26 nginx-1.16.1]# pwd
    /opt/ylbzj/soft/nginx/nginx-1.16.1
    [root@sybj-int-26 nginx-1.16.1]# ./configure --add-module=/opt/ylbzj/soft/fastdfs-nginx-module-1.22/src
    
    

    然后执行nginx 安装 make make install

    到 fastdfs-nginx-module-1.22 目录 拷贝 mod_文件到/etc/fdfs目录

    [root@sybj-int-26 soft]# cd fastdfs-nginx-module-1.22/
    [root@sybj-int-26 fastdfs-nginx-module-1.22]# ll
    total 8
    -rw-r--r--. 1 root root 3036 Nov 19 12:29 HISTORY
    -rw-r--r--. 1 root root 2001 Nov 19 12:29 INSTALL
    drwxr-xr-x. 2 root root  109 Nov 19 12:29 src
    [root@sybj-int-26 fastdfs-nginx-module-1.22]# cd src/
    [root@sybj-int-26 src]# ll
    total 84
    -rw-r--r--. 1 root root 43507 Nov 19 12:29 common.c
    -rw-r--r--. 1 root root  3995 Nov 19 12:29 common.h
    -rw-r--r--. 1 root root   848 Nov 19 12:29 config
    -rw-r--r--. 1 root root  3725 Nov 19 12:29 mod_fastdfs.conf
    -rw-r--r--. 1 root root 28668 Nov 19 12:29 ngx_http_fastdfs_module.c
    [root@sybj-int-26 src]# pwd
    /opt/ylbzj/soft/fastdfs-nginx-module-1.22/src
    [root@sybj-int-26 src]# cp mod_fastdfs.conf /etc/fdfs/
    

    编辑mod_fastdfs.conf

    cd /etc/fdfs/mod_fastdfs.conf
    vim mod_fastdfs.conf
    
      # connect timeout in seconds
    # default value is 30s
    connect_timeout=5
    
    # network recv and send timeout in seconds
    # default value is 30s
    network_timeout=30
    
    # the base path to store log files
    base_path=/tmp
    
    # if load FastDFS parameters from tracker server
    # since V1.12
    # default value is false
    load_fdfs_parameters_from_tracker=true
    
    # storage sync file max delay seconds
    # same as tracker.conf
    # valid only when load_fdfs_parameters_from_tracker is false
    # since V1.12
    # default value is 86400 seconds (one day)
    storage_sync_file_max_delay = 86400
    
    # if use storage ID instead of IP address
    # same as tracker.conf
    # valid only when load_fdfs_parameters_from_tracker is false
    # default value is false
    # since V1.13
    use_storage_id = false
    
    # specify storage ids filename, can use relative or absolute path
    # same as tracker.conf
    # valid only when load_fdfs_parameters_from_tracker is false
    # since V1.13
    storage_ids_filename = storage_ids.conf
    
    # FastDFS tracker_server can ocur more than once, and tracker_server format is
    #  "host:port", host can be hostname or ip address
    # valid only when load_fdfs_parameters_from_tracker is true
    # NOTE: 配置 tracker server 列表
    tracker_server=10.0.3.27:22122
    tracker_servce=10.0.3.28:22122
    # the port of the local storage server
    # the default value is 23000
    storage_server_port=23000
    
    # 本次 groupName 咱们目前就配置了一个group
    # the group name of the local storage server
    group_name=group1
    
    # NOTE: 修改为true 支持http 直接下载
    # if the url / uri including the group name
    # set to false when uri like /M00/00/00/xxx
    # set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx
    # default value is false
    url_have_group_name = true
    
    # NOTE: 跟本地的storage server 配置路径要一致
    # path(disk or mount point) count, default value is 1
    # must same as storage.conf
    store_path_count=1
    
    # NOTE: 跟本地的storage server 配置路径要一致
    # store_path#, based 0, if store_path0 not exists, it's value is base_path
    # the paths must be exist
    # must same as storage.conf
    store_path0=/opt/ylbzj/fastdfs_storge_data1
    #store_path1=/home/yuqing/fastdfs1
    
    
    • 以上是部分配置,主要配置完毕,其他的配置项都是默认的
    • 如果有多个组设置,需要修改下边的配置
    # set the group count
    # set to none zero to support multi-group on this storage server
    # set to 0  for single group only
    # groups settings section as [group1], [group2], ..., [groupN]
    # default value is 0
    # since v1.14
    group_count = 0
    
    # group settings for group #1
    # since v1.14
    # when support multi-group on this storage server, uncomment following section
    #[group1]
    #group_name=group1
    #storage_server_port=23000
    #store_path_count=2
    #store_path0=/home/yuqing/fastdfs
    #store_path1=/home/yuqing/fastdfs1
    
    # group settings for group #2
    # since v1.14
    # when support multi-group, uncomment following section as neccessary
    #[group2]
    #group_name=group2
    #storage_server_port=23000
    #store_path_count=1
    #store_path0=/home/yuqing/fastdfs
    
    

    目前咱们就配置了一个组,没有配置以上配置项

    fastdfs-nginx-module 依赖了两个配置文件 http.conf, mine.types文件,这两个文件在 fastdfs源码目录的conf目录下,需要拷贝到/etc/fdfs目录

    [root@sybj-int-26 src]# cd /opt/ylbzj/soft/fastdfs-6.06/
    [root@sybj-int-26 fastdfs-6.06]# cd conf/
    [root@sybj-int-26 conf]# ll
    total 92
    -rw-r--r--. 1 root root 23981 Dec 31 07:36 anti-steal.jpg
    -rw-r--r--. 1 root root  1909 Dec 31 07:36 client.conf
    -rw-r--r--. 1 root root   965 Dec 31 07:36 http.conf
    -rw-r--r--. 1 root root 31172 Dec 31 07:36 mime.types
    -rw-r--r--. 1 root root 10246 Dec 31 07:36 storage.conf
    -rw-r--r--. 1 root root   620 Dec 31 07:36 storage_ids.conf
    -rw-r--r--. 1 root root  9138 Dec 31 07:36 tracker.conf
    [root@sybj-int-26 conf]# cp http.conf mime.types /etc/fdfs
    

    查看一下http.conf

      vim /etc/fdfs/http.conf
    
    # if use token to anti-steal
    # default value is false (0)
    http.anti_steal.check_token = false
    
    # token TTL (time to live), seconds
    # default value is 600
    http.anti_steal.token_ttl = 900
    
    # secret key to generate anti-steal token
    # this parameter must be set when http.anti_steal.check_token set to true
    # the length of the secret key should not exceed 128 bytes
    http.anti_steal.secret_key = FastDFS1234567890
    
    

    http.conf 中的这几项用于防盗链设置,http.anti_steal.check_token = true 表示开启token验证。http下载的时候需要携带?token=xxxx 参数

    修改一下nginx.conf,增加一个location 匹配。 nginx.conf 文件在/usr/local/nginx/conf目录

    [root@sybj-int-27 fdfs]# cd /usr/local/nginx/conf/
    [root@sybj-int-27 conf]# vim nginx.conf
    
         server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
            # 增加这一行
            location ~/group([0-9])/M00 {
                ngx_fastdfs_module;
            }
    
    

    至此nginx 和fastdfs-nginx-module 配置完毕,所有storage节点都需要安装,执行以上步骤。
    在两台机器上 启动nginx

       /usr/local/nginx/sbin/nginx
    

    测试一下:

    [root@sybj-int-27 fdfs]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf client.conf
    group1/M00/00/00/CgADG157DIaAWoGUAAAHXJ4aSxg95.conf
    [root@sybj-int-27 fdfs]# wget localhost/group1/M00/00/00/CgADG157DIaAWoGUAAAHXJ4aSxg95.conf
    
    3.2.3 扩展
    • 目前两台机器上都有storage,nginx,http目前没有一个统一的入口,可以在加1-N台 单独的nginx服务器,配置keepalived, 将独立安装的nginx 的请求路由到 storage server上的nginx端口即可
    • 目前部署了单个group群组。可以配置多个group,拷贝storage.conf修改,修改组名,增加机器部署。

    在新的storage server上安装好storage server 和nginx。
    修改storage.conf

       # 多组部署
       group_name = groupN
    

    修改mod_fastdfs.conf

    # the group name of the local storage server
    group_name=groupN
    
    3.2.4 防火墙设置

    centos7 防火墙使用的是firewall
    在每台机器上开发端口:22122 ,23000, 80(nginx端口)

    # firewall-cmd --zone=public(作用域) --add-port=80/tcp(端口和访问类型) --permanent(永久生效)
    firewall-cmd --zone=public --add-port=XXX/tcp --permanent
    firewall-cmd --reload    # 重新载入,更新防火墙规则
    

    4 nginx,tracker,storage 开机启动

    使用工具systemctl

    4.1 nginx 开机启动

    cd /usr/lib/systemd/system
    vim nginx.service
    
    [Unit]
    Description=The NGINX HTTP and reverse proxy server
    After=syslog.target network.target remote-fs.target nss-lookup.target
    
    [Service]
    Type=forking
    PIDFile=/usr/local/nginx/logs/nginx.pid
    ExecStartPre=/usr/local/nginx/sbin/nginx -t
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/bin/kill -s QUIT $MAINPID
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    

    保存后执行:

    # 加载服务配置
    systemctl daemon-reload
    # 启动nginx
    systemctl start nginx
    # 停止nginx
    systemctl stop nginx
    # 设置开机启动
    systemctl enable nginx
    

    注意nginx.service 配置PIDFile的路径是否正确,nginx的pid默认就在/usr/local/nginx/logs/nginx.pid

    4.2 fdfs_trackerd 开机启动

    cd /usr/lib/systemd/system
    vim fdfs_trackerd.service
    
    [Unit]
    Description=The fastdfs tracker server
    After=network.target
    
    [Service]
    Type=forking
    PIDFile=/opt/ylbzj/fastdfs_tracker_data/data/fdfs_trackerd.pid
    ExecStart=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start
    ExecReload=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
    ExecStop=/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop
    
    [Install]
    WantedBy=multi-user.target
    
    

    保存后执行:

    # 加载服务配置
    systemctl daemon-reload
    # 启动fdfs_trackerd
    systemctl start fdfs_trackerd
    # 停止fdfs_trackerd
    systemctl stop fdfs_trackerd
    # 设置开机启动
    systemctl enable fdfs_trackerd
    

    fdfs_trackerd.service 中PIDFile fastdfs默认生成到base_path/data 注意路径要正确

    4.3 fdfs_storaged 开机启动

    cd /usr/lib/systemd/system
    vim fdfs_storaged.service
    
    [Unit]
    Description=fastdfs tracker service
    After=syslog.target network.target remote-fs.target nss-lookup.target
    
    [Service]
    Type=forking
    PIDFile=/opt/ylbzj/fastdfs_storge/data/fdfs_storaged.pid
    ExecStart=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
    ExecReload=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
    ExecStop=/usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop
    PrivateTmp=true
    
    [Install]
    WantedBy=multi-user.target
    
    

    保存后执行:

    # 加载服务配置
    systemctl daemon-reload
    # 启动fdfs_storaged
    systemctl start fdfs_storaged
    # 停止fdfs_storaged
    systemctl stop fdfs_storaged
    # 设置开机启动
    systemctl enable fdfs_storaged
    

    fdfs_storaged.service 中PIDFile fastdfs默认生成到base_path/data 注意路径要正确

    相关文章

      网友评论

          本文标题:Centos7下FastDFS集群搭建

          本文链接:https://www.haomeiwen.com/subject/iqutuhtx.html