*服务器规划
跟踪服务器1【主机】(Tracker Server):10.10.77.165
存储服务器2(Storage Server):10.10.77.166
存储服务器3(Storage Server):10.10.77.167
数据存储目录
应用 | 安装目录 |
---|---|
安装包 | /usr/local/src |
Tracker_data | /fastdfs/tracker |
Storage_data | /fastdfs/storage |
nginx | /opt/nginx |
安装包:
FastDFS_v5.08.tar.gz:FastDFS源码
libfastcommon-master.zip:(从 FastDFS 和 FastDHT 中提取出来的公共 C 函数库)
fastdfs-nginx-module-master.zip:storage节点http服务nginx模块
nginx-1.10.0.tar.gz:Nginx安装包
下载完成后,将压缩包解压到/usr/local/src目录下
正式开始前需要确认gcc、g++开发库已经预先安装好,检查gcc是否安装,gcc --version
检查g++是否安装,g++ --version。
如果是离线安装,还需要以下包,,下面的三个包主要是编译nginx所需要的包:
zlib-1.2.11.tar.gz
pcre-8.12.tar.gz
openssl-1.1.0g.tar.gz
将包上传到服务器后,依次安装,安装命令如下:
pcre安装
执行如下命令:
tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42/
./configure
make
make install
zlib安装
执行如下命令:
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure
make
make install
openssl安装
执行如下命令:
tar -zxvf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h/
./config
make
make install
正式开始:
**
步骤一:所有tracker和storage节点都执行如下操作**
1、安装所需的依赖包
yum install make cmake gcc gcc-c++
2、安装libfatscommon依次执行下列命令
cd /usr/local/src
unzip libfastcommon-master.zip
cd libfastcommon-master
./make.sh
./make.sh install
3、安装FastDFS 依次执行下列命令
cd /usr/local/src
tar -xzvf FastDFS_v5.08.tar.gz
cd FastDFS
./make.sh
./make.sh install
采用默认安装方式,相应的文件与目录检查如下:
1> 服务脚本:
/etc/init.d/fdfs_storaged
/etc/init.d/fdfs_trackerd
2> 配置文件(示例配置文件):
ll /etc/fdfs/
出现下列内容
-rw-r–r-- 1 root root 1461 1月 4 14:34 client.conf.sample
-rw-r–r-- 1 root root 7927 1月 4 14:34 storage.conf.sample
-rw-r–r-- 1 root root 7200 1月 4 14:34 tracker.conf.sample
3> 命令行工具(/usr/bin目录下)
ll /usr/bin/fdfs_*
出现下列内容
-rwxr-xr-x 1 root root 260584 1月 4 14:34 fdfs_appender_test
-rwxr-xr-x 1 root root 260281 1月 4 14:34 fdfs_appender_test1
-rwxr-xr-x 1 root root 250625 1月 4 14:34 fdfs_append_file
-rwxr-xr-x 1 root root 250045 1月 4 14:34 fdfs_crc32
-rwxr-xr-x 1 root root 250708 1月 4 14:34 fdfs_delete_file
-rwxr-xr-x 1 root root 251515 1月 4 14:34 fdfs_download_file
-rwxr-xr-x 1 root root 251273 1月 4 14:34 fdfs_file_info
-rwxr-xr-x 1 root root 266401 1月 4 14:34 fdfs_monitor
-rwxr-xr-x 1 root root 873233 1月 4 14:34 fdfs_storaged
-rwxr-xr-x 1 root root 266952 1月 4 14:34 fdfs_test
-rwxr-xr-x 1 root root 266153 1月 4 14:34 fdfs_test1
-rwxr-xr-x 1 root root 371336 1月 4 14:34 fdfs_trackerd
-rwxr-xr-x 1 root root 251651 1月 4 14:34 fdfs_upload_appender
-rwxr-xr-x 1 root root 252781 1月 4 14:34 fdfs_upload_file
**
步骤二:配置tracker服务器
**
1、复制tracker样例配置文件,并重命名
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
2、修改tracker配置文件
vim /etc/fdfs/tracker.conf
主要修改以下内容
disabled=false # 启用配置文件
port=22122 # tracker服务器端口(默认22122)
base_path=/fastdfs/tracker # 存储日志和数据的根目录
store_group=group1
其它参数保留默认配置, 具体配置解释可参考官方文档说明:http://bbs.chinaunix.net/thread-1941456-1-1.html
3、创建base_path指定的目录
mkdir -p /fastdfs/tracker
4、防火墙中打开tracker服务器端口( 默认为 22122)
防火墙如果是iptables
vi /etc/sysconfig/iptables
添加如下端口行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22122 -j ACCEPT
重启防火墙
service iptables restart
防火墙人如果是firewall
新开端口
firewall-cmd --zone=public --add-port=端口/tcp --permanent
重启
firewall-cmd --reload
5、启动tracker服务器
/etc/init.d/fdfs_trackerd start
初次启动,会在/fastdfs/tracker目录下生成logs、data两个目录。
drwxr-xr-x 2 root root 4096 1月 4 15:00 data
drwxr-xr-x 2 root root 4096 1月 4 14:38 logs
检查FastDFS Tracker Server是否启动成功:
ps -ef | grep fdfs_trackerd
tracker启动与停止
停止:
killall fdfs_trackerd
启动:
/etc/init.d/fdfs_trackerd start
或者
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf(确定一下/usr/local/bin还是/usr/bin)
重启:
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
三、配置storage服务器
1、复制storage样例