1. 程式人生 > >搭建單機版的FastDFS伺服器

搭建單機版的FastDFS伺服器

        由於FastDFS叢集搭建非常複雜,對於初期學習FastDFS來說,搭建個單機版的作為入門更為實際一些。

第一步:搭建虛擬環境

        FastDFS需要在Linux系統上安裝,我們一般使用的都是Windows系統,這樣就需要有虛擬環境,我這裡使用Vmware12建立虛擬機器,關於虛擬機器最小化的安裝大家可以參考:http://blog.csdn.net/u012453843/article/details/68947589這篇部落格進行學習

第二步:配置靜態IP而且要保證能上網

       大家可以參考:http://blog.csdn.net/u012453843/article/details/52839105這篇部落格進行學習,需要提醒的是,由於最小化安裝預設是沒有vim命令的,因此在配置靜態IP時使用vi命令即可。

第三步:安裝vim命令

       之所以安裝vim命令是因為在安裝它的同時會自動幫我們安裝perl,而perl在進行編譯安裝時是必須要有的。安裝vim的命令是:yum install vim-enhanced

第四步:安裝gcc

      使用命令:yum install make cmake gcc gcc-c++進行安裝即可

第五步:上傳安裝檔案到Linux伺服器

      為了便於管理,我們在Linux伺服器上新建一個/usr/local/software目錄,專門用於存放安裝包,如下所示

[[email protected] ~]# mkdir /usr/local/software
[
[email protected]
~]#
       下面我們把需要用到的安裝包都上傳到/usr/local/software目錄下,我們可以使用XShell和Xftp5相結合來方便的進行上傳下載操作,大家可以參考http://blog.csdn.net/u012453843/article/details/68951776這篇部落格進行學習。也可以通過安裝rzsz命令來進行上傳下載操作,安裝rzsz的命令是yum install lrzsz,安裝完之後,rz表示上傳,sz 檔案表示下載。

        大家可以到http://download.csdn.net/detail/u012453843/9802538這個地址下載需要的安裝包,上傳完之後,如下所示

[[email protected] software]# ll
總用量 1248
-rw-r--r--. 1 root root  17510 11月 28 00:19 fastdfs-nginx-module_v1.16.tar.gz
-rw-r--r--. 1 root root 345400 11月 28 00:20 FastDFS_v5.05.tar.gz
-rw-r--r--. 1 root root 102378 11月 28 00:19 libfastcommon-master.zip
-rw-r--r--. 1 root root 804164 11月 28 01:11 nginx-1.6.2.tar.gz
[[email protected] software]# 

第六步:安裝zip和unzip命令

        由於解壓.zip結尾的檔案需要用到unzip命令,因此我們需要安裝,安裝命令是yum install zip unzip

第七步:安裝libfastcommon

       1、解壓

[[email protected] software]# unzip libfastcommon-master.zip -d /usr/local/fast/
       2、進入目錄
[[email protected] software]# cd /usr/local/fast/libfastcommon-master/
[[email protected] libfastcommon-master]# ll
總用量 28
-rw-r--r--. 1 root root 2913 2月  27 2015 HISTORY
-rw-r--r--. 1 root root  582 2月  27 2015 INSTALL
-rw-r--r--. 1 root root 1342 2月  27 2015 libfastcommon.spec
-rwxr-xr-x. 1 root root 2151 2月  27 2015 make.sh
drwxr-xr-x. 2 root root 4096 2月  27 2015 php-fastcommon
-rw-r--r--. 1 root root  617 2月  27 2015 README
drwxr-xr-x. 2 root root 4096 2月  27 2015 src
[[email protected] libfastcommon-master]#
      3、編譯
[[email protected] libfastcommon-master]# ./make.sh
      4、安裝
[[email protected] libfastcommon-master]# ./make.sh install

 第八步:建立軟連結

       FastDFS主程式設定的目錄為/usr/local/lib/,所以我們需要建立/ usr/lib64/下的一些核心執行程式的軟連線檔案。如下所示。

[[email protected] libfastcommon-master]# ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
[[email protected] libfastcommon-master]# ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
[[email protected] libfastcommon-master]# ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
[[email protected] libfastcommon-master]# ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
第九步:安裝FastDFS

       1、進入到cd /usr/local/software下,解壓FastDFS_v5.05.tar.gz檔案 

