fastDFS 6.0.9 单机安装案例

news2024/10/6 16:17:53

文章目录

  • `fastDFS 6.0.9`单机安装案例
    • (1)前置环境安装明细
    • (2)依赖库安装
    • (3)`libfatscommon`安装
    • (4)`libserverframe` 安装
    • (5)`FastDFS` 安装
      • 默认命令工具查看
    • (6)配置文件修改
        • `/etc/fdfs/tracker.conf`修改启动tracker
        • `/etc/fdfs/storage.conf`修改启动storage
        • 查看storage和tracker是否在通讯
        • 上传图片测试
    • (7)nginx 安装
    • (8)`fastdfs-nginx-module` 安装
    • (9)`nginx` 集成 `fastdfs-nginx-module`
    • (10)最终结果演示
    • 参考资料

fastDFS 6.0.9单机安装案例

好奇之前项目里用到的文件存储系统,决定自己搭建一个玩玩,于是乎开始倒腾,发现fastdfs安装部署这块内容网上还是比较多的但是版本啥的都已经比较老旧了,于是乎搜了下官方公众号最近的一次推荐部署版本 V6.09,就准备开干了。网上搜了下已经有大哥部署过该版本了centos7上单机安装fastdfs6.0.9,我就结合官网的install和大哥的手册跟着来了一遍,全程没卡壳很顺利。

(1)前置环境安装明细

依赖库备注
libfatscommon基础库-fastdfs分离出来的公共函数 (V1.0.61 版本)
libserverframe基础库-网络框架库 (V1.1.20 版本)
FastDFSfastdfs (6.0.9 版本)
fastdfs-nginx-modulefastdfs与nginx整合模块 (V1.23版本)
nginxnginx (1.22.1版本)

(2)依赖库安装

[root@localhost ~]# yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel -y

Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.ustc.edu.cn
base    
................
................
Complete!

(3)libfatscommon安装

我这里是用的git的方式下载然后进行编译安装,你们也可以去它的git官网找到对应的 tag下载对应的压缩包上传后进行编译安装

  • git clone https://gitee.com/fastdfs100/libfastcommon.git
  • cd libfastcommon
  • git checkout V1.0.61
  • ./make.sh clean && ./make.sh && ./make.sh install
[root@localhost installpackage]# git clone https://gitee.com/fastdfs100/libfastcommon.git
Cloning into 'libfastcommon'...
remote: Enumerating objects: 4887, done.
remote: Counting objects: 100% (708/708), done.
remote: Compressing objects: 100% (707/707), done.
remote: Total 4887 (delta 494), reused 0 (delta 0), pack-reused 4179
Receiving objects: 100% (4887/4887), 1.72 MiB | 1.62 MiB/s, done.
Resolving deltas: 100% (3702/3702), done.
[root@localhost installpackage]# cd libfastcommon/
[root@localhost libfastcommon]# git checkout V1.0.61
Note: checking out 'V1.0.61'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at c416c6e... upgrade version to 1.0.61
[root@localhost libfastcommon]# ./make.sh clean && ./make.sh && ./make.sh install
rm -f hash.o chain.o shared_func.o ini_file_reader.o logger.o sockopt.o base64.o sched_thread.o http_func.o md5.o pthread_func.o local_ip_func.o avl_tree.o ioevent.o ioevent_loop.o fast_task_queue.o fast_timer.o locked_timer.o process_ctrl.o fast_mblock.o 
...............................................................
thread_pool.lo array_allocator.lo sorted_array.lo  libfastcommon.so libfastcommon.a
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o shared_func.o shared_func.c  
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -c -o ini_file_reader.o ini_file_reader.c  
....................................................................
 multi_socket_client.o skiplist_set.o uniq_skiplist.o json_parser.o buffered_file_writer.o server_id_func.o fc_queue.o sorted_queue.o fc_memory.o shared_buffer.o thread_pool.o array_allocator.o sorted_array.o
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/fastcommon
install -m 755 libfastcommon.so /usr/lib64
install -m 644 common_define.h hash.h chain.h logger.h base64.h shared_func.h pthread_func.h ini_file_reader.h _os_define.h 
locked_list.h json_parser.h buffered_file_writer.h server_id_func.h fc_queue.h sorted_queue.h fc_memory.h shared_buffer.h thread_pool.h fc_atomic.h array_allocator.h sorted_array.h /usr/include/fastcommon

