CentOS 單機搭建FastDFS文件系統


title: CentOS 單機搭建FastDFS文件系統

此例爲在CentOS7.2 單機上搭建一個FastDFS 文件管理系統

FastDFS架構圖

安裝所需文件均上傳到百度雲盤,位置:FastDFS百度雲盤 安裝清單以下:php

軟件名稱 版本 百度雲盤存放名稱
FastDFS 5.11 fastdfs-5.11.zip
FastDFS-Nginx-module fastdfs-nginx-module-master.zip
LibFastCommon 1.0.36 libfastcommon-1.0.36.zip
nginx 1.10.3 nginx-1.10.3.tar.gz

1、安裝FastDFS

1.安裝libfastcommon

先解壓安裝包到目錄html

[root@localhost fastDFS]# unzip libfastcommon-1.0.36.zip 
複製代碼

解壓後目錄以下:nginx

[root@localhost fastdfs-5.11]# ll
[root@localhost libfastcommon-1.0.36]# ll
總用量 32
drwxr-xr-x. 2 root root  117 4月   5 2017 doc
-rw-r--r--. 1 root root 8005 4月   5 2017 HISTORY
-rw-r--r--. 1 root root  566 4月   5 2017 INSTALL
-rw-r--r--. 1 root root 1606 4月   5 2017 libfastcommon.spec
-rwxr-xr-x. 1 root root 3099 4月   5 2017 make.sh
drwxr-xr-x. 2 root root  191 4月   5 2017 php-fastcommon
-rw-r--r--. 1 root root 2763 4月   5 2017 README
drwxr-xr-x. 3 root root 4096 1月  17 11:21 src
複製代碼

安裝C編譯工具 gccc++

[root@localhost fastdfs-5.11]# yum -y install gcc-c++
複製代碼

編譯libfastcommon軟件並安裝web

[root@localhost fastdfs-5.11]# ./make.sh && ./make.sh install
複製代碼

爲libcommon 建立軟連接到/usr/local/lib目錄下bash

[root@localhost fastdfs-5.11]# ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
[root@localhost fastdfs-5.11]# ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
[root@localhost fastdfs-5.11]# ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
[root@localhost fastdfs-5.11]# ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
複製代碼

2.安裝FastDFS

解壓安裝包服務器

[root@localhost fastDFS]# unzip fastdfs-5.11.zip 
複製代碼

解壓後目錄以下:session

總用量 128
drwxr-xr-x. 3 root root  4096 1月  17 11:25 client
drwxr-xr-x. 2 root root  4096 1月  17 11:25 common
drwxr-xr-x. 2 root root   146 6月   3 2017 conf
-rw-r--r--. 1 root root 35067 6月   3 2017 COPYING-3_0.txt
-rw-r--r--. 1 root root  3171 6月   3 2017 fastdfs.spec
-rw-r--r--. 1 root root 33100 6月   3 2017 HISTORY
drwxr-xr-x. 2 root root    48 6月   3 2017 init.d
-rw-r--r--. 1 root root  7755 6月   3 2017 INSTALL
-rwxr-xr-x. 1 root root  5548 6月   3 2017 make.sh
drwxr-xr-x. 2 root root  4096 6月   3 2017 php_client
-rw-r--r--. 1 root root  2380 6月   3 2017 README.md
-rwxr-xr-x. 1 root root  1768 6月   3 2017 restart.sh
-rwxr-xr-x. 1 root root  1680 6月   3 2017 stop.sh
drwxr-xr-x. 4 root root  4096 1月  17 11:25 storage
drwxr-xr-x. 2 root root  4096 6月   3 2017 test
drwxr-xr-x. 2 root root  4096 1月  17 11:25 tracker
複製代碼

進入解壓目錄並進行編譯和安裝架構

[root@localhost fastDFS]# cd fastdfs-5.11/
[root@localhost fastdfs-5.11]# ./make.sh && ./make.sh install
複製代碼

安裝成功後,FastDFS會安裝在/etc/fdfs目錄下:app