[[email protected] fast]# cd /usr/local/software/
[[email protected] software]# ll
總用量 1248
-rw-r--r--. 1 root root  17510 4月  11 03:28 fastdfs-nginx-module_v1.16.tar.gz
-rw-r--r--. 1 root root 345400 4月  11 03:28 FastDFS_v5.05.tar.gz
-rw-r--r--. 1 root root 102378 4月  11 03:28 libfastcommon-master.zip
-rw-r--r--. 1 root root 804164 4月  11 03:29 nginx-1.6.2.tar.gz
[[email protected] software]# tar -zxvf FastDFS_v5.05.tar.gz -C /usr/local/fast/
       2、編譯安裝
[[email protected] software]# cd /usr/local/fast/FastDFS/
[[email protected] FastDFS]# ./make.sh
[[email protected] FastDFS]# ./make.sh install
      安裝完後,服務指令碼位置如下
[[email protected] FastDFS]# cd /etc/init.d/ && ls | grep fdfs
fdfs_storaged
fdfs_trackerd
[[email protected] init.d]#
       配置檔案位置如下:
[[email protected] init.d]# cd /etc/fdfs/
[[email protected] fdfs]# ll
總用量 20
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]# 
       FastDFS一系列執行指令碼如下,可以看到有上傳檔案指令碼、下載檔案指令碼等等。
[[email protected] fdfs]# cd /usr/bin/ && ls | grep fdfs
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
[[email protected] bin]# 
      3、因為FastDFS服務指令碼設定的bin目錄為/usr/local/bin/下,但是實際我們安裝在了/u sr/bin/下面。所以我們需要修改FastDFS配置檔案中的路徑,也就是需要修改兩個配置檔案

     使用命令vim /etc/init.d/fdfs_storaged進入編輯模式,然後直接輸入":",游標會定位到最後一行,在":"後輸入"%s+/usr/local/bin+/usr/bin",如下圖所示。輸入完之後回車,會提示修改了7處。為了確保所有的/usr/local/bin都被替換了,我們可以再開啟檔案確認一下。

       接著修改第二個配置檔案,我們使用命令vim /etc/init.d/fdfs_trackerd進入編輯模式,接著按照上面那樣輸入":%s+/usr/local/bin+/usr/bin "並按回車,同樣會提醒我們修改了7處。



第十步:配置跟蹤器

     1、進入到/etc/fdfs目錄並且複製一份tracker.conf.sample並命名為tracker.conf,如下所示。

[[email protected] bin]# cd /etc/fdfs/
[[email protected] fdfs]# ll
總用量 20
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]# cp tracker.conf.sample tracker.conf
[[email protected] fdfs]# 
      2、使用命令vim /etc/fdfs/tracker.conf進入編輯模式,然後修改base_path的值為/fastdfs/tracker,如下圖所示。

/
      3、我們在上圖配置檔案中配置的/fastdfs/tracker目前是不存在的,因此我們需要建立一下該目錄

[[email protected] fdfs]# mkdir -p /fastdfs/tracker
[[email protected] fdfs]# 

      4、配置防火牆,放開tracker使用的埠22122,使用命令vim /etc/sysconfig/iptables進入編輯模式,新增一行內容-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT,如下圖所示。

      5、重啟防火牆

[[email protected] fdfs]# service iptables restart
iptables:將鏈設定為政策 ACCEPT:filter                    [確定]
iptables:清除防火牆規則:                                 [確定]
iptables:正在解除安裝模組:                                   [確定]
iptables:應用防火牆規則:                                 [確定]
[[email protected] fdfs]# 
      6、在啟動tracker之前,/fastdfs/tracker目錄下是沒有任何檔案的,如下所示
[[email protected] tracker]# cd /fastdfs/tracker/ && ll
總用量 0
[[email protected] tracker]# 
       啟動tracker,啟動完之後,可以看到這個目錄下多了兩個目錄data和logs。如下所示。
