FastDFS分布式文件管理系统集群

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`
```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值