(4)libserverframe 安装

我这里是用的git的方式下载然后进行编译安装,你们也可以去它的git官网找到对应的 tag下载对应的压缩包上传后进行编译安装

  • git clone https://gitee.com/fastdfs100/libserverframe.git
  • cd libserverframe/
  • git checkout V1.1.20
  • ./make.sh clean && ./make.sh && ./make.sh install
[root@localhost installpackage]# git clone https://gitee.com/fastdfs100/libserverframe.git
Cloning into 'libserverframe'...
remote: Enumerating objects: 2218, done.
remote: Counting objects: 100% (817/817), done.
remote: Compressing objects: 100% (803/803), done.
remote: Total 2218 (delta 568), reused 0 (delta 0), pack-reused 1401
Receiving objects: 100% (2218/2218), 452.70 KiB | 0 bytes/s, done.
Resolving deltas: 100% (1613/1613), done.
[root@localhost installpackage]# 
[root@localhost installpackage]# 
[root@localhost installpackage]# cd libserverframe/
[root@localhost libserverframe]# git checkout V1.1.20
Note: checking out 'V1.1.20'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 16be02e... upgrade version to 1.1.20
[root@localhost libserverframe]# 
[root@localhost libserverframe]# 
[root@localhost libserverframe]#  ./make.sh clean && ./make.sh && ./make.sh install
rm -f sf_nio.lo sf_iov.lo sf_service.lo sf_global.lo sf_func.lo sf_util.lo sf_configs.lo sf_proto.lo sf_sharding_htable.lo sf_cluster_cfg.lo sf_connection_manager.lo sf_serializer.lo sf_binlog_index.lo sf_file_writer.lo sf_binlog_writer.lo idempotency/client/receipt_handler.lo idempotency/client/client_channel.lo libserverframe.so 
....................................................................
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -fPIC -c -o sf_nio.lo sf_nio.c  -Iinclude -I/usr/local/include
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -fPIC -c -o sf_iov.lo sf_iov.c  -Iinclude -I/usr/local/include
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O3 -fPIC -c -o sf_service.lo sf_service.c  -Iinclude -I/usr/local/include
....................................................................
idempotency/server/request_htable.lo idempotency/server/channel_htable.lo idempotency/server/server_handler.lo idempotency/server/request_metadata.lo idempotency/client/receipt_handler.lo idempotency/client/client_channel.lo -lpthread -lfastcommon 
mkdir -p /usr/lib64
mkdir -p /usr/lib
mkdir -p /usr/include/sf/idempotency/common
mkdir -p /usr/include/sf/idempotency/server
mkdir -p /usr/include/sf/idempotency/client
install -m 755 libserverframe.so /usr/lib64
cp -f sf_types.h sf_global.h sf_define.h sf_nio.h sf_service.h sf_func.h sf_util.h sf_configs.h sf_proto.h sf_cluster_cfg.h sf_sharding_htable.h sf_connection_manager.h sf_serializer.h sf_binlog_index.h sf_file_writer.h sf_binlog_writer.h sf_ordered_writer.h sf_buffered_writer.h sf_iov.h sf_shared_mbuffer.h /usr/include/sf
cp -f idempotency/common/idempotency_types.h /usr/include/sf/idempotency/common
cp -f idempotency/server/server_types.h idempotency/server/server_channel.h idempotency/server/request_htable.h idempotency/server/channel_htable.h idempotency/server/server_handler.h idempotency/server/request_metadata.h /usr/include/sf/idempotency/server
cp -f idempotency/client/client_types.h idempotency/client/receipt_handler.h idempotency/client/client_channel.h idempotency/client/rpc_wrapper.h /usr/include/sf/idempotency/client

(5)FastDFS 安装

我这里是用的git的方式下载然后进行编译安装,你们也可以去它的git官网找到对应的 tag下载对应的压缩包上传后进行编译安装

  • git clone https://gitee.com/fastdfs100/fastdfs.git
  • cd fastdfs; git checkout V6.09
  • ./make.sh clean && ./make.sh && ./make.sh install