[[email protected] tracker]# /etc/init.d/fdfs_trackerd start 
Starting FastDFS tracker server: 
[[email protected] tracker]# cd /fastdfs/tracker/ && ll
總用量 8
drwxr-xr-x. 2 root root 4096 4月  11 05:01 data
drwxr-xr-x. 2 root root 4096 4月  11 05:01 logs
[[email protected] tracker]# 
      7、設定開機自啟動,在rc.local檔案中新增/etc/init.d/fdfs_trackerd start,如下所示。
[[email protected] tracker]# vim /etc/rc.d/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/etc/init.d/fdfs_trackerd start
第十一步:配置FastDFS儲存

     1、進入/etc/fdfs目錄,複製一份storage.conf.sample檔案並命名為storage.conf,如下所示。

[[email protected] tracker]# cd /etc/fdfs/
[[email protected] fdfs]# ll
總用量 28
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7098 4月  11 04:45 tracker.conf
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]# cp storage.conf.sample storage.conf
[[email protected] fdfs]# ll
總用量 36
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7829 4月  11 05:07 storage.conf
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7098 4月  11 04:45 tracker.conf
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]#
     2、修改storage.conf檔案 ,我們使用命令vim /etc/fdfs/storage.conf進入編輯模式,對以下四項進行修改,192.168.156.13是我的虛擬機器的IP,大家根據自己虛擬機器的IP自行設定。
base_path=/fastdfs/storage
store_path0=/fastdfs/storage
tracker_server=192.168.156.13:22122
http.server_port=8888
      3、建立儲存目錄,如下所示。
[[email protected] fdfs]# mkdir -p /fastdfs/storage
[[email protected] fdfs]# 
     4、配置防火牆,允許外界訪問storage的預設埠23000,如下所示。
[[email protected] fdfs]# vim /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 23000 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
       新增完之後,重啟防火牆,如下所示。
[[email protected] fdfs]# service iptables restart
iptables:將鏈設定為政策 ACCEPT:filter                    [確定]
iptables:清除防火牆規則:                                 [確定]
iptables:正在解除安裝模組:                                   [確定]
iptables:應用防火牆規則:                                 [確定]
[[email protected] fdfs]# 
       5、在啟動storage之前,/fastdbf/storage目錄下是沒有任何檔案的
[[email protected] fdfs]# cd /fastdfs/storage/ && ll
總用量 0
[[email protected] storage]# 
       啟動storage,啟動後再看/fastdfs/storage目錄,可以看到多了data和logs。
[[email protected] storage]# /etc/init.d/fdfs_storaged start
Starting FastDFS storage server: 
[[email protected] storage]# cd /fastdfs/storage/ && ll
總用量 8
drwxr-xr-x. 68 root root 4096 4月  11 05:21 data
drwxr-xr-x.  2 root root 4096 4月  11 05:20 logs
[[email protected] storage]#
      6、檢視FastDFS tracker和storage 是否啟動成功,當看到如下所示資訊時說明都啟動成功了。
[[email protected] storage]# ps -ef | grep fdfs
root       2124      1  0 05:01 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root       2228      1  0 05:21 ?        00:00:00 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
root       2238   1360  0 05:22 pts/0    00:00:00 grep fdfs
[[email protected] storage]#
      7、我們進入到 /fastdfs/storage/data/目錄下,可以看到兩級共256*256個目錄,每級都是從00到FF,如下只是列出了第一級的目錄,點進去每個目錄都還有00到FF共256個目錄。
