Centos7下FastDFS集群搭建

1 安裝包準備

  1. libfastcommon 需要在tracker知纷,storage 節(jié)點分別安裝。
  2. 在storage節(jié)點需要安裝nginx,fastdfs-nginx-module(fastdfs之前內(nèi)置了http server秃励,現(xiàn)在如果需要直接通過http下載需要安裝nginx,fastdfs-nginx-module)
  3. fastdfs-nginx-module group組中數(shù)據(jù)同步延遲問題,可以將請求重定向他其他節(jié)點。

2 環(huán)境準備

簡易集群部署挺尾,我這里是最小環(huán)境安裝,使用了2臺機器 10.0.3.27站绪,10.0.3.28 Centos7系統(tǒng)遭铺。

實際環(huán)境中:可以單獨部署tracker集群. 程序Client上傳文件的時候sdk連接tracker集群,下載的時候恢准,可以加幾臺機器部署一層Nginx+Keepalived 魂挂,將請求轉(zhuǎn)發(fā)到 storage節(jié)點上的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包.在解壓目錄執(zhí)行./make.sh,執(zhí)行完畢后執(zhí)行./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解壓,進入到解壓目錄執(zhí)行./make.sh 然后執(zhí)行./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的可執(zhí)行文件安裝到了:/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 的工作目錄和日志目錄
# 此目錄需要提前創(chuàng)建好
# the base path to store data and log files
base_path = /opt/ylbzj/fastdfs_tracker_data
# 最大連接數(shù)
# max concurrent connections this server support
# you should set this parameter larger, eg. 10240
# default value is 256
max_connections = 1024

# 處理連接的accept線程數(shù)矫钓,可根據(jù)CPU核數(shù)而定
# accept thread count
# default value is 1 which is recommended
# since V4.07
accept_threads = 4

# 工作線程數(shù)量 要尔,根據(jù)CPU數(shù)量而定
# 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

# 我理解的是同一個組內(nèi)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上同樣執(zhí)行一樣还惠,將本次修改好的配置文件同步到10.0.3.28. 確保base_path指定的目錄已經(jīng)創(chuàng)建了

     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的數(shù)據(jù)存儲地址衰粹,這里配置和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上同樣執(zhí)行一樣锣光,將本次修改好的配置文件同步到10.0.3.28. 確保base_path,store_path0 指定的目錄已經(jīng)創(chuàng)建了

將所有的Storage Server 啟動,咱們這里是2臺機器铝耻,分別啟動

 /etc/init.d/fdfs_storaged start
3.2.1 測試上傳文件到fastdfs

上邊的步驟誊爹,已經(jīng)將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
# 根據(jù)自己地址指定一個即可
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
  • 上邊已經(jīng)能把文件傳到fastdfs搂漠,還無法通過http 下載
  • 現(xiàn)在咱們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的源碼目錄執(zhí)行

 [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

然后執(zhí)行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 參數(shù)

修改一下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節(jié)點都需要安裝,執(zhí)行以上步驟宿接。
在兩臺機器上 啟動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目前沒有一個統(tǒng)一的入口睦霎,可以在加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
在每臺機器上開發(fā)端口: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    # 重新載入拷窜,更新防火墻規(guī)則

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

保存后執(zhí)行:

# 加載服務配置
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

保存后執(zhí)行:

# 加載服務配置
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

保存后執(zhí)行:

# 加載服務配置
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 注意路徑要正確

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末赋荆,一起剝皮案震驚了整個濱河市笋妥,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌窄潭,老刑警劉巖春宣,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異嫉你,居然都是意外死亡月帝,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進店門幽污,熙熙樓的掌柜王于貴愁眉苦臉地迎上來嚷辅,“玉大人,你說我怎么就攤上這事距误◆じ悖” “怎么了?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵准潭,是天一觀的道長趁俊。 經(jīng)常有香客問我,道長刑然,這世上最難降的妖魔是什么寺擂? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮泼掠,結(jié)果婚禮上怔软,老公的妹妹穿的比我還像新娘。我一直安慰自己武鲁,他們只是感情好爽雄,可當我...
    茶點故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布蝠检。 她就那樣靜靜地躺著沐鼠,像睡著了一般。 火紅的嫁衣襯著肌膚如雪叹谁。 梳的紋絲不亂的頭發(fā)上饲梭,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天,我揣著相機與錄音焰檩,去河邊找鬼憔涉。 笑死,一個胖子當著我的面吹牛析苫,可吹牛的內(nèi)容都是我干的兜叨。 我是一名探鬼主播穿扳,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼国旷!你這毒婦竟也來了矛物?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤跪但,失蹤者是張志新(化名)和其女友劉穎履羞,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體屡久,經(jīng)...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡忆首,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了被环。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片糙及。...
    茶點故事閱讀 40,680評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖蛤售,靈堂內(nèi)的尸體忽然破棺而出丁鹉,到底是詐尸還是另有隱情,我是刑警寧澤悴能,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布揣钦,位于F島的核電站,受9級特大地震影響漠酿,放射性物質(zhì)發(fā)生泄漏冯凹。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一炒嘲、第九天 我趴在偏房一處隱蔽的房頂上張望宇姚。 院中可真熱鬧,春花似錦夫凸、人聲如沸浑劳。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽魔熏。三九已至,卻和暖如春鸽扁,著一層夾襖步出監(jiān)牢的瞬間蒜绽,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工桶现, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留躲雅,地道東北人。 一個月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓骡和,卻偏偏與公主長得像相赁,于是被迫代替她去往敵國和親相寇。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,691評論 2 361

推薦閱讀更多精彩內(nèi)容