FastDFS分佈式文件管理系統集羣

版權聲明:本文爲博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/aojianmo2012/article/details/59069883

FastDFS分佈式文件管理系統集羣

一. 硬件準備

```
2臺tracker跟蹤服務器
192.168.1.101
192.168.1.102

4臺storage存儲服務器
192.168.1.201
192.168.1.202
192.168.1.203
192.168.1.204
```

二. 安裝準備

```
yum -y groupinstall 'Development Tools'
yum -y install wget
```

1. 安裝libfastcommon

```
cd ~
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
./make.sh
./make.sh install
```

2. 安裝fastdfs

```
cd ~
wget https://github.com/happyfish100/fastdfs/archive/V5.08.tar.gz
tar -zxvf V5.08.tar.gz
cd fastdfs-5.08
./make.sh  
./make.sh install
```

3. 創建目錄

```
mkdir /data/
mkdir /data/fdfs
mkdir /data/fdfs/client
mkdir /data/fdfs/storage
mkdir /data/fdfs/tracker
```

4. 配置client(在storage服務器)

```
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
vim /etc/fdfs/client.conf

base_path=/data/fdfs/client
tracker_server=192.168.1.101:22122 #tracker服務器1 ip地址
tracker_server=192.168.1.102:22122 #tracker服務器2 ip地址

ESC
:wq
```

5. 配置storage(在storage服務器)

```
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf

base_path=/data/fdfs/storage
store_path0=/data/fdfs/storage #這樣配置只有M00
tracker_server=192.168.1.101:22122 #tracker服務器1 ip地址
tracker_server=192.168.1.102:22122 #tracker服務器2 ip地址
group_name=group0

#以下配置安裝FastDHT才配置!!!!!!!!!!
#以下配置安裝FastDHT才配置!!!!!!!!!!
#以下配置安裝FastDHT才配置!!!!!!!!!!

check_file_duplicate=1
key_namespace=FastDFS
keep_alive=1
#include /etc/fdht/fdht_servers.conf

ESC
:wq
```

6. 配置tracker(在tracker服務器)

```
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
vim /etc/fdfs/tracker.conf

base_path=/data/fdfs/tracker
# 0輪詢 1指定組 2最大剩餘空間
store_lookup=2

ESC
:wq
```

7. 啓動tracker和storage

```
# 用來做storage的服務器執行
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
# 用來做tracker的服務器執行
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
```

8. 開機啓動

“`
# 用來做storage的服務器執行
vim /etc/rc.local
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
ESC
:wq

# 用來做tracker的服務器執行
vim /etc/rc.local
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
ESC
:wq

“`

1. 可通過日誌查看是否啓動成功

```
# 用來做storage的服務器執行
tail -f /data/fdfs/storage/logs/storaged.log

# 用來做tracker的服務器執行
tail -f /data/fdfs/tracker/logs/trackerd.log

#在storage服務器創建軟連接
ln -s /data/fdfs/storage/data/ /data/fdfs/storage/data/group0/M00
```

2. 停止(不要執行)

```
# 用來做storage的服務器執行
pkill fdfs_storaged

# 用來做tracker的服務器執行
pkill fdfs_trackerd
```

3. 防火牆相關配置

```
yum install firewalld
systemctl enable firewalld
systemctl start firewalld
#開啓 8888 22122 23000 端口
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
systemctl restart firewalld
```

4. 測試功能是否正常

```
cd /
#上傳
/usr/bin/fdfs_test          /etc/fdfs/client.conf upload /root/anaconda-ks.cfg

#下載
/usr/bin/fdfs_download_file /etc/fdfs/client.conf group1/M00/00/00/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg
#查看下載文件
ll /
#刪除下載文件
rm /xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg

#刪除
/usr/bin/fdfs_delete_file   /etc/fdfs/client.conf group1/M00/00/00/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.cfg
```

5. 爲php安裝fastdfs_client擴展

```
進入擴展源碼目錄
cd /root/fastdfs-5.08/php_client
初始化
/usr/local/php-7.0.13/bin/phpize
配置
./configure --with-php-config=/usr/local/php-7.0.13/bin/php-config
安裝
make
make install
增量配置
一定注意,這裏要修改/etc/fdfs/client.conf文件中tracker服務器地址!!!!!!!!!!!!!!
一定注意,這裏要修改/etc/fdfs/client.conf文件中tracker服務器地址!!!!!!!!!!!!!!
一定注意,這裏要修改/etc/fdfs/client.conf文件中tracker服務器地址!!!!!!!!!!!!!!
cat /root/fastdfs-5.08/php_client/fastdfs_client.ini >> /usr/local/php-7.0.13/lib/php.ini
重啓php-fpm
kill -USR2 `cat /usr/local/php-7.0.13/var/run/php-fpm.pid`
```

6. 爲php安裝fastcommon擴展

```
進入擴展源碼目錄
cd /root/libfastcommon/php-fastcommon
初始化
/usr/local/php-7.0.13/bin/phpize
配置
./configure --with-php-config=/usr/local/php-7.0.13/bin/php-config
安裝
make
make install
vim /usr/local/php-7.0.13/lib/php.ini
extension=fastcommon.so
ESC
:wq
重啓php-fpm
kill -USR2 `cat /usr/local/php-7.0.13/var/run/php-fpm.pid`
```
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章