FastDFS安裝與配置centos 7

前期準備

yum install git (安裝git)

yum -y install gcc (安裝gcc)

vim編輯器需要安裝三個包:??

vim-enhanced-7.0.109-7.el5

vim-minimal-7.0.109-7.el5

vim-common-7.0.109-7.el5

1. 查看一下你本機已經(jīng)存在的包,確認一下你的VIM是否已經(jīng)安裝:

?? 輸入? rpm -qa|grep vim 這個命令,如果已經(jīng)正確安裝,則會顯示上面三個包的名稱

2. 如果缺少了某個,如vim-enhanced,執(zhí)行:yum -y install vim-enhanced 命令,它會自動下載安裝。

3. 如果上面三個包一個都沒有顯示,則直接輸入命令:

?? yum -y install vim*


FastDFS安裝與配置

1.安裝 libfastcommon

cd /usr/local/

git clone https://github.com/happyfish100/libfastcommon.git

cd libfastcommon/

./make.sh

./make.sh install

此處需要重新設置軟鏈接(類似于Windows的快捷方式):

ln -s /usr/lib/libfastcommon.so /usr/local/lib/libfastcommon.so

ln -s /usr/lib/libfdfsclient.so /usr/local/lib/libfdfsclient.so

2.安裝 fastdfs

cd /usr/local/

git clone https://github.com/happyfish100/fastdfs.git

cd fastdfs/

./make.sh

./make.sh install

ln -s /usr/bin/fdfs_trackerd /usr/local/bin?

ln -s /usr/bin/stop.sh /usr/local/bin

ln -s /usr/bin/restart.sh /usr/local/bin

3.配置 tracker

cd /etc/fdfs

cp tracker.conf.sample tracker.conf

vim /etc/fdfs/tracker.conf

disabled=false(默認為false,表示是否無效)

port=22122(默認為22122)

base_path=/data/fdfs/tracker

繼續(xù)

4.配置 client.conf

cd /etc/fdfs

cp client.conf.sample client.conf

vim /etc/fdfs/client.conf

base_path=/data/fdfs/tracker

tracker_server=你的IP:22122

創(chuàng)建 tracker 目錄

mkdir -pv /data/fdfs/tracker

啟動 tracker

centos6 啟動方式

service fdfs_trackerd start

centos7 啟動方式

/etc/init.d/fdfs_trackerd start

查看端口

ss -lntup|grep 22122

tcp LISTEN 0 128 :22122 :* users:((“fdfs_trackerd”,3785,5))

關閉tracker

/etc/init.d/fdfs_trackerd stop

注意:雖然FastDFS區(qū)分tracker和storage服務器,但是安裝的軟件及步驟均相同,只是不同的配置文件而已,因此以上安裝適用tracker server和storage server

5.配置 storage

cd /etc/fdfs

cp storage.conf.sample storage.conf

vim /etc/fdfs/storage.conf

disabled=false(默認為false,表示是否無效)

port=23000(默認為23000)

group_name=group1 #指定組名

base_path=/data/fdfs/storage # 用于存儲數(shù)據(jù)

store_path_count=2? #設置設備數(shù)量

store_path0=/data/fdfs/storage/m0 #指定存儲路徑0

store_path1=/data/fdfs/storage/m1 #指定存儲路徑1

注意:同一組內(nèi)存儲路徑不能沖突,例如:下一個節(jié)點的存儲路徑就是m2,m3….等

tracker_server=你的IP:22122 #指定tracker

http.server_port=8888(默認為8888,nginx中配置的監(jiān)聽端口那之一致)

mkdir -pv /data/fdfs/storage/m0? # 創(chuàng)建數(shù)據(jù)目錄

mkdir -pv /data/fdfs/storage/m1? # 創(chuàng)建數(shù)據(jù)目錄

啟動 storage

必須先啟動tracker,再啟動storage

// centos6 啟動方式

service fdfs_storaged start

// centos7 啟動方式

/etc/init.d/fdfs_storaged start

// 查看端口

ss -lntup|grep 23000

LISTEN 0 128 :23000 :*

// 關閉storage

/etc/init.d/fdfs_storaged stop

文件上傳測試

/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /home/penny/test.png(原圖片路徑)

/group1/M00/00/00/z_Zjt1w2_fOAPCelAAASpu4JDkM139.jpg

