FastDFS 安装配置和测试

1 资源信息

服务器信息 IP地址
tracker服务器 192.168.51.5
storage服务器 192.168.51.6
资源信息 版本 备注
libfastcommon 1.0.42 FastDFS分离出的一些公用函数包
fastdfs 6.04 FastDFS Linux部署文件

官网地址:https://github.com/happyfish100/fastdfs

CSDN下载地址: FastDFS资源集合

因为storage服务启动的时候需要向tracker服务发送心跳,因此配置的过程中,需要先启动tracker服务,再启动storage服务

2 文件上传

官网部署文档地址:https://github.com/happyfish100/fastdfs

将文件通过FTP或者命令的方式,上传到两台服务器上,我这边的上传目录为 /opt/module/software/FastDFS

[root@localhost ~]# cd /opt/module/software/FastDFS
[root@localhost FastDFS]# ll
总用量 1984
-rw-r--r--.  1 root root  800157 3月  11 10:24 fastdfs-6.04.tar.gz
-rw-r--r--.  1 root root  164704 3月  11 10:24 libfastcommon-1.0.42.tar.gz

3 配置tracker服务

tracker服务器 上准备安装tracker服务 ,也就是IP为 192.168.51.5 的虚拟机上。

3.1 安装基础环境

[root@localhost FastDFS]# yum install -y gcc gcc-c++
[root@localhost FastDFS]# yum -y install libevent

3.2 安装libfatscommon函数库

3.2.1 解压文件

[root@localhost FastDFS]# tar -zxvf libfastcommon-1.0.42.tar.gz

3.2.2 编译并安装

[root@localhost FastDFS]# cd /opt/module/software/FastDFS/libfastcommon-1.0.42
[root@localhost libfastcommon-1.0.42]# ./make.sh
[root@localhost libfastcommon-1.0.42]# ./make.sh install

3.3 安装FastDFS

3.3.1 解压文件

[root@localhost libfastcommon-1.0.42]#  cd /opt/module/software/FastDFS/
[root@localhost FastDFS]# tar -zxvf fastdfs-6.04.tar.gz
[root@localhost FastDFS]# cd opt/module/software/FastDFS/fastdfs-6.04
[root@localhost FastDFS]# mkdir -p /usr/bin
[root@localhost FastDFS]# mkdir -p /etc/fdfs
[root@localhost fastdfs-6.04]# vi make.sh

3.3.2 查看安装路径

TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc/fdfs
TARGET_INIT_PATH=$DESTDIR/etc/init.d

3.3.3 编译并安装

[root@localhost fastdfs-6.04]# ./make.sh
[root@localhost fastdfs-6.04]# ./make.sh install

3.3.4 查看安装

[root@localhost fastdfs-6.04]# cd /usr/bin
[root@localhost bin]# ls fdfs_*
fdfs_appender_test   fdfs_append_file  fdfs_delete_file    fdfs_file_info  fdfs_regenerate_filename  fdfs_test   fdfs_trackerd         fdfs_upload_file
fdfs_appender_test1  fdfs_crc32        fdfs_download_file  fdfs_monitor    fdfs_storaged             fdfs_test1  fdfs_upload_appender
[root@localhost etc]# cd /etc/fdfs
[root@localhost fdfs]# ll
总用量 120
-rw-r--r--. 1 root root 23981 3月  11 10:35 anti-steal.jpg
-rw-r--r--. 1 root root  1834 3月  11 10:35 client.conf
-rw-r--r--. 1 root root  1834 3月  11 10:32 client.conf.sample
-rw-r--r--. 1 root root   955 3月  11 10:35 http.conf
-rw-r--r--. 1 root root 31172 3月  11 10:35 mime.types
-rw-r--r--. 1 root root  3753 3月  11 13:53 mod_fastdfs.conf
-rw-r--r--. 1 root root 10085 3月  11 10:35 storage.conf
-rw-r--r--. 1 root root 10085 3月  11 10:32 storage.conf.sample
-rw-r--r--. 1 root root   527 3月  11 10:35 storage_ids.conf
-rw-r--r--. 1 root root   527 3月  11 10:32 storage_ids.conf.sample
-rw-r--r--. 1 root root  8077 3月  11 10:48 tracker.conf
-rw-r--r--. 1 root root  8038 3月  11 10:32 tracker.conf.sample
  • /usr/bin 中包含了可执行文件

  • /etc/fdfs 包含了配置文件

3.4 修改配置文件

3.4.1 修改工作目录

[root@localhost conf]# cp /opt/module/software/FastDFS/fastdfs-6.04/conf/* /etc/fdfs/
[root@localhost conf]# mkdir /usr/local/fastdfs/tracker -p
[root@localhost conf]# vi /etc/fdfs/tracker.conf
# tracker工作目录,保存数据以及日志
base_path=/usr/local/fastdfs/tracker

3.4.2 启动tracker服务

[root@localhost conf]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
[root@localhost conf]# ps -ef|grep tracker
root      33667      1  0 10:49 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

3.4.3 停止tracker服务

[root@localhost conf]# /usr/bin/stop.sh /etc/fdfs/tracker.conf

4 配置storage服务

storage服务器 上准备安装 storage服务 ,也就是IP为 192.168.51.6 的虚拟机上。

4.1 安装基础环境

[root@localhost FastDFS]# yum install -y gcc gcc-c++
[root@localhost FastDFS]# yum -y install libevent

4.2 安装libfatscommon函数库

4.2.1 解压文件

[root@localhost FastDFS]# tar -zxvf libfastcommon-1.0.42.tar.gz

4.2.2 编译并安装

[root@localhost FastDFS]# cd /opt/module/software/FastDFS/libfastcommon-1.0.42
[root@localhost libfastcommon-1.0.42]# ./make.sh
[root@localhost libfastcommon-1.0.42]# ./make.sh install

4.3 安装FastDFS

4.3.1 解压文件

[root@localhost libfastcommon-1.0.42]#  cd /opt/module/software/FastDFS/
[root@localhost FastDFS]# tar -zxvf fastdfs-6.04.tar.gz
[root@localhost FastDFS]# cd opt/module/software/FastDFS/fastdfs-6.04
[root@localhost FastDFS]# mkdir -p /usr/bin
[root@localhost FastDFS]# mkdir -p /etc/fdfs
[root@localhost fastdfs-6.04]# vi make.sh

4.3.2 查看安装路径

TARGET_PREFIX=$DESTDIR/usr
TARGET_CONF_PATH=$DESTDIR/etc/fdfs
TARGET_INIT_PATH=$DESTDIR/etc/init.d

4.3.3 编译并安装

[root@localhost fastdfs-6.04]# ./make.sh
[root@localhost fastdfs-6.04]# ./make.sh install

4.4 修改配置文件

4.4.1 配置storage

[root@localhost conf]# cp /opt/module/software/FastDFS/fastdfs-6.04/conf/* /etc/fdfs/
[root@localhost conf]# mkdir /usr/local/fastdfs/storage -p
[root@localhost conf]# vi /etc/fdfs/storage.conf

修改内容

# 修改组名
group_name=auskat
# 修改storage的工作空间
base_path=/usr/local/fastdfs/storage
# 修改storage的存储空间
store_path0=/usr/local/fastdfs/storage
# 修改tracker的地址和端口号,用于心跳
tracker_server=192.168.51.5:22122
# 后续结合nginx的一个对外服务端口号
http.server_port=8888

4.4.2 启动storage服务

[root@localhost conf]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf
[root@localhost ~]# ps -ef|grep storage
root      20276      1  0 07:09 ?        00:00:15 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf

4.4.3 停止storage服务

[root@localhost conf]# /usr/bin/stop.sh etc/fdfs/storage.conf

5 功能测试

5.1 修改client配置

[root@localhost conf]# mkdir /usr/local/fastdfs/client -p
[root@localhost conf]# vi /etc/fdfs/client.conf

修改内容

# 配置路径
base_path=/usr/local/fastdfs/client
# 配置tracker地址
tracker_server=192.168.51.5:22122

5.2 测试上传

将事先准备好的 测试图片 test.jpg 上传到 /opt/module/ 目录下

[root@localhost conf]# /usr/bin/fdfs_test /etc/fdfs/client.conf upload /opt/module/test.jpg 
This is FastDFS client test program v6.04

Copyright (C) 2008, Happy Fish / YuQing

FastDFS may be copied only under the terms of the GNU General
Public License V3, which may be found in the FastDFS source kit.
Please visit the FastDFS Home Page http://www.fastken.com/ 
for more detail.

[2021-03-11 11:06:47] DEBUG - base_path=/usr/local/fastdfs/client, connect_timeout=10, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

tracker_query_storage_store_list_without_group: 
	server 1. group_name=, ip_addr=192.168.51.6, port=23000

group_name=auskat, ip_addr=192.168.51.6, port=23000
storage_upload_by_filename
group_name=auskat, remote_filename=M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg
source ip address: 192.168.51.6
file timestamp=2021-03-11 11:06:47
file size=333722
file crc32=1187530787
example file url: http://192.168.51.6/auskat/M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg
storage_upload_slave_by_filename
group_name=auskat, remote_filename=M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506_big.jpg
source ip address: 192.168.51.6
file timestamp=2021-03-11 11:06:47
file size=333722
file crc32=1187530787
example file url: http://192.168.51.6/auskat/M00/00/00/wKgzBmBJiUeAI4QjAAUXmkbISCM506_big.jpg

5.3 查看信息

[root@localhost conf]# cd /usr/local/fastdfs/storage/data/00/00
root@localhost 00]# ll
总用量 872
-rw-r--r--. 1 root root 333722 3月  11 11:06 wKgzBmBJiUeAI4QjAAUXmkbISCM506_big.jpg
-rw-r--r--. 1 root root     49 3月  11 11:06 wKgzBmBJiUeAI4QjAAUXmkbISCM506_big.jpg-m
-rw-r--r--. 1 root root 333722 3月  11 11:06 wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg
-rw-r--r--. 1 root root     49 3月  11 11:06 wKgzBmBJiUeAI4QjAAUXmkbISCM506.jpg-m
-rw-r--r--. 1 root root 102921 3月  11 15:29 wKgzBmBJxtOAE2YdAAGSCZ4xzd8808.png
-rw-r--r--. 1 root root 102921 3月  11 15:39 wKgzBmBJyTmADux5AAGSCZ4xzd8581.png

6 相关信息

  • 博文不易,辛苦各位猿友点个关注和赞,感谢

猜你喜欢

转载自blog.csdn.net/qq_15769939/article/details/115060989