安装 fastDFS时一定要注意它的 cp -f fdfs_storaged /usr/bin, cp -f fdfs_trackerd /usr/bin 是否成功,如果失败的话就需要重新安装,否则在启动的时候就会有问题

[root@localhost installpackage]# git clone https://gitee.com/fastdfs100/fastdfs.git
Cloning into 'fastdfs'...
remote: Enumerating objects: 2777, done.
remote: Counting objects: 100% (476/476), done.
remote: Compressing objects: 100% (471/471), done.
remote: Total 2777 (delta 291), reused 3 (delta 2), pack-reused 2301
Receiving objects: 100% (2777/2777), 10.51 MiB | 2.28 MiB/s, done.
Resolving deltas: 100% (2053/2053), done.
[root@localhost installpackage]# 
[root@localhost installpackage]# cd fastdfs; git checkout V6.09
Note: checking out 'V6.09'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at e6fcd3e... use atomic counter instead of mutex lock
[root@localhost fastdfs]# 
[root@localhost fastdfs]# ./make.sh clean && ./make.sh && ./make.sh install
rm -f ../common/fdfs_global.o tracker_proto.o tracker_mem.o tracker_service.o tracker_status.o tracker_global.o tracker_func.o fdfs_server_id_func.o fdfs_shared_func.o tracker_relationship.o tracker_dump.o fdfs_trackerd
.............................................................................
ar rcs libfdfsclient.a  ../common/fdfs_global.o ../common/fdfs_http_shared.o ../common/mime_file_parser.o ../tracker/tracker_proto.o ../tracker/fdfs_shared_func.o ../tracker/fdfs_server_id_func.o ../storage/trunk_mgr/trunk_shared.o tracker_client.o client_func.o client_global.o storage_client.o
gcc -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -g -O1 -DDEBUG_FLAG -o libfdfsclient.so  -shared ../common/fdfs_global.lo ../common/fdfs_http_shared.lo ../common/mime_file_parser.lo ../tracker/tracker_proto.lo ../tracker/fdfs_shared_func.lo ../tracker/fdfs_server_id_func.lo ../storage/trunk_mgr/trunk_shared.lo tracker_client.lo client_func.lo client_global.lo storage_client.lo -L/usr/lib64 -lpthread -lfastcommon -lserverframe
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_trackerd /usr/bin
if [ ! -f /etc/fdfs/tracker.conf ]; then cp -f ../conf/tracker.conf /etc/fdfs/tracker.conf; fi
if [ ! -f /etc/fdfs/storage_ids.conf ]; then cp -f ../conf/storage_ids.conf /etc/fdfs/storage_ids.conf; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
cp -f fdfs_storaged  /usr/bin
if [ ! -f /etc/fdfs/storage.conf ]; then cp -f ../conf/storage.conf /etc/fdfs/storage.conf; fi
mkdir -p /usr/bin
mkdir -p /etc/fdfs
mkdir -p /usr/lib64
mkdir -p /usr/lib
cp -f fdfs_monitor fdfs_test fdfs_test1 fdfs_crc32 fdfs_upload_file fdfs_download_file fdfs_delete_file fdfs_file_info fdfs_appender_test fdfs_appender_test1 fdfs_append_file fdfs_upload_appender fdfs_regenerate_filename /usr/bin
if [ 0 -eq 1 ]; then cp -f libfdfsclient.a /usr/lib64; cp -f libfdfsclient.a /usr/lib/;fi
if [ 1 -eq 1 ]; then cp -f libfdfsclient.so /usr/lib64; cp -f libfdfsclient.so /usr/lib/;fi
mkdir -p /usr/include/fastdfs
cp -f ../common/fdfs_define.h ../common/fdfs_global.h ../common/mime_file_parser.h ../common/fdfs_http_shared.h ../tracker/tracker_types.h ../tracker/tracker_proto.h ../tracker/fdfs_shared_func.h ../tracker/fdfs_server_id_func.h ../storage/trunk_mgr/trunk_shared.h tracker_client.h storage_client.h storage_client1.h client_func.h client_global.h fdfs_client.h /usr/include/fastdfs
if [ ! -f /etc/fdfs/client.conf ]; then cp -f ../conf/client.conf /etc/fdfs/client.conf; fi

默认命令工具查看

要注意 fdfs_trackerd, 和 fdfs_trackerd 在不在