返回文件ID即說明文件已經(jīng)上傳成功


存儲服務器(storage server)安裝并配置nginx

1.安裝 fastdfs-nginx-module 模塊

cd /root

git clone https://github.com/happyfish100/fastdfs-nginx-module

cp /root/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

vim /etc/fdfs/mod_fastdfs.conf

connect_timeout=10

base_path=/tmp(默認為/tmp)

tracker_server=你的IP:22122

storage_server_port=23000(默認配置為23000)

url_have_group_name = true (一定要配置否則不能用group)

store_path_count=2 # 設置設備數(shù)量

store_path0=/data/fdfs/storage/m0

store_path1=/data/fdfs/storage/m1

group_name=group1(默認配置為group1)

2.安裝 nginx 依賴庫

yum -y install pcre-devel zlib-devel

yum -y install openssl openssl-devel

3.安裝 nginx

cd /root

wget http://nginx.org/download/nginx-1.8.1.tar.gz

tar xf nginx-1.8.1.tar.gz

cd nginx-1.8.1

./configure --prefix=/application/nginx/ --add-module=../fastdfs-nginx-module/src/

make && make install

cp /usr/local/fastdfs/conf/http.conf? /etc/fdfs/

cp /usr/local/fastdfs/conf/mime.types? /etc/fdfs/

注意:fastdfs安裝目錄下的配置文件

4.配置 nginx

vim /application/nginx/conf/nginx.conf

user? root;? ?

worker_processes? 1;

events {

? ? worker_connections? 1024;

}

? ? http {

? ? ? ? include? ? ? mime.types;

? ? ? ? default_type? application/octet-stream;

? ? ? ? sendfile? ? ? ? on;

? ? ? ? keepalive_timeout? 65;

? ? ? ? server {

? ? ? ? ? ? listen? ? ? 8888;

? ? ? ? ? ? server_name? localhost;

? ? ? ? ? ? location ~/group[0-9]/ {

? ? ? ? ? ? ? ? ngx_fastdfs_module;

? ? ? ? ? ? }

? ? ? ? ? ? error_page? 500 502 503 504? /50x.html;

? ? ? ? ? ? location = /50x.html {

? ? ? ? ? ? root? html;

? ? ? ? ? ? }

? ? ? ? }

? ? }

5.啟動 nginx

cp /application/nginx/sbin/nginx /etc/init.d/

/etc/init.d/nginx

ss -lntup|grep 8888

tcp LISTEN 0 128 :8888 :* users:((“nginx”,7308,6),(“nginx”,7309,6))

6.配置 firewalld-cmd(防火墻)

開啟8888端口

添加

firewall-cmd --zone=public --add-port=8888/tcp --permanent (--permanent永久生效,沒有此參數(shù)重啟后失效)

重新載入

firewall-cmd --reload

可以使用 你的IP:8888//group1/M00/00/00/z_Zjt1w2_fOAPCelAAASpu4JDkM139.jpg 訪問


引用

分布式文件系統(tǒng) FastDFS 5.0.5 & Linux CentOS 7 安裝配置 - 小燈光環(huán) - CSDN博客

Centos7 fastdfs/nginx 安裝與配置 - 胖胖的ALEX - CSDN博客

Centos 下安裝與設置VIM編輯器 - 天道酬勤 - CSDN博客


注釋:

防火墻命令

1.啟動防火墻

systemctl start firewalld

2.禁用防火墻

systemctl stop firewalld

3.設置開機啟動

systemctl enable firewalld

4.停止并禁用開機啟動

sytemctl disable firewalld

5.重啟防火墻

firewall-cmd --reload

nginx命令

1.重啟

/application/nginx/sbin/nginx -s reload??

2.nginx -s

nginx -s reload? ? 在不重新啟動nginx的情況下重新加載配置文件

nginx -s reopen? ? 重啟nginx

nginx -s stop? ? ? 停止nginx

nginx -s quit? ? ? 停止nginx

3.測試Nginx的配置。

nginx -t

4.查看進程列表并過濾

ps -ef | grep nginx?

5.通過端口判斷啟動

yum install net-tools

netstat -anp | grep :8888

引用:linux如何查看nginx是否啟動_百度經(jīng)驗

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容