|
|
# 一、前言
|
|
|
|
|
|
#FastHT
|
|
|
## 一、前言
|
|
|
FastDHT解决FastDFS重复文件上传,不支持重复文件去重的造成磁盘资源浪费的痛点。
|
|
|
FastDHT是分布式哈希系统(DHT),使用BerkeleyDB做数据存储,使用libevent做网络IO处理。依赖于libfastcommon。
|
|
|
|
|
|
# 二、安装
|
|
|
|
|
|
## 1、基本环境:
|
|
|
## 二、安装
|
|
|
### 1、基本环境:
|
|
|
CentOS7、libfastcommon、Berkeley、FastDHT
|
|
|
## 2、安装前需要的环境gcc
|
|
|
### 2、安装前需要的环境gcc
|
|
|
```
|
|
|
yum install make cmake gcc gcc-c++
|
|
|
cd /usr/local/src
|
|
|
```
|
|
|
### ①安装libfastcommon (安装FastDFS应该已经装了。无需重复安装)
|
|
|
#### ①安装libfastcommon (安装FastDFS应该已经装了。无需重复安装)
|
|
|
```
|
|
|
unzip libfastcommon-master.zip
|
|
|
cd libfastcommon-master
|
|
|
./make.sh && ./make.sh install
|
|
|
```
|
|
|
### ②安装 Berkeley DB
|
|
|
#### ②安装 Berkeley DB
|
|
|
```
|
|
|
wget http://download.oracle.com/berkeley-db/db-6.2.32.tar.gz
|
|
|
cd /usr/local/src/db-6.2.32/build_unix/
|
... | ... | @@ -26,7 +26,7 @@ chmod 777 ../dist/configure |
|
|
make && make install
|
|
|
```
|
|
|
|
|
|
### ③安装fastDHT
|
|
|
#### ③安装fastDHT
|
|
|
```
|
|
|
cd /usr/local/src/
|
|
|
git clone https://github.com/happyfish100/fastdht.git --depth 1
|
... | ... | @@ -35,37 +35,33 @@ cd fastdht |
|
|
./make.sh && ./make.sh install
|
|
|
```
|
|
|
最后会在/usr/local/bin生成安装后的文件,在/etc/fdht下生成配置文件。
|
|
|
|
|
|
# 二、环境配置
|
|
|
|
|
|
## 1、创建目录
|
|
|
## 二、环境配置
|
|
|
### 1、创建目录
|
|
|
```
|
|
|
mkdir /fastdht
|
|
|
```
|
|
|
## 2、修改fdhtd.conf文件
|
|
|
### 2、修改fdhtd.conf文件
|
|
|
```
|
|
|
vim /etc/fdht/fdhtd.conf
|
|
|
port=11411
|
|
|
base_path=/fastdht
|
|
|
#include /etc/fdht/fdht_servers.conf
|
|
|
```
|
|
|
## 3、修改fdht_servers.conf文件
|
|
|
|
|
|
### 3、修改fdht_servers.conf文件
|
|
|
```
|
|
|
vim /etc/fdht/fdht_servers.conf
|
|
|
group_count = 2 #数字可自定义
|
|
|
group0 = 192.168.224.223:11411
|
|
|
group1 = 192.168.224.223:11411
|
|
|
```
|
|
|
|
|
|
## 4、修改fdht_client.conf文件
|
|
|
### 4、修改fdht_client.conf文件
|
|
|
```
|
|
|
vim /etc/fdht/fdht_client.conf
|
|
|
keep_alive=1 #本选项关联 storaged.conf文件
|
|
|
base_path= /fastdht
|
|
|
#include /etc/fdht/fdht_servers.conf #注意:#和include之间没有空格)
|
|
|
```
|
|
|
## 5、修改storage.conf文件
|
|
|
### 5、修改storage.conf文件
|
|
|
```
|
|
|
vim /etc/fdfs/storage.conf
|
|
|
#是否检测上传文件已经存在。如果已经存在,则不存在文件内容,建立一个索引链接以节省磁盘空间
|
... | ... | @@ -110,10 +106,10 @@ fdhtd /etc/fdht/fdhtd.conf |
|
|
#执行命令,使之生效:
|
|
|
chmod +x /etc/rc.local
|
|
|
```
|
|
|
## 5、验证
|
|
|
### 6、验证
|
|
|
```
|
|
|
#多次执行命令来上传同一个文件:
|
|
|
fdfs_upload_file /etc/fdfs/client.conf /usr/local/src/nginx-1.15.4.tar.gz
|
|
|
#目录存在多个软连接,说明FastDHT文件去重功能已经成功实现
|
|
|
ll ../fastdfs/storage/data/00/01
|
|
|
``` |
|
|
\ No newline at end of file |
|
|
``` |