[root@localhost fastdfs]# cd /usr/bin/ && ll | grep fdfs
-rwxr-xr-x.   1 root root     380400 Jul 18 22:03 fdfs_appender_test
-rwxr-xr-x.   1 root root     380176 Jul 18 22:03 fdfs_appender_test1
-rwxr-xr-x.   1 root root     367144 Jul 18 22:03 fdfs_append_file
-rwxr-xr-x.   1 root root     365776 Jul 18 22:03 fdfs_crc32
-rwxr-xr-x.   1 root root     367176 Jul 18 22:03 fdfs_delete_file
-rwxr-xr-x.   1 root root     367904 Jul 18 22:03 fdfs_download_file
-rwxr-xr-x.   1 root root     367856 Jul 18 22:03 fdfs_file_info
-rwxr-xr-x.   1 root root     387464 Jul 18 22:03 fdfs_monitor
-rwxr-xr-x.   1 root root     367416 Jul 18 22:03 fdfs_regenerate_filename
-rwxr-xr-x.   1 root root    1297968 Jul 18 22:03 fdfs_storaged
-rwxr-xr-x.   1 root root     390304 Jul 18 22:03 fdfs_test
-rwxr-xr-x.   1 root root     389520 Jul 18 22:03 fdfs_test1
-rwxr-xr-x.   1 root root     509944 Jul 18 22:03 fdfs_trackerd
-rwxr-xr-x.   1 root root     368120 Jul 18 22:03 fdfs_upload_appender
-rwxr-xr-x.   1 root root     369128 Jul 18 22:03 fdfs_upload_file

(6)配置文件修改

创建数据文件

/etc/fdfs/tracker.conf修改启动tracker

vim /etc/fdfs/tracker.conf

  • 防火墙开放端口:
    • firewall-cmd --zone=public --add-port=22122/tcp --permanent
    • firewall-cmd --reload
# 配置文件是否不生效 false为生效
disabled = false
# tracker 服务的端口
port = 22122
# tracker 存储数据和日志文件的根目录,根目录需要提前创建好
base_path = /data/fastdfs/tracker
  • 启动tracker server: /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

  • 检测tracker server 是否启动: ps -ef | grep fd

  • 检测22122端口是否被监听: netstat -tnpl | grep 22122

  • 关闭tracker server(根据自己的需要执行): /usr/bin/fdfs_trackerd stop

[root@localhost tracker]# /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
[root@localhost tracker]# ps -ef | grep fd
root       4703      1  0 22:10 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
root       4714   2739  0 22:11 pts/1    00:00:00 grep --color=auto fd
[root@localhost tracker]# netstat -tnpl | grep 22122
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      4703/fdfs_trackerd  

/etc/fdfs/storage.conf修改启动storage

注意防火墙的开放端口 23000,8888

关闭tracker server(根据自己的需要执行): /usr/bin/fdfs_storaged stop

vim /etc/fdfs/storage.conf

# 配置文件是否不生效,false 为生效
disabled=false 
# 指定此 storage server 所在 组
group_name=group1
# storage server 服务的端口
port=23000
# Storage 数据和日志目录地址,目录必须提前创建好
base_path=/data/fastdfs/storage
# 文件存储路径的个数。
store_path_count=1
# 配置 store_path_count 个路径,索引号从 0 开始。
# 如果不配置 store_path0,那它就和 base_path 的路径一样。
store_path0=/data/fastdfs/storage
# FastDFS 存储文件时,采用了两级目录。这里配置存放文件的目录个数。 
# tracker_server 的列表 ,会主动连接 tracker_server
# 当存在多个 tracker server 时,每个 tracker server 写一行
tracker_server=192.168.121.137:22122
# 此存储服务器上web服务器的端口
http.server_port=8888
[root@localhost tracker]# /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
[root@localhost tracker]# ps -ef | grep fd
root       6895      1  0 23:29 ?        00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
root       6934      1 13 23:30 ?        00:00:03 /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
root       6959   2739  0 23:30 pts/1    00:00:00 grep --color=auto fd
[root@localhost tracker]# 
[root@localhost tracker]# netstat -tnpl | grep 2300
tcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      6934/fdfs_storaged  
[root@localhost tracker]# 