[[email protected] storage]# cd /fastdfs/storage/data/ && ls
00  09  12  1B  24  2D  36  3F  48  51  5A  63  6C  75  7E  87  90  99  A2  AB  B4  BD  C6  CF  D8  E1  EA  F3  FC
01  0A  13  1C  25  2E  37  40  49  52  5B  64  6D  76  7F  88  91  9A  A3  AC  B5  BE  C7  D0  D9  E2  EB  F4  FD
02  0B  14  1D  26  2F  38  41  4A  53  5C  65  6E  77  80  89  92  9B  A4  AD  B6  BF  C8  D1  DA  E3  EC  F5  fdfs_storaged.pid
03  0C  15  1E  27  30  39  42  4B  54  5D  66  6F  78  81  8A  93  9C  A5  AE  B7  C0  C9  D2  DB  E4  ED  F6  FE
04  0D  16  1F  28  31  3A  43  4C  55  5E  67  70  79  82  8B  94  9D  A6  AF  B8  C1  CA  D3  DC  E5  EE  F7  FF
05  0E  17  20  29  32  3B  44  4D  56  5F  68  71  7A  83  8C  95  9E  A7  B0  B9  C2  CB  D4  DD  E6  EF  F8  storage_stat.dat
06  0F  18  21  2A  33  3C  45  4E  57  60  69  72  7B  84  8D  96  9F  A8  B1  BA  C3  CC  D5  DE  E7  F0  F9  sync
07  10  19  22  2B  34  3D  46  4F  58  61  6A  73  7C  85  8E  97  A0  A9  B2  BB  C4  CD  D6  DF  E8  F1  FA
08  11  1A  23  2C  35  3E  47  50  59  62  6B  74  7D  86  8F  98  A1  AA  B3  BC  C5  CE  D7  E0  E9  F2  FB
[[email protected] data]# 
     8、設定storage開機自啟動,新增一行/etc/init.d/fdfs_storaged start,如下所示。
[[email protected] data]# vim /etc/rc.local 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_storaged start
第十二步:測試圖片上傳

      1、進入到/etc/fdfs目錄下並複製一份client.conf.sample並更名為client.conf,如下所示。

[[email protected] data]# cd /etc/fdfs
[[email protected] fdfs]# ll
總用量 36
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7820 4月  11 05:12 storage.conf
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7098 4月  11 04:45 tracker.conf
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]# cp client.conf.sample client.conf
[[email protected]fs fdfs]# ll
總用量 40
-rw-r--r--. 1 root root 1461 4月  11 05:40 client.conf
-rw-r--r--. 1 root root 1461 4月  11 04:10 client.conf.sample
-rw-r--r--. 1 root root 7820 4月  11 05:12 storage.conf
-rw-r--r--. 1 root root 7829 4月  11 04:10 storage.conf.sample
-rw-r--r--. 1 root root 7098 4月  11 04:45 tracker.conf
-rw-r--r--. 1 root root 7102 4月  11 04:10 tracker.conf.sample
[[email protected] fdfs]# 
     2、使用命令vim /etc/fdfs/client.conf進入編輯模式並修改如下兩項內容,如下所示。
base_path=/fastdfs/tracker
tracker_server=192.168.156.13:22122
     3、我們找到命令的指令碼位置,並且使用命令,進行檔案的上傳。
[[email protected] bin]# cd /usr/bin/ && ls | grep fdfs
fdfs_appender_test
fdfs_appender_test1
fdfs_append_file
fdfs_crc32
fdfs_delete_file
fdfs_download_file
fdfs_file_info
fdfs_monitor
fdfs_storaged
fdfs_test
fdfs_test1
fdfs_trackerd
fdfs_upload_appender
fdfs_upload_file
[[email protected] bin]# 
       下面使用fdfs_upload_file指令碼進行檔案上傳操作,如下所示。可以看到已經上傳成功了,返回的是圖片的儲存位置:group1/M00/00/00/wKicDVjr_ayAE4VVAAHk-VzqZ6w020.jpg
[[email protected] bin]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/software/3.jpg
group1/M00/00/00/wKicDVjr_ayAE4VVAAHk-VzqZ6w020.jpg
[[email protected] bin]#
第十三步:FastDFS與nginx相結合

     1、先安裝nginx,大家可以參考http://blog.csdn.net/u012453843/article/details/69396434這篇部落格的第四步Nginx安裝(我們已經安裝過的vim、gcc等就不需要重複安裝了)。

     2、安裝fastdfs-nginxmodule_v1.16.tar.gz(fast與nginx相結合的模組安裝包), 進入 /usr/local/software目錄並解壓,如下所示。

[[email protected] nginx-1.6.2]# cd /usr/local/software/
[[email protected] software]# tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /usr/local/fast/
fastdfs-nginx-module/
fastdfs-nginx-module/src/
fastdfs-nginx-module/src/ngx_http_fastdfs_module.c
fastdfs-nginx-module/src/mod_fastdfs.conf
fastdfs-nginx-module/src/config
fastdfs-nginx-module/src/common.h
fastdfs-nginx-module/src/common.c
fastdfs-nginx-module/INSTALL
fastdfs-nginx-module/HISTORY
[[email protected] software]#
     3、進入到/usr/local/fast目錄下可以看到解壓的fastdfs-nginx-module目錄,然後進入到fastdfs-nginx-module/src/目錄下,可以看到config檔案。
