最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Centos7配置fastdfs和nginx分布式文件存儲系統(tǒng)實現(xiàn)過程解析

 更新時間:2020年06月23日 08:55:10   作者:vevian  
這篇文章主要介紹了centos7配置fastdfs及nginx并實現(xiàn)分布式文件存儲系統(tǒng),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

1、安裝libfastcommon-1.0.43,安裝包可以在大佬的https://github.com/happyfish100/libfastcommon/releases下載

[root@localhost Downloads]# tar -zxvf libfastcommon-1.0.43.tar.gz

# 解壓后進入目錄進行編譯并安裝
[root@localhost libfastcommon-1.0.43]#cd libfastcommon-1.0.43
[root@localhost libfastcommon-1.0.43]#make
[root@localhost libfastcommon-1.0.43]#make install

注意:libfastcommon安裝好后會在/usr/lib64 目錄下生成 libfastcommon.so 庫文件;由于FastDFS程序引用usr/lib目錄所以需要將/usr/lib64下的庫文件拷貝至/usr/lib下

cp /usr/lib64/libfastcommon.so /usr/lib

2、安裝fastdfs,安裝包可以在大佬的https://github.com/happyfish100/fastdfs/releases下載

#解壓到當前目錄
tar -zxvf fastdfs-6.06.tar.gz

# 進入到目錄進行編譯與安裝
make.sh
make.sh install

安裝成功后,將/conf下的文件復制到/etc/fdfs中

[root@localhost conf]# ll
total 92
-rw-rw-r--. 1 root root 23981 Dec 31 07:36 anti-steal.jpg
-rw-rw-r--. 1 root root 1909 Dec 31 07:36 client.conf
-rw-rw-r--. 1 root root 965 Dec 31 07:36 http.conf
-rw-rw-r--. 1 root root 31172 Dec 31 07:36 mime.types
-rw-rw-r--. 1 root root 10246 Dec 31 07:36 storage.conf
-rw-rw-r--. 1 root root 620 Dec 31 07:36 storage_ids.conf
-rw-rw-r--. 1 root root 9138 Dec 31 07:36 tracker.conf
[root@localhost conf]# cd ..
[root@localhost fastdfs-6.06]# cp /conf/* /etc/fdfs
[root@localhost fastdfs-6.06]# ll /etc/fdfs
total 128
-rw-r--r--. 1 root root 23981 Jun 21 02:16 anti-steal.jpg
-rw-r--r--. 1 root root 1904 Jun 21 02:24 client.conf
-rw-r--r--. 1 root root 1909 Jun 21 02:15 client.conf.sample
-rw-r--r--. 1 root root 965 Jun 21 02:54 http.conf
-rw-r--r--. 1 root root 31172 Jun 21 02:54 mime.types
-rw-r--r--. 1 root root 3738 Jun 21 02:41 mod_fastdfs.conf
-rw-r--r--. 1 root root 10238 Jun 21 02:23 storage.conf
-rw-r--r--. 1 root root 10246 Jun 21 02:15 storage.conf.sample
-rw-r--r--. 1 root root 620 Jun 21 02:16 storage_ids.conf
-rw-r--r--. 1 root root 620 Jun 21 02:15 storage_ids.conf.sample
-rw-r--r--. 1 root root 9129 Jun 21 02:18 tracker.conf
-rw-r--r--. 1 root root 9138 Jun 21 02:15 tracker.conf.sample
[root@localhost fastdfs-6.06]#

3、配置和啟動tracker

# 進入/etc/fdfs目錄中
cd /etc/fdfs

# 拷貝一份新的tracker配置文件
cp tracker.conf.sample tracker.conf

#修改tracker.conf ; vim tracker.conf
# /home/fastdfs用于存放tracker的data和log
base_path=/home/yuqing/fastdfs 改為: base_path=/home/fastdfs
http.server_port 改為: 80

# 啟動tracker
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

4、配置和啟動storage

# 進入/etc/fdfs目錄中
cd /etc/fdfs

# 拷貝一份新的tracker配置文件
cp storage.conf.sample storage.conf

# 修改storage.conf ; vim storage.conf
group_name=group1 #配置組名
base_path=/home/yuqing/fastdfs 改為: base_path=/home/fastdfs

#store存放文件的位置(store_path)
store_path0=/home/yuqing/fastdfs 改為: store_path0=/home/fdfs_storage 
#如果有多個掛載磁盤則定義多個store_path,如下
#store_path1=.....
#store_path2=......

#配置tracker服務器:IP
tracker_server=192.168.172.20:22122
#如果有多個則配置多個tracker
#tracker_server=192.168.101.4:22122

#配置http端口,使用默認端口
http.server_port=8888

#啟動storage, 運行命令如下:
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