查看storage和tracker是否在通讯

  • /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
  • 注意 tracker server is: XXXX.XXXX.XXXX.XXXX:22122, 和 Storage: 的信息即可
[root@localhost storage]# /usr/bin/fdfs_monitor /etc/fdfs/storage.conf
[2023-07-18 23:36:06] DEBUG - base_path=/opt/software/fastdfs/data/fastdfs/storage, connect_timeout=5, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0, use_connection_pool=1, g_connection_pool_max_idle_time=3600s, use_storage_id=0, storage server id count: 0

server_count=1, server_index=0

tracker server is 192.168.125.100:22122

group count: 1

Group 1:
group name = group1
disk total space = 29,504 MB
disk free space = 18,374 MB
trunk free space = 0 MB
storage server count = 1
active server count = 1
storage server port = 23000
storage HTTP port = 8888
store path count = 1
subdir count per path = 256
current write server index = 0
current trunk file id = 0

	Storage 1:
		id = 192.168.125.100
		ip_addr = 192.168.125.100  ACTIVE
		http domain = 
		version = 6.09
		join time = 2023-07-18 23:30:11
		up time = 2023-07-18 23:30:11
		total storage = 29,504 MB
		free storage = 18,374 MB
		upload priority = 10
		store_path_count = 1
		subdir_count_per_path = 256
		storage_port = 23000
		storage_http_port = 8888
		current_write_path = 0
.......................................
		success_file_read_count = 0
		total_file_write_count = 0
		success_file_write_count = 0
		last_heart_beat_time = 2023-07-18 23:35:47
		last_source_update = 1970-01-01 08:00:00
		last_sync_update = 1970-01-01 08:00:00
		last_synced_timestamp = 1970-01-01 08:00:00 
[root@localhost storage]# 

上传图片测试

可以使用 rz命令选择要上传的文件,也可以使用其它工具进行上传,然后修改下 client.conf的 配置文件

  • vim /etc/fdfs/client.conf
  • /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/software/fastdfs/temp/hlb_head_pic.jpg

使用client的上传命令后,会返回一串上传文件的 文件id, 例如:

group1/M00/00/00/wKh9ZGS2tZmAWHQ2AADDSj7EXjU588.jpg

  • group1: storage的组名
  • M00:磁盘
  • /00/00/:路径
  • wKh9ZGS2tZmAWHQ2AADDSj7EXjU588.jpg : 文件名
# 存储client的日志文件
base_path = /data/fastdfs/client
# tracker服务器的地址,多个写多行
tracker_server = 192.168.100.125:22122
[root@localhost temp]# pwd
/opt/software/fastdfs/temp
[root@localhost temp]# ll
total 52
-rw-r--r--. 1 root root 49994 Jul 18 17:56 hlb_head_pic.jpg
[root@localhost temp]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /opt/software/fastdfs/temp/hlb_head_pic.jpg 
group1/M00/00/00/wKh9ZGS2tZmAWHQ2AADDSj7EXjU588.jpg

上面那个文件id 所指向的位置,实际上就是group 组为 group1的storage server ,它配置的base_path里的路径下的data,再往下

我配置的 group 组为 group1的storage server , base_path = /opt/software/fastdfs/data/fastdfs/storage, 最后上传文件后放在了 /opt/software/fastdfs/data/fastdfs/storage/data/00/00

[root@localhost 00]# pwd
/opt/software/fastdfs/data/fastdfs/storage/data/00/00
[root@localhost 00]# 
[root@localhost 00]# 
[root@localhost 00]# ls
wKh9ZGS2tZmAWHQ2AADDSj7EXjU588.jpg

(7)nginx 安装

  • 下载:wget http://nginx.org/download/nginx-1.22.1.tar.gz
  • 解压: tar -zxvf nginx-1.22.1.tar.gz -C /opt/software
  • 编译:
    • ./configure
    • make
    • make install
  • 测试 安装是否存在问题
    • /usr/local/nginx/sbin/nginx -v
  • 启动:/usr/local/nginx/sbin/nginx
  • 停止:/usr/local/nginx/sbin/nginx -s stop
  • 刷新配置:/usr/local/nginx/sbin/nginx -s reload