[root@localhost fastdfs-5.11]# ll /etc/fdfs/
總用量 76
-rw-r--r--. 1 root root   316 1月  17 11:47 client.conf
-rw-r--r--. 1 root root  1461 1月  17 11:25 client.conf.sample
-rw-r--r--. 1 root root   955 1月  17 13:20 http.conf
-rw-r--r--. 1 root root 31172 1月  17 13:21 mime.types
-rw-r--r--. 1 root root  3716 1月  17 12:57 mod_fastdfs.conf
-rw-r--r--. 1 root root  1278 1月  17 11:40 storage.conf
-rw-r--r--. 1 root root  7927 1月  17 11:25 storage.conf.sample
-rw-r--r--. 1 root root   105 1月  17 11:25 storage_ids.conf.sample
-rw-r--r--. 1 root root  1356 1月  17 11:34 tracker.conf
-rw-r--r--. 1 root root  7389 1月  17 11:25 tracker.conf.sample
複製代碼

咱們須要把這三個示例文件複製一份,去掉.sample

[root@localhost fdfs]# cp client.conf.sample client.conf
[root@localhost fdfs]# cp storage.conf.sample storage.conf
[root@localhost fdfs]# cp tracker.conf.sample tracker.conf
複製代碼

FastDFS安裝結束

2、安裝Tracker

1.建立tracker工做目錄

此目錄用於保存tracker 的data和log

[root@localhost fdfs]# mkdir /opt/fastdfs_tracker
複製代碼

2.配置tracker

配置 /etc/fdfs目錄下tracker.conf 主要實現如下4個配置內容:

1.disabled=false 
2.port=22122 #默認端口號 
3.base_path=/opt/fastdfs_tracker #我剛剛建立的目錄 
4.http.server_port=8080 #默認端口是8080
5.bind_addr= 0.0.0.0 監聽地址
複製代碼

完整tracker.conf 文件信息以下:

disabled=false

bind_addr= 0.0.0.0

port=22122

connect_timeout=30

network_timeout=60

base_path=/opt/fastdfs_tracker

max_connections=512

accept_threads=1

work_threads=4

min_buff_size = 8KB

max_buff_size = 128KB

store_lookup=2

store_group=group2

store_server=0

store_path=0

download_server=0

reserved_storage_space = 10%

log_level=info

run_by_group=

run_by_user=

allow_hosts=*

sync_log_buff_interval = 10

check_active_interval = 120

thread_stack_size = 64KB

storage_ip_changed_auto_adjust = true

storage_sync_file_max_delay = 86400

storage_sync_file_max_time = 300

use_trunk_file = false 

slot_min_size = 256

slot_max_size = 16MB

trunk_file_size = 64MB

trunk_create_file_advance = false

trunk_create_file_time_base = 02:00

trunk_create_file_interval = 86400

trunk_create_file_space_threshold = 20G

trunk_init_check_occupying = false

trunk_init_reload_from_binlog = false

trunk_compress_binlog_min_interval = 0

use_storage_id = false

storage_ids_filename = storage_ids.conf

id_type_in_filename = ip

store_slave_file_use_link = false

rotate_error_log = false

error_log_rotate_time=00:00

rotate_error_log_size = 0

log_file_keep_days = 0

use_connection_pool = false

connection_pool_max_idle_time = 3600

http.server_port=8080

http.check_alive_interval=30

http.check_alive_type=tcp

http.check_alive_uri=/status.html
複製代碼

修改保存後建立軟引用

[root@localhost fdfs]# ln -s /usr/bin/fdfs_storaged /usr/local/bin
複製代碼

4.啓動tracker,並加入開機啓動項

[root@localhost fdfs]# service fdfs_trackerd start
複製代碼

進行剛剛建立的tracker目錄,發現目錄中多了data和log兩個目錄

[root@localhost fdfs]# ll /opt/fastdfs_tracker/
總用量 0
drwxr-xr-x. 2 root root 178 1月  17 13:48 data
drwxr-xr-x. 2 root root  26 1月  17 11:35 logs
複製代碼

將tracker加入開機啓動項

[root@localhost fdfs]# echo "service fdfs_trackerd start" |tee -a /etc/rc.d/rc.local
複製代碼

查看一下tracker的端口監聽狀況

[root@localhost fdfs]# netstat -unltp|grep fdfs
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      3088/fdfs_trackerd  
複製代碼

3、安裝Storage

1.配置storage工做目錄

因爲storage還須要一個目錄用來存儲數據,所以多建了兩個目錄fastdfs_storage_data,fastdfs_storage