[[email protected] software]# cd /usr/local/fast/
[[email protected] fast]# ll
總用量 12
drwxr-xr-x. 10 8980 users 4096 4月  11 04:10 FastDFS
drwxrwxr-x.  3  500   500 4096 5月   4 2014 fastdfs-nginx-module
drwxr-xr-x.  4 root root  4096 4月  11 03:30 libfastcommon-master
[[email protected] fast]# cd fastdfs-nginx-module/src/
[[email protected] src]# ll
總用量 76
-rw-rw-r--. 1 500 500 33207 8月  30 2013 common.c
-rw-rw-r--. 1 500 500  3479 1月   3 2012 common.h
-rw-rw-r--. 1 500 500   447 11月  4 2010 config
-rw-rw-r--. 1 500 500  3679 3月  30 2013 mod_fastdfs.conf
-rw-rw-r--. 1 500 500 28542 5月   4 2014 ngx_http_fastdfs_module.c
[[email protected] src]# 
       修改該conf檔案,我們把檔案的第四行配置中的/usr/local/include都改為/usr/include,共兩處。


      4、fastdfs與nginx進行結合,由於我們剛才安裝過nginx了,因此在/usr/local目錄下已經生成了一個nginx目錄了,如下圖所示。


       為了將nginx與fastdfs相結合,我們先把這個nginx目錄刪除掉,如下圖所示,可以看到已經沒有nginx目錄了。


       進入到nginx-1.6.2/目錄下並執行配置和編譯安裝,如下所示。

[[email protected] local]# cd nginx-1.6.2/
[[email protected] nginx-1.6.2]# ./configure --add-module=/usr/local/fast/fastdfs-nginx-module/src/
[[email protected] nginx-1.6.2]# make && make install
       複製fastdfs-nginx-module中的配置檔案,到/etc/fdfs目錄中,如下所示。
[[email protected] fdfs]# cd /usr/local/fast/fastdfs-nginx-module/src/
[[email protected] src]# ll
總用量 76
-rw-rw-r--. 1 500 500 33207 8月  30 2013 common.c
-rw-rw-r--. 1 500 500  3479 1月   3 2012 common.h
-rw-rw-r--. 1 500 500   435 4月  11 06:09 config
-rw-rw-r--. 1 500 500  3679 3月  30 2013 mod_fastdfs.conf
-rw-rw-r--. 1 500 500 28542 5月   4 2014 ngx_http_fastdfs_module.c
[[email protected] src]# cp /usr/local/fast/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[[email protected] src]# 
        我們到 /etc/fdfs/ 目錄下,修改我們剛copy過來的mod_fastdfs.conf 檔案,需要修改的項如下,其中第一項是超時時長,第三項是允許外界通過http方式訪問資源。
connect_timeout=10
tracker_server=192.168.156.13:22122
url_have_group_name = true
store_path0=/fastdfs/storage
        複製FastDFS裡的2個檔案,到/etc/fdfs目錄中,如下所示。
[[email protected] fdfs]# cd /usr/local/fast/FastDFS/conf/
[[email protected] conf]# ll
總用量 84
-rw-r--r--. 1 8980 users 23981 12月  2 2014 anti-steal.jpg
-rw-r--r--. 1 8980 users  1461 12月  2 2014 client.conf
-rw-r--r--. 1 8980 users   858 12月  2 2014 http.conf
-rw-r--r--. 1 8980 users 31172 12月  2 2014 mime.types
-rw-r--r--. 1 8980 users  7829 12月  2 2014 storage.conf
-rw-r--r--. 1 8980 users   105 12月  2 2014 storage_ids.conf
-rw-r--r--. 1 8980 users  7102 12月  2 2014 tracker.conf
[[email protected] conf]# cp http.conf mime.types /etc/fdfs/
[[email protected] conf]# 
       建立一個軟連線,在/fastdfs/storage檔案儲存目錄下建立軟連線,將其連結到實際存放資料 的目錄,如下所示。