#啟動完成后進入 /home/fdfs_storage/data 目錄下,顯示目錄如下
[root@localhost home]# cd fdfs_storage/
[root@localhost fdfs_storage]# ls
data
[root@localhost fdfs_storage]# cd data/
[root@localhost data]# ls
00 0A 14 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 A0 AA B4 BE C8 D2 DC E6 F0 FA
01 0B 15 1F 29 33 3D 47 51 5B 65 6F 79 83 8D 97 A1 AB B5 BF C9 D3 DD E7 F1 FB
02 0C 16 20 2A 34 3E 48 52 5C 66 70 7A 84 8E 98 A2 AC B6 C0 CA D4 DE E8 F2 FC
03 0D 17 21 2B 35 3F 49 53 5D 67 71 7B 85 8F 99 A3 AD B7 C1 CB D5 DF E9 F3 FD
04 0E 18 22 2C 36 40 4A 54 5E 68 72 7C 86 90 9A A4 AE B8 C2 CC D6 E0 EA F4 FE
05 0F 19 23 2D 37 41 4B 55 5F 69 73 7D 87 91 9B A5 AF B9 C3 CD D7 E1 EB F5 FF
06 10 1A 24 2E 38 42 4C 56 60 6A 74 7E 88 92 9C A6 B0 BA C4 CE D8 E2 EC F6
07 11 1B 25 2F 39 43 4D 57 61 6B 75 7F 89 93 9D A7 B1 BB C5 CF D9 E3 ED F7
08 12 1C 26 30 3A 44 4E 58 62 6C 76 80 8A 94 9E A8 B2 BC C6 D0 DA E4 EE F8
09 13 1D 27 31 3B 45 4F 59 63 6D 77 81 8B 95 9F A9 B3 BD C7 D1 DB E5 EF F9
[root@localhost data]#

5、使用fastdfs自帶工具測試上傳文件

# 切換目錄到 /etc/fdfs/ 目錄下
cd /etc/fdfs

# 拷貝一份新的client配置文件
cp client.conf.sample client.conf

# 修改client.conf ; vim client.conf
base_path = /home/fastdfs
tracker_server = 192.168.52.133:22122
#tracker_server = 192.168.0.197:22122

#進行上傳文件的測試,運行如下:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload wyc01.jpg

#結果:
[youth@localhost Pictures]$ /usr/bin/fdfs_test /etc/fdfs/client.conf upload wyc01.jpg 
This is FastDFS client test program v6.06

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/ 
for more detail.

[2020-06-21 03:54:35] DEBUG - base_path=/home/fastdfs, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
 server 1. group_name=, ip_addr=192.168.52.133, port=23000

group_name=group1, ip_addr=192.168.52.133, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKg0hV7uaXyALZfuAABDP6pWIGE814.jpg
source ip address: 192.168.52.133
file timestamp=2020-06-21 03:54:36
file size=17215
file crc32=2857771105
example file url: http://192.168.52.133/group1/M00/00/00/wKg0hV7uaXyALZfuAABDP6pWIGE814.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKg0hV7uaXyALZfuAABDP6pWIGE814_big.jpg
source ip address: 192.168.52.133
file timestamp=2020-06-21 03:54:36
file size=17215
file crc32=2857771105
example file url: http://192.168.52.133/group1/M00/00/00/wKg0hV7uaXyALZfuAABDP6pWIGE814_big.jpg
[youth@localhost Pictures]$

注意:http://192.168.52.133/group1/M00/00/00/wKg0hV7uaXyALZfuAABDP6pWIGE814.jpg就是剛才上傳圖片的鏈接,但是現(xiàn)在沒有整合nginx,所以無法通過http訪問

6、fastdfs和nginx整合

①安裝fastdfs-nginx-module,安裝包可以在大佬的https://github.com/happyfish100/fastdfs-nginx-module/releases下載

#解壓
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

# 進入到目錄里修改conf配置
cd /usr/local/fastdfs-nginx-module/src/

vim conf

 HTTP_MODULES="$HTTP_MODULES ngx_http_fastdfs_module"
 NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fastdfs_module.c"
 # 只修改這里,把local刪除
 CORE_INCS="$CORE_INCS /usr/include"
 CORE_LIBS="$CORE_LIBS -lfastcommon -lfdfsclient"
 CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -DFDFS_OUTPUT_CHUNK_SIZE='256*1024' -DFDFS_MOD_CONF_FILENAME='\"/etc/fdfs/mod_fastdfs.conf\"'"

②將fastdfs-nginx-module/src下的mod_fastdfs.conf拷貝至/etc/fdfs/下

  cp mod_fastdfs.conf /etc/fdfs/

?、鄄⑿薷?/etc/fdfs/mod_fastdfs.conf 的內容;vi /etc/fdfs/mod_fastdfs.conf

base_path=/home/fastdfs
tracker_server=192.168.172.20:22122
#tracker_server=192.168.172.20:22122 #(多個tracker配置多行)
url_have_group_name=true #url中包含group名稱
store_path0=/home/fdfs_storage #指定文件存儲路徑(上面配置的store路徑)