[root@localhost opt]# mkdir fastdfs_storage
[root@localhost opt]# mkdir fastdfs_storage_data
[root@localhost opt]# ll
總用量 0
drwxr-xr-x. 4 root root 30 1月  17 11:45 fastdfs_storage
drwxr-xr-x. 3 root root 18 1月  17 11:45 fastdfs_storage_data
drwxr-xr-x. 4 root root 30 1月  17 11:35 fastdfs_tracker
複製代碼

2.配置storage文件

修改 /etc/fdfs 目錄下 storage.conf 文件 修改要點以下:

1.disabled=false 
2.group_name=group1 #組名,根據實際狀況修改 
3.port=23000 #設置storage的端口號,默認是23000,同一個組的storage端口號必須一致 
4.base_path=/opt/fastdfs_storage #設置storage數據文件和日誌目錄 
5.store_path_count=1 #存儲路徑個數,須要和store_path個數匹配 
6.store_path0=/opt/fastdfs_storage_data #實際文件存儲路徑 
7.tracker_server=192.168.43.60:22122 #我CentOS7的ip地址 
8.http.server_port=8888 #設置 http 端口號
複製代碼

完整信息以下:

disabled=false
group_name=group1
bind_addr= 0.0.0.0
client_bind=true
port=23000
connect_timeout=30
network_timeout=60
heart_beat_interval=30
stat_report_interval=60
base_path=/opt/fastdfs_storage
max_connections=256
buff_size = 256KB
accept_threads=1
work_threads=4
disk_rw_separated = true
disk_reader_threads = 1
disk_writer_threads = 1
sync_wait_msec=50
sync_interval=0
sync_start_time=00:00
sync_end_time=23:59
write_mark_file_freq=500
store_path_count=1
store_path0=/opt/fastdfs_storage_data
subdir_count_per_path=256
tracker_server=192.168.43.60:22122
log_level=info
run_by_group=
run_by_user=
allow_hosts=*
file_distribute_path_mode=0
file_distribute_rotate_count=100
fsync_after_written_bytes=0
sync_log_buff_interval=10
sync_binlog_buff_interval=10
sync_stat_file_interval=300
thread_stack_size=512KB
upload_priority=10
if_alias_prefix=
check_file_duplicate=0
file_signature_method=hash
key_namespace=FastDFS
keep_alive=0
use_access_log = false
rotate_access_log = false
access_log_rotate_time=00:00
rotate_error_log = false
error_log_rotate_time=00:00
rotate_access_log_size = 0
rotate_error_log_size = 0
log_file_keep_days = 0
file_sync_skip_invalid_record=false
use_connection_pool = false
connection_pool_max_idle_time = 3600
http.domain_name=
http.server_port=8888
複製代碼

修改保存後建立軟引用

[root@localhost fdfs]# ln -s /usr/bin/fdfs_storaged /usr/local/bin
複製代碼

3.啓動Storage

[root@localhost fdfs]# service fdfs_storaged start
複製代碼

設置開機啓動:

[root@localhost fdfs]# echo "service fdfs_storaged start" |tee -a /etc/rc.d/rc.local
複製代碼

查看一下服務是否啓動

[root@localhost fdfs]# netstat -unltp | grep fdfs 
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      3088/fdfs_trackerd  
tcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      3139/fdfs_storaged  
複製代碼

4.校驗整合

到這裏,fastdfs的東西都已安裝完成,最後咱們還要肯定一下,storage是否註冊到了tracker中去。 查看命令:

[root@localhost fdfs]# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
複製代碼

成功後能夠看到: ip_addr = 192.168.43.60 (localhost.localdomain) ACTIVE

4、測試

1.配置客戶端

修改 /etc/fdfs/目錄下的client.conf 文件 修改要點爲:

base_path=/opt/fastdfs_tracker #tracker服務器文件路徑
tracker_server=192.168.43.60:22122 #tracker服務器IP地址和端口號
http.tracker_server_port=8080 # tracker 服務器的 http端口號,必須和tracker的設置對應起來
複製代碼

完整client.conf 文件信息以下:

connect_timeout=30
network_timeout=60
base_path=/opt/fastdfs_tracker
tracker_server=192.168.43.60:22122
log_level=info
use_connection_pool = false
connection_pool_max_idle_time = 3600
load_fdfs_parameters_from_tracker=false
use_storage_id = false
storage_ids_filename = storage_ids.conf
http.tracker_server_port=8080
複製代碼