[root@localhost installpackage]# pwd
/opt/installpackage
[root@localhost installpackage]# wget http://nginx.org/download/nginx-1.22.1.tar.gz
--2023-03-31 06:20:27--  http://nginx.org/download/nginx-1.22.1.tar.gz
Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|52.58.199.22|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073948 (1.0M) [application/octet-stream]
Saving to: ‘nginx-1.22.1.tar.gz’

100%[=================================================================================================================================================================

2023-03-31 06:22:57 (6.99 KB/s) - ‘nginx-1.22.1.tar.gz’ saved [1073948/1073948]

[root@localhost installpackage]# tar -zxvf nginx-1.22.1.tar.gz -C /opt/software
[root@localhost installpackage]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.22.1
[root@localhost installpackage]# /usr/local/nginx/sbin/nginx -t
ngx_http_fastdfs_set pid=15289
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost installpackage]# cd /opt/software/nginx-1.22.1	
[root@localhost nginx-1.22.1]# pwd
/opt/software/nginx-1.22.1
[root@localhost nginx-1.22.1]# ./configure
....
[root@localhost nginx-1.22.1]# make
....
[root@localhost nginx-1.22.1]# make install
....

(8)fastdfs-nginx-module 安装

我这里是用的git的方式下载然后进行编译安装,你们也可以去它的git官网找到对应的 tag下载对应的压缩包上传后进行编译安装

  • 注意不同于libfastcomon libserverframefastdfs-nginx-module不需要进行编译
  • 下载后需要用nginx加载该模块
[root@localhost installpackage]# git clone https://gitee.com/fastdfs100/fastdfs-nginx-module.git
Cloning into 'fastdfs-nginx-module'...
remote: Enumerating objects: 129, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 129 (delta 2), reused 0 (delta 0), pack-reused 115
Receiving objects: 100% (129/129), 47.39 KiB | 0 bytes/s, done.
Resolving deltas: 100% (65/65), done.
[root@localhost installpackage]# 
[root@localhost installpackage]# 
[root@localhost installpackage]# cd fastdfs-nginx-module; git checkout V1.23
Note: checking out 'V1.23'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 17e919f... upgrade by FastDFS v6.09

(9)nginx 集成 fastdfs-nginx-module

  • 先进入nginx的源码包,然后执行 ./configure --add-module=/opt/installpackage/fastdfs-nginx-module/src 添加 fastd-nginx module。注意 --add-module=XXX后面的路径就是你下载的 fastdfs-nginx-module,并且要到src目录下
  • 编译:make; make install
  • 查看nginx集成的模块:/usr/local/nginx/sbin/nginx -V
  • 复制 fastdfs-nginx-module 里的 mod_fastdfs.conf文件 到 /etc/fdfs/
  • 复制 fastdfs的conf 下的 mime.typeshttp.conf/etc/fdfs 下, 注意这里是 fastdfsconf 是前面的 FastDFS安装的那个
  • 编辑/etc/fdfs/mod_fastdfs.conf
  • 配置nginx conf 的 server 段
[root@localhost nginx-1.22.1]# ./configure --add-module=/opt/installpackage/fastdfs-nginx-module/src
[root@localhost nginx-1.22.1]# make; make install
[root@localhost nginx-1.22.1]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.22.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
configure arguments: --add-module=/opt/installpackage/fastdfs-nginx-module/src
[root@localhost nginx-1.22.1]# cp /opt/installpackage/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost nginx-1.22.1]# cp /opt/installpackage/fastdfs/conf/mime.types /etc/fdfs/
[root@localhost nginx-1.22.1]# cp /opt/installpackage/fastdfs/conf/http.conf /etc/fdfs/

编辑 /etc/fdfs/mod_fastdfs.conf

  • vim /etc/fdfs/mod_fastdfs.conf
# tracker server 的地址,多个写多行
tracker_server=192.168.125.100:22122
# storage server的端口
storage_server_port=23000
# storage server的组名
group_name=group1
# url上是否有组名 默认是false,本案例这里需要打开true
url_have_group_name = true
# 和 storage.conf配置文件中配置的一样
store_path_count=1
# 和 storage.conf配置文件中配置的一样
store_path0=/data/fastdfs/storage

配置nginx conf 的 server 段,此处的8888/etc/fdfs/storage.conf中的http.server_port=8888 值要一致。

  • vim /usr/local/nginx/conf/nginx.conf