7、安裝nginx

# nginx官網(wǎng)上有安裝包,可以直接下載
# 解壓
tar -zxvf nginx-1.8.0.tar.gz

# 進入目錄,配置命令
# --prefix是nginx的安裝路徑
# --add-module是fastdfs-nginx-module解壓后的文件路徑
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/usr/local/fastdfs-nginx-module/src# 編譯并安裝
make && make install# 復制nginx-1.19.0/conf配置文件夾(解壓后的nginx)里面的兩個文件到/etc/fdfs
cp http.conf mime.types /etc/fdfs/

注意:上邊將臨時文件目錄指定為/var/temp/nginx,需要在/var下創(chuàng)建temp及nginx目錄;我指定了pid-path,所以也要在/var/run文件夾下創(chuàng)建一個nginx,然后在nginx文件夾下創(chuàng)建一個nginx.pid,否則啟動nginx時會報錯nginx: [emerg] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory),還是建議不指定了,這個坑太深了

8、修改nginx配置文件

server {
  listen  80;
  #server_name localhost;
  server_name 192.168.52.133;

  #charset koi8-r;

  #access_log logs/host.access.log main;
 
  location ~/group([1~9])/M00/{
   root /home/fdsf_storage/data;
   ngx_fastdfs_module;
  }

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

9、啟動nginx,因為nginx默認是80端口,確保80端口沒有被占用,如果占用就kill掉;確保防火墻firewall允許外部設備訪問服務器

/use/local/nginx/sbin/nginx

[root@localhost fdfs]# ps -ef | grep nginx
root 7466 1 0 03:12 ? 00:00:00 nginx: master process nginx
nobody 7590 7466 0 03:21 ? 00:00:00 nginx: worker process
root 8514 2806 0 04:17 pts/0 00:00:00 grep --color=auto nginx
[root@localhost fdfs]#

10、通過外部設備訪問fastdfs文件系統(tǒng)的圖片

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • apache 配置成滾動日志的方法

    apache 配置成滾動日志的方法

    apache默認的日志只是1個文件,隨著訪問量的加大,該日志文件會越來越大,借助apache的rotatelogs.exe自動生成滾動日志。
    2010-12-12
  • 17個Linux tar命令實用示例

    17個Linux tar命令實用示例

    這篇文章主要為大家詳細介紹了Linux 中 17 個tar命令實用示例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Linux的wget命令詳解

    Linux的wget命令詳解

    這篇文章主要為大家詳細介紹了Linux的wget命令,教大家如何使用wget,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Centos搭建GTK+Codeblock完整版

    Centos搭建GTK+Codeblock完整版

    剛搭建完成一個程序用的軟件。把自己在搭建時步驟寫下來,省的在搭建的時候走彎路,找資料。
    2010-02-02
  • 詳解Linux系統(tǒng)三種模式下的簡單命令

    詳解Linux系統(tǒng)三種模式下的簡單命令

    這篇文章主要介紹了Linux系統(tǒng)三種模式下的簡單命令,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-07-07
  • 如何實現(xiàn)在Linux上執(zhí)行exe文件

    如何實現(xiàn)在Linux上執(zhí)行exe文件

    這篇文章主要介紹了在Linux上執(zhí)行exe文件實現(xiàn)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-09-09
  • Linux系統(tǒng)下netstat命令詳細介紹

    Linux系統(tǒng)下netstat命令詳細介紹

    大家好,本篇文章主要講的是Linux系統(tǒng)下netstat命令詳細介紹,感興趣的同學趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • environments was not found on the java.library.path 問題的解決方法

    environments was not found on the java.library.path 問題的解決方法

    The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path 問題的解決方法,需要的朋友可以參考下
    2016-08-08
  • CentOs下手動升級node版本的方法

    CentOs下手動升級node版本的方法

    這篇文章主要介紹了CentOs下手動升級node版本的方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-11-11
  • 淺談linux rwxrwxrwt文件夾屬性

    淺談linux rwxrwxrwt文件夾屬性

    下面小編就為大家?guī)硪黄獪\談linux rwxrwxrwt文件夾屬性。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-12-12

最新評論

江都市| 香港 | 永德县| 垦利县| 策勒县| 贵溪市| 水城县| 时尚| 昌乐县| 土默特右旗| 射阳县| 凤冈县| 瓦房店市| 黔东| 天等县| 香格里拉县| 鱼台县| 抚宁县| 凌云县| 桐乡市| 紫云| 安图县| 大厂| 休宁县| 陇西县| 库尔勒市| 彭州市| 凤冈县| 广宗县| 隆回县| 绍兴县| 合川市| 宁海县| 梁平县| 剑阁县| 叶城县| 运城市| 新野县| 普安县| 台北县| 正安县|