模擬上傳 從我的用戶目錄上傳一個圖片,進行測試

[root@localhost fdfs]# fdfs_upload_file /etc/fdfs/client.conf /home/zhangyongliang/9408.jpg #這後面放的是圖片的位置
複製代碼

成功後會返回圖片存儲路徑

[root@localhost fdfs]# fdfs_upload_file /etc/fdfs/client.conf /home/zhangyongliang/9408.jpg 
group1/M00/00/00/wKgrPFpe9OqAWsHxAAH5yvc2jn8251.jpg
複製代碼

組名:group1 磁盤:M00 目錄:00/00 文件名稱:wKgrPFpe9OqAWsHxAAH5yvc2jn8251.jpg 定位上傳的文件位置以下:

[root@localhost fdfs]# ll /opt/fastdfs_storage_data/data/00/00/
總用量 256
-rw-r--r--. 1 root root 129482 1月  17 15:02 wKgrPFpe9OqAWsHxAAH5yvc2jn8251.jpg
-rw-r--r--. 1 root root 129482 1月  17 11:53 wKgrPFpeyM2ATkGUAAH5yvc2jn8013.jpg
複製代碼

實際文件存儲路徑下有建立好的多級目錄。data下有256個1級目錄,每級目錄下又有256個2級子目錄,總共65536個文件,新寫的文件會以hash的方式被路由到其中某個子目錄下,而後將文件數據直接做爲一個本地文件存儲到該目錄中。
若是要訪問剛上傳的圖片,咱們得須要結合nginx來實現

5、安裝Nginx並實現配置

1.安裝Nginx依賴環境

[root@localhost fdfs]# yum -y install pcre pcre-devel 
[root@localhost fdfs]# yum -y install zlib zlib-devel 
[root@localhost fdfs]# yum -y install openssl openssl-devel
複製代碼

2.安裝nginx並添加fastdfs-nginx-module

解壓nginx和fastdfs-nginx-module

[root@localhost fdfs]# tar -zxvf nginx-1.10.3.tar.gz
[root@localhost fdfs]# unzip fastdfs-nginx-module-master.zip
複製代碼

解壓後進入nginx目錄編譯安裝nginx,並添加fastdfs-nginx-module

[root@localhost nginx-1.10.3]# ./configure --prefix=/usr/local/nginx --add-module=/home/zhangyongliang/apps/fastdfs-nginx-module-master/src #解壓後fastdfs-nginx-module所在的位置
複製代碼

以後進行編譯和安裝

[root@localhost nginx-1.10.3]# make && make isntall
複製代碼

安裝成功後,nginx會安裝在/usr/local/nginx,安裝後查看

[root@localhost src]# ll /usr/local/nginx/
總用量 8
drwx------. 2 nobody root    6 1月  17 13:23 client_body_temp
drwxr-xr-x. 2 root   root 4096 1月  17 13:17 conf
drwx------. 2 nobody root    6 1月  17 13:23 fastcgi_temp
drwxr-xr-x. 2 root   root   40 1月  17 13:17 html
drwxr-xr-x. 2 root   root   58 1月  17 13:49 logs
-rw-r--r--. 1 root   root 1156 1月  17 13:29 nginx.conf
drwx------. 2 nobody root    6 1月  17 13:23 proxy_temp
drwxr-xr-x. 2 root   root   19 1月  17 13:17 sbin
drwx------. 2 nobody root    6 1月  17 13:23 scgi_temp
drwx------. 2 nobody root    6 1月  17 13:23 uwsgi_temp
複製代碼

安裝成功後,nginx還沒有運行時,nginx文件夾沒有臨時文件夾,例如fastcgi_temp這些文件。

3.配置Storage Nginx

修改Nginx 目錄下 conf 的配置文件nginx.conf,新增location信息,具體以下:

server {
        listen       9991;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        location ~/group1/M00 {
            root /opt/fastdfs_storage/data;
            ngx_fastdfs_module;
        }

        location = /50x.html {
            root   html;
        }
}
複製代碼

而後進入FastDFS安裝時的解壓過的目錄,將http.conf和mime.types拷貝到/etc/fdfs目錄下:

[root@localhost src]# cp http.conf mime.types /etc/fdfs/
[root@localhost src]# cp mime.types /etc/fdfs/
複製代碼