server {
        listen       8888;
        server_name  192.168.125.100;
        location ~/group([0-9])/ {
                ngx_fastdfs_module;
        }
 }

重启 nginx

  • 测试:/usr/local/nginx/sbin/nginx -t
  • 启动:/usr/local/nginx/sbin/nginx
  • 刷新配置(根据需要操作):/usr/local/nginx/sbin/nginx -s reload
  • 关闭(根据需要操作):/usr/local/nginx/sbin/nginx -s stop
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -t
ngx_http_fastdfs_set pid=19661
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx]# /usr/local/nginx/sbin/nginx

(10)最终结果演示

访问前面上传图片测试的路径,ip:端口/fastdfs生成的图片路径,即可访问到了

在这里插入图片描述

参考资料

  • centos7上单机安装fastdfs6.0.9
  • fastDFS gitee 官网
  • fastdfs 6.0.9 install手册
  • fastdfs-nginx-modeule V1.23 install 手册

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/772487.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何快速入门C#编程?

学习C#需要持续努力和实践,但是在一周内入门是有可能的,前提是你愿意付出足够的时间和精力。以下是一周内入门C#的步骤和建议: 设定学习目标: 在一周内学习C#需要专注于基础知识。明确你的学习目标,例如了解语法、变量…

使用STM32 在实现温湿度LCD显示并蓝牙透传

项目需求 通过温湿度传感器将值传到LCD1602,并实时通过蓝牙透传到手机。 硬件介绍 LCD1602 是一种工业字符型液晶,能够同时显示16x02即32字符 (16列两行) DHT11 DHT11数字温湿度传感器是一款含有已校准数字信号输出的温湿度复…

云计算名词-IaaS,PaaS,SaaS

在学习分布式的过程中,知道了PaaS这个词儿,但是不知道是什么意思。从网上查询了之后,做了简单的了解。这里简单记录一下,方面之后的查阅。 IAAS(Infrastructure-as-a-Service)基础设施即服务 网上的定义是…

hdfs的读写流程

hdfs的写入流程 1.client发起文件上传请求,通过rpc与namenode建立通讯,namenode检查目标文件是否已经存在,父目录是否存在,返回是否可以上传 2.client请求第一个block该传输到哪些datanode服务器上 3.namenode根据配置文件中指定…

支付宝支付上线准备工作(商家自研接入)

商家自研流程 1.创建应用 登录支付宝开放平台创建 网页/移动应用 说明:生成的应用唯一标识 APPID 可用于调用开放产品接口。 2.配置应用 2.1 应用详情 2.2 产品绑定 2.3 开发设置 在开发 > 开发设置 中配置应用信息。 2.3.1 接口加密方式 按操作步骤进行…

Mysql——》InnoDB行格式

推荐链接: 总结——》【Java】 总结——》【Mysql】 总结——》【Redis】 总结——》【Kafka】 总结——》【Spring】 总结——》【SpringBoot】 总结——》【MyBatis、MyBatis-Plus】 总结——》【Linux】 总结——》【MongoD…

微服务保护---挑战(雪崩问题/流量控制/隔离和降级)

目录 1.雪崩问题 1.1.解决雪崩问题的常见方式有四种 2.什么是Sentinel 2.1.安装Sentinel控制台 2.2.微服务整合Sentinel 3.流量控制 3.1.簇点链路 3.2.快速入门 3.2.1.示例 3.2.2.利用jmeter测试 3.3.流控模式 3.3.1.关联模式 3.3.2.链路模式 3.3.3.总结 3.4.流控…

数字原生时代,奥哲如何让企业都成为“原住民”?

22年前,美国教育学家马克‧普伦斯基(Marc Prensky)出版了《数字原生与数字移民》(Digital Natives, Digital Immigrants)一书,首次提出了“数字原住民”和“数字移民”两大概念,用来定义跨时代的…

ylb-项目简介

1、各模块服务功能 注&#xff1a;其部分实体类、接口、mapper文件由MyBatis逆向工程生成。 2、Maven管理&#xff08;多模块&#xff0c;继承和聚合&#xff09; 2.1 parent模块 <?xml version"1.0" encoding"UTF-8"?> <project xmlns"…

Unity根据目标点的位置计算Input输入

当给一个目标点&#xff0c;如果目标直接去目标点我们可以直接让position指向目标点的position。 如果是转换输入呢&#xff1f; 举例&#xff1a;例如一个人物动画里有两个参数X和Y&#xff0c;X&#xff08;- 1 &#xff0c;1) 表示向左走和向右走&#xff0c;Y (-1 , 1) 向…

vue条件渲染复习

 在某些情况下&#xff0c;我们需要根据当前的条件决定某些元素或组件是否渲染&#xff0c;这个时候我们就需要进行条件判断了。  Vue 提供了下面的指令来进行条件判断&#xff1a;  v-if  v-else  v-else-if  v-show 1.示例 <html lang"en"> &l…

onnx如何改变输入的维度

最近遇到一个难题&#xff0c;就算在用行为识别onnx转rknn的时候提示维度不对&#xff0c;因为行为识别模型是5维的。而rknn只支持4维。

650亿参数,训练飙升38%!LLaMA基础大模型复刻最佳实践开源,GitHub已获30k星

开源LLaMA神话再次复现&#xff01;首个开源650亿参数大模型高性能预训练方案&#xff0c;训练加速38%&#xff0c;低成本打造量身大模型。 「百模大战」正风起云涌&#xff0c;AIGC相关企业融资和并购金额也屡创新高&#xff0c;全球科技企业争相入局。 然而&#xff0c;AI大…

关于allure和pycharm的运行模式

案例 新建一个项目allure_mode 新建一个python代码test_allure_001.py 代码如下 import pytest, os def test_001(): assert 1 1 if __name__ __main__: pytest.main([-sv, __file__, --alluredir, ./html, --clean-alluredir]) os.system(fallure se…

试玩python的web框架 flask、fastapi、tornado、django

文章目录 一、Flask入门案例 [官网](https://flask.net.cn/quickstart.html) [其它参考](https://zhuanlan.zhihu.com/p/104273184?utm_id0)二、FastAPI入门案例 [官网](https://fastapi.tiangolo.com/zh/) [w3cschool教程](https://www.w3cschool.cn/fastapi/fastapi-feature…

数据容器入门(dict 字典)

字典的定义&#xff1a; 字典的定义&#xff0c;同样使用{}&#xff0c;不过存储的元素是一个个的&#xff1a;键值对&#xff0c;如下语法&#xff1a; # 定义字典字面量 {key&#xff1a;value, key&#xff1a;value, ........., key&#xff1a;value}# 定义字典变量 my_di…

JVM面试题总结

一.请简述对象的创建过程 对象的new字节码执行指令如下图 首先0指令new出一片内存空间&#xff0c;然后进行对象的初始化&#xff0c;初始化完成前变量都是初始值如m0 然后创建连接&#xff0c;t指向对象。 二.DCL单例要不要加volatile&#xff1f; DCL单例就是要懒汉式从创建…

广州市番禺区委领导一行莅临和鲸科技考察交流

7月18日下午&#xff0c;广州市番禺区区委常委、组织部部长、人才工作局局长唐力明&#xff0c;组织部副部长、两新工委书记罗翌洁及组织部其他相关领导一行莅临和鲸科技开展实地考察与调研&#xff0c;国投科创广州基地负责人、海创人才南方创业服务中心常务副秘书长徐斌&…

中小企业部署MES管理系统需要考虑哪些问题

随着制造业的快速发展&#xff0c;越来越多的中小企业开始意识到数字化管理的重要性。为了提高生产效率、降低成本、提升品质及满足客户需求&#xff0c;部署MES生产管理系统成为了中小企业实现数字化转型的关键一步。然而&#xff0c;在部署MES管理系统时&#xff0c;中小企业…

公开讲座笔记 | 雷达学报 雷达系统微课 - 第三讲 相控阵雷达 与 “1+1=2“

原文链接&#xff1a;https://mp.weixin.qq.com/s?__bizMzg4MjgxMjgyMg&mid2247486366&idx2&sn242bd062b6bcd1d32acba16a148f58c9&chksmcf51b967f8263071d912a178881c7ff3c4143b78201c30723a8c121cc53f47ade584a918648c#rd 第三讲 相控阵雷达 与 “112” 主讲…