[[email protected] conf]# ln -s /fastdfs/storage/data/ /fastdfs/storage/data/M00
[[email protected] conf]# 
       進入到/usr/local/nginx/conf/目錄下,修改nginx.conf檔案,如下圖所示。


        修改的內容如下圖示


        可以直接複製下面的內容。

        listen       8888;

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

       設定nginx開機自啟動,這樣下次重啟裝置之後,tracker、storage、nginx都自動啟動了,直接就可以使用服務,如下所示。

[[email protected] ~]# vim /etc/rc.d/rc.local 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_storaged start
/usr/local/nginx/sbin/nginx

       啟動nginx,如下所示。

[[email protected] conf]# /usr/local/nginx/sbin/nginx 
ngx_http_fastdfs_set pid=6809
[[email protected] conf]# 
      5、在通過8888埠訪問圖片之前先配置下防火牆,允許外界訪問8888埠,新增的一行是-A INPUT -m state --state NEW -m tcp -p tcp --dport 8888 -j ACCEPT,如下圖所示。


      配置完防火牆後重啟防火牆

[[email protected] conf]# service iptables restart
iptables:將鏈設定為政策 ACCEPT:filter                    [確定]
iptables:清除防火牆規則:                                 [確定]
iptables:正在解除安裝模組:                                   [確定]
iptables:應用防火牆規則:                                 [確定]
[[email protected] conf]# 
      6、現在我們便可以通過http的方式訪問我們剛才上傳的圖片了(我們剛才上傳圖片返回的地址是group1/M00/00/00/wKicDVjr_ayAE4VVAAHk-VzqZ6w020.jpg),如下圖所示。



     至此,一個單機版的FastDFS便搭建完畢了!!
   
    







相關推薦

使用TortoiseSVN在Windows系統下搭建單機SVN伺服器版本控制

為了對電腦上的程式碼進行管理,避免各種複製、貼上,而且還容易混亂,決定在本機上搭建單機版本控制伺服器,原來想著可能需要特別大的磁碟空間用於儲存伺服器及程式碼,並且也做好了學習SVN伺服器配置的準備,但搜尋資料發現,其實沒有那麼複雜,自己電腦上安裝的TortoiseSVN就

Docker一鍵搭建 FastDFS單機 圖片伺服器

本教程基於docker和docker-compose環境,使用了morunchang/fastdfs映象(包含nginx訪問模組).可快速實現FastDFS的單機圖片伺服器部署. 1 建立docker檔案結構 檔案結構如下 2 編寫docker

搭建單機FastDFS伺服器

        由於FastDFS叢集搭建非常複雜,對於初期學習FastDFS來說,搭建個單機版的作為入門更為實際一些。 第一步:搭建虛擬環境         FastDFS需要在Linux系統上安裝,我們一般使用的都是Windows系統,這樣就需要有虛擬環境,我這裡使用V

開源解決方案一:快速搭建單機 LAMP 網站

opera clas 資源管理 都在 ger source environ 本地 tin LAMP 通常表示 Linux + Apache + MySQL/MariaDB + Perl/PHP/Python,LAMP 的各個組件不是一成不變的,並不局限於它最初的選擇。作為一

【Spark筆記】Windows10 本地搭建單機Spark開發環境

語句 spl 嘗試 spa efi 下載界面 RR 是否 錯誤 0x00 環境及軟件 1、系統環境 OS:Windows10_x64 專業版 2、所需軟件或工具 JDK1.8.0_131 spark-2.3.0-bin-hadoop2.7.tgz hadoop-2.8

linux搭建單機和偽分散式hadoop

前提:我使用的window作業系統,然後下載的VMware建立虛擬機器,然後在xshell中進行操作,並使用filezilla進行檔案的上傳。這些可以自行百度搜索下載。 單機版hadoop環境搭建 首先我們用VMware建立一個新的虛擬機器。建立過程不在細說了。 建立完成後,user

Solr全文搜尋伺服器搭建以及在Java中的使用(solr單機

直接步入正題。。。。。。Solr的搭建環境:JDK:1.8.0_161Tomcat:7.0.57OS:CentOS 7Solr服務搭建:第一步:將solr的壓縮包上傳至Linux系統,下載地址:http://www.apache.org/dyn/closer.lua/luce

Linux伺服器redis單機和叢集搭建

Linux的下載命令,根據需要版本進行下載即可: [[email protected] bin]# wgethttp://download.redis.io/releases/redis-4.0.8.tar.gz 2.linux下redis單機版搭建        2.1 redis需要c

單機solr的搭建

windows nal sch 系統 web.xml example multi sse val 1.1. Solr的環境 Solr是java開發。 需要安裝jdk。 安裝環境Linux。 需要安裝Tomcat。 1.2. 搭建步驟 第一步:把solr 的壓縮包上傳到L

虛擬機搭建redis單機及redis-cluster,使用redis desktop manager和java(eclipse)連接redis過程遇到問題匯總

init clu centos 一律 有用 tex 保護模式 bin service 如果你看到這裏,我默認你已經安裝好了redis,並且已經成功的在虛擬機的Linux系統中ping通。 介紹一下我的環境:VMware虛擬機安裝centos 6.5版的Linux系統,red

hadoop環境搭建(linux單機

mapred 單機 keygen opts -c 配置 驗證 bsp 服務 一、在Ubuntu下創建hadoop用戶組合hadoop用戶 1、創建hadoop用戶組 addgroup hadoop 2、創建hadoop用戶 adduser -ingrou

快速搭建redis單機和redis集群

rdo replicas src install 分布式 安裝redis 運行環境 color spa 單機版    第一步:需要安裝redis所需的C語言環境,若虛擬機聯網,則執行 yum install gcc-c++    第二步:redis的源碼包上傳到linux系

hbase+opentsdb 單機搭建

sync dfs 寫入 -- har all 配置 web 返回值 2018年2月19日星期一 Lee 這個實驗步驟比較簡單,只能用來演示下搭建過程,實際生產環境復雜的很多。 實驗環境: centos6.5 x86_64IP: 10.0.20.25 這裏實驗沒有

FastDFS單機安裝

kilo 依次 文件的 統計 安裝目錄 enc [1] 架構圖 tst FastDFS分布式文件系統1 目標了解項目中使用FastDFS的原因和意義。掌握FastDFS的架構組成部分,能說出tracker和storage的作用。了解FastDFS+nginx上傳和下載的執行

linux下redis單機搭建

運行 在線好友 列表 適應 後端 c++ 字符串 moni 集合類型 1.1.什麽是redis Redis是用C語言開發的一個開源的高性能鍵值對(key-value)數據庫。它通過提供多種鍵值數據類型來適應不同場景下的存儲需求,目前為止Redis支持的鍵值數據類型如下: 字

rabbitmq 集群搭建 單機多實例

rabbitmq 集群 單機多實例版本rabbitmq 是一個開源的AMQP實現,用ERLANG編寫,由於erlang天生支持分布式高並發的語言,這也是rabbitmq被許多開發者所喜愛。 AMQP概念,這裏不做介紹,可以google一下,概念很重要,概念很重要,概念很重要,重要的事說三遍。 下面開始集群搭建

分布式搭建-簡易文件上傳下載服務器FastDFS

centos 提取 新的 一份 xms x64 子目錄 archive 加權 一、FastDFS介紹 FastDFS開源地址:https://github.com/happyfish100 參考:分布式文件系統FastDFS設計原理 參考:FastDFS分布式文件系統 個

Linux 安裝FastDFS<單機>(使用Mac遠程訪問)

c-c class roo kcon body 第一個 tar font RR 閱讀本文需要先閱讀安裝FastDFS<準備> 一 編譯環境 yum install gcc-c++ yum -y install libevent yum install -y pc

CentOS7.5搭建Solr7.4.0單機與集群

resources ren 設置 ima -s and tar json 嘗試 一.Solr安裝環境 1.官方參考文檔 Solr教程參考指南:http://lucene.apache.org/solr/guide/7_4/solr-tutorial.html 2.So

linux搭建redis(單機)

 1.redis的安裝   1.1 redis 下載    官網地址 點選開啟連結    下載地址  點選開啟連結   1.2 redis 的安裝    安裝