另外還須要把fastdfs-nginx-module安裝目錄中src目錄下的mod_fastdfs.conf也拷貝到/etc/fdfs目錄下:

[root@localhost src]# cp mod_fastdfs.conf /etc/fdfs/
複製代碼

對剛剛拷貝的mod_fastdfs.conf文件進行修改:

base_path=/opt/fastdfs_storage  #保存日誌目錄
tracker_server=192.168.43.60:22122 #tracker服務器的IP地址以及端口號
storage_server_port=23000 #storage服務器的端口號
url_have_group_name = true #文件 url 中是否有 group 名
store_path0=/opt/fastdfs_storage_data   #存儲路徑
group_count = 1 #設置組的個數
複製代碼

在文件的最後,設置group

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/opt/fastdfs_storage_data
複製代碼

建立M00至storage存儲目錄的符號鏈接:

ln  -s  /opt/fastdfs_storage_data/data/ /opt/fastdfs_storage_data/data/M00
複製代碼

啓動Nginx:

[root@localhost src]# /usr/local/nginx/sbin/nginx
複製代碼

訪問Nginx是否啓動

[root@localhost src]# curl localhost:9991
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
複製代碼

4.配置Tracker Nginx

在nginx.conf 文件添加一個虛擬機

upstream fdfs_group1 {
        server 127.0.0.1:9991;
    }
   server {
        listen       80;
        server_name  localhost;
       location /group1/M00 {
            proxy_pass http://fdfs_group1;
        }
      error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
複製代碼

完整nginx.conf配置文件以下:

#user nobody;
worker_processes  1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log logs/access.log main;

    sendfile        on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout  65;

    #gzip on;

    server {
        listen       9991;
        server_name  localhost;

        #charset koi8-r;

        #access_log logs/host.access.log main;

        location / {
            root   html;
            index  index.html index.htm;
        }
        location ~/group1/M00 {
            root /opt/fastdfs_storage/data;
            ngx_fastdfs_module;
        }
        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        # proxy_pass http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        # root html;
        # fastcgi_pass 127.0.0.1:9000;
        # fastcgi_index index.php;
        # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
        # include fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        # deny all;
        #}
    }

    upstream fdfs_group1 {
       server 127.0.0.1:9991;
    }
	 server {
        listen       80;
        server_name  localhost;
       location /group1/M00 {
            proxy_pass http://fdfs_group1;
        }
      error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    # listen 8000;
    # listen somename:8080;
    # server_name somename alias another.alias;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}


    # HTTPS server
    #
    #server {
    # listen 443 ssl;
    # server_name localhost;

    # ssl_certificate cert.pem;
    # ssl_certificate_key cert.key;

    # ssl_session_cache shared:SSL:1m;
    # ssl_session_timeout 5m;

    # ssl_ciphers HIGH:!aNULL:!MD5;
    # ssl_prefer_server_ciphers on;

    # location / {
    # root html;
    # index index.html index.htm;
    # }
    #}

}
複製代碼

將Nginx從新啓動

[root@localhost src]# /usr/local/nginx/sbin/nginx -s reload
複製代碼

訪問Nginx是否已經啓動

[root@localhost src]# curl localhost:9991
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@localhost src]# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
複製代碼

5.HTTP訪問圖片資源

訪問圖片資源路徑http://192.168.43.60/group1/M00/00/00/wKgrPFpeyM2ATkGUAAH5yvc2jn8013.jpg

FastDFS資源訪問截圖
能夠看到已上傳的圖片,說明你已成功實現了FastDFS單機的文件系統搭建。

補充說明:

若是Tracker 服務、Storage服務、Nginx服務開機後沒有自啓動,請執行一下操做並進行重啓

[root@localhost ~]# chkconfig --add fdfs_trackerd
[root@localhost ~]# chkconfig --add fdfs_storaged
複製代碼

編輯目錄下的/etc/rc.d/rc.local,內容以下:

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
/usr/local/nginx/sbin/nginx
複製代碼

主要增長了Nginx的啓動,以後進行文件生效,從新啓動系統

[root@localhost ~]# chmod +x /etc/rc.d/rc.local
[root@localhost ~]# source /etc/rc.d/rc.local 
[root@localhost ~]# reboot
複製代碼

查看fastdfs 鏈接數

netstat -antp | grep 23000 | grep ESTABLISHED -c
複製代碼
相關文章
相關標籤/搜索