FastDFS distributed cluster quickly erected (graphic details)

A, FastDFS planning to build clusters

FastDFS-tracker-group-01-131		192.168.44.131
FastDFS-tracker-group-02-132		192.168.44.132

FastDFS-storage-group1-01-135		192.168.44.135
FastDFS-storage-group1-02-136		192.168.44.136

FastDFS-storage-group2-01-137		192.168.44.137
FastDFS-storage-group2-02-138		192.168.44.138

Second, the installation of public dependent (6 hosts simultaneously perform)

1, upload source packages

#创建文件夹/opt/module(模块安装路径) /opt/software(源码包路径)
mkdir -p /opt/module /opt/software

#上传源码包到/opt/software下

#切换目录并查看
cd /opt/software && ll

Here Insert Picture Description

2, the installation dependencies

#编译依赖包
yum install -y make cmake gcc gcc-c++

#nginx需要的依赖
yum instll -y pcre pcre-devel zlib zlib-devel

#其它
yum install -y unzip zip telnet vim

#整合命令
yum install -y make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel unzip zip telnet vim

3, installation libfastcommon

1): extracting libfastcommon-master.zip to opt / lower / module

#进入/opt/software目录
cd /opt/software

#解压到指定位置
unzip libfastcommon-master.zip -d /opt/module/

#切换目录并查看
 cd /opt/module && ll

Here Insert Picture Description

2): compile and install

#进入libfastcommon-master目录
cd libfastcommon-master/

#编译
./make.sh

#安装
./make.sh install

Here Insert Picture Description

  • Note that the installation path: libfastcommon installed by default to the / usr / lib64 / this position.

3): Create a soft link

  • FastDFS set for the main program directory / usr / local / lib /, so we need to create some soft-core connection file execution of the program / usr / lib64 / under
#创建目录
mkdir -p /usr/local/lib/

#创建软链接
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so
ln -s /usr/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so

4, the installation FastDFS 5.05

1): extracting FastDFS_v5.05.tar.gz to opt / lower / module

#切换目录
cd /opt/software/

#解压到/opt/module
tar -zxvf FastDFS_v5.05.tar.gz -C /opt/module/

#切换/opt/module目录
cd /opt/module && ll

2): compile and install

#进入FastDFS目录
cd FastDFS/

#编译
./make.sh

#安装
./make.sh install

#整合命令
cd FastDFS/ && ./make.sh && ./make.sh install

3): Modify the configuration file path FastDFS

#编辑fdfs_storaged
vim /etc/init.d/fdfs_storaged
#进行全局替换命令
%s+/usr/local/bin+/usr/bin

#编辑fdfs_trackerd
vim /etc/init.d/fdfs_trackerd
进行全局替换命令
%s+/usr/local/bin+/usr/bin

Third, the group configuration tracker (192.168.44.131 192.168.44.132 two nodes simultaneously executed)

1, the copy of the / etc / fdfs tracker.conf.samp is tracker.conf

#创建存储目录
mkdir -p  /opt/module/FastDFS/repo/tracker

#拷贝 /etc/fdfs下tracker.conf.samp 为tracker.conf
cd /etc/fdfs/
cp tracker.conf.sample tracker.conf

Here Insert Picture Description

2, edit tracker.conf

#编辑
vim /etc/fdfs/tracker.conf

#修改内容
store_lookup=0
base_path=/opt/module/FastDFS/repo/tracker

Here Insert Picture Description

3, start tracker

#查看自己创建的目录
cd /opt/module/FastDFS/repo/tracker/ && ll

#启停tracker
/etc/init.d/fdfs_trackerd start
/etc/init.d/fdfs_trackerd stop
#查看日志
tail -100 /opt/module/FastDFS/repo/tracker/logs/trackerd.log 

#查看进程
ps -ef | grep fdfs

Here Insert Picture Description

Fourth, the configuration storage storage (192.168.44.135 192.168.44.136 192.168.44.137 192.168.44.138 four storage nodes simultaneously performed)

1, copy / etc / fdfs the storage.conf.sample is storage.conf

#创建存储目录
mkdir -p /opt/module/FastDFS/repo/storage

#拷贝
cd /etc/fdfs/
cp storage.conf.sample storage.conf

2, edit storage.conf

  • Stored packet description: the same configuration of the same group (135 136 to the same group group1), (137 138 to the same group group2)
#修改storage.conf文件
vim /etc/fdfs/storage.conf

#修改内容:
#(135 136为group1)、(137 138为group2)
group_name=group1
base_path=/opt/module/FastDFS/repo/storage
store_path_count=1
store_path0=/opt/module/FastDFS/repo/storage
#多个tracker直接添加多条配置
tracker_server=192.168.44.131:22122
tracker_server=192.168.44.132:22122
http.server_port=8888

3, start storage (192.168.44.131 192.168.44.132 tracker must first start)

#查看存储节点
cd /opt/module/FastDFS/repo/storage/ && ll

#启停storage
/etc/init.d/fdfs_storaged start
/etc/init.d/fdfs_storaged stop
#查看日志
tail -f /opt/module/FastDFS/repo/storage/logs/storaged.log 

#查看进程
ps -ef | grep fdfs

Here Insert Picture Description

4, any storage node can see the current cluster information

#查询相关命令
 cd /usr/bin/ &&  ll | grep  fdfs
 
 #查看集群信息
  /usr/bin/fdfs_monitor /etc/fdfs/storage.conf

Here Insert Picture Description

V. test file upload (192.168.44.131)

1, copy / etc / fdfs / client.conf.sample of the client.conf

#拷贝
cd /etc/fdfs/
cp client.conf.sample client.conf

2, edit client.conf

#编辑client.conf文件
vim /etc/fdfs/client.conf

修改内容:
base_path=/opt/module/FastDFS/repo/tracker
tracker_server=192.168.44.131:22122
tracker_server=192.168.44.132:22122

3, test upload

#查看相关命令工具
cd /usr/bin/ && ls | grep fdfs

#上传命令
/usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/software/libfastcommon-master.zip 

#查看存储目录
cd /opt/module/FastDFS/repo/storage/data/00/00 && ls

Here Insert Picture Description
Here Insert Picture Description

  • If the file is uploaded to the group1 group (135 136) automatic backup node, if the file is uploaded to the group2 group (137 138) node data is automatically backed up.
  • Other: File down occurs if the node 135, will be automatically restored after the synchronization pull node 136

Sixth, fastdfs-nginx-module configuration

1, the installation fastdfs-nginx-module

#切换目录
cd /opt/software/ && ll

#解压到指定目录
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz -C /opt/module/

#查看解压后的信息
cd /opt/module && ll

Here Insert Picture Description

2, compile and install

#切换目录
cd /opt/module/fastdfs-nginx-module/src/
#编辑
vim /opt/module/fastdfs-nginx-module/src/config
#修改内容
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/local/include/fastcommon/"
修改为
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/local/fastcommon/"

Seven, configure Nginx

opt / under 1, to extract the nginx-1.6.2.tar.gz / module

#查看源码包并解压
cd /opt/software/
tar -zxvf nginx-1.6.2.tar.gz -C /opt/module/
#切换目录
cd /opt/module/nginx-1.6.2/
#加入模块
./configure --add-module=/opt/module/fastdfs-nginx-module/src/
#重新编译安装
make && make install

2, copy / opt / module / fastdfs-nginx-module / src / the mod_fastdfs.conf file to / etc / and modify the fdfs

#拷贝文件
cp /opt/module/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
#编辑
vim /etc/fdfs/mod_fastdfs.conf
#修改内容
connect_timeout=10
#(135 136同组为group1)、(137 138同组为group2)
group_name=group1
tracker_server=192.168.44.131:22122
tracker_server=192.168.44.132:22122
url_have_group_name = true
store_path0=/opt/module/FastDFS/repo/storage
group_count = 2

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/opt/module/FastDFS/repo/storage

[group2]
group_name=group2
storage_server_port=23000
store_path_count=1
store_path0=/opt/module/FastDFS/repo/storage

3, copy the configuration file FastDFS

cp /opt/module/FastDFS/conf/http.conf /etc/fdfs/
cp /opt/module/FastDFS/conf/mime.types /etc/fdfs/

4. Create a soft link

#在/opt/module/FastDFS/repo/storage文件存储目录下创建软连接,将其链接到实际存放数据的目录。
ln -s /opt/module/FastDFS/repo/storage/data/ /opt/module/FastDFS/repo/storage/data/M00

5, modify the configuration file Nginx

#切换目录
cd /usr/local/nginx/conf/ && ll
vim nginx.conf
  • Content
    Here Insert Picture Description
  • change into
listen 8888;
server_name localhost;
location ~/group([0-9])/M00 {
ngx_fastdfs_module;
}

6, start the service nginx

#启动
/usr/local/nginx/sbin/nginx
#查看进程
ps -ef|grep nginx

Here Insert Picture Description

7, showing the effect of

#理论
135 136同组可访问
137 138同组可访问

Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44187730/article/details/88047779