CentOS 7 安装、测试和部署FastDFS

news2025/4/27 5:06:10

目录

FastDFS环境搭建

安装 libfastcommon 库

安装FastDFS

查看编译后的文件

FastDFS配置

 FastDFS启动

启动tracker服务

启动storage服务

查看storage是否已经注册到了tracker下

查看存储文件的目录

FastDFS重启

FastDFS关闭

使用fdfs_test进行测试

修改client.conf配置文件,修改两个配置

创建base_path指定的目录

fdfs命令格式

FastDFS的HTTP访问

安装Nginx并且添加FastDFS模块

nginx安装

将编译好的Nginx替换原有的Nginx

修改Nginx配置文件

重启Nginx

设置开机自启

FastDFS环境搭建

[root@centos_7_fastdfs01 ~]# yum install -y make cmake gcc gcc-c++ wget perl lrzsz

安装 libfastcommon 库

  • 链接: https://pan.baidu.com/s/1PS4fmN4D6Krwqc9a2tk5Yw 提取码: b66k

  • 将下载好的文件上传到Linux系统下

[root@centos_7_fastdfs01 ~]# tar -zxvf libfastcommon-1.0.75.tar.gz

  • 切换到解压后的libfastcommon目录,执行make脚本进行编译

[root@centos_7_fastdfs01 ~]# cd libfastcommon-1.0.75

[root@centos_7_fastdfs01 libfastcommon-1.0.75]# ./make.sh

  • 执行make install进行安装

[root@centos_7_fastdfs01 libfastcommon-1.0.39]# ./make.sh install

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 sockopt.h sched_thread.h http_func.h md5.h local_ip_func.h avl_tree.h ioevent.h ioevent_loop.h fast_task_queue.h fast_timer.h process_ctrl.h fast_mblock.h connection_pool.h fast_mpool.h fast_allocator.h fast_buffer.h skiplist.h multi_skiplist.h flat_skiplist.h skiplist_common.h system_info.h fast_blocked_queue.h php7_ext_wrapper.h id_generator.h char_converter.h char_convert_loader.h common_blocked_queue.h multi_socket_client.h skiplist_set.h fc_list.h /usr/include/fastcommon

if [ ! -e /usr/lib/libfastcommon.so ]; then ln -s /usr/lib64/libfastcommon.so /usr/lib/libfastcommon.so; fi

[root@centos_7_fastdfs01 libfastcommon-1.0.39]# echo $?

0

[root@centos_7_fastdfs01 libfastcommon-1.0.39]#

安装FastDFS

  • 链接:https://pan.baidu.com/s/1AUlnfJAhSrji_vn8M_jOPQ 提取码: auae
  • 链接:https://pan.baidu.com/s/1auPbOU7Nwy_kUqy0mkGFSg?pwd=pq1v 提取码:pq1v

  • 将下载好的文件上传到Linux系统上

[root@centos_7_fastdfs01 ~]# ll fastdfs-6.12.2.tar.gz

-rw-r--r--. 1 root root 5312227 12月 21 09:07 fastdfs-6.12.2.tar.gz [root@centos_7_fastdfs01 ~]# tar xf fastdfs-6.12.2.tar.gz

[root@localhost ~]# tar xf libserverframe-1.2.5.tar.gz

[root@localhost ~]# cd libserverframe-1.2.5

[root@localhost libserverframe-1.2.5]#  ./make.sh

[root@localhost libserverframe-1.2.5]# ./make.sh install

  • 切换到解压后FastDFS的目录,执行make脚本进行编译

[root@centos_7_fastdfs01 fastdfs-6.12.2]# ./make.sh

  • 执行make install进行安装

[root@centos_7_fastdfs01 fastdfs-6.12.2]# ./make.sh install

查看编译后的文件

  • 查看FastDFS相关的可执行程序

[root@centos_7_fastdfs01 fastdfs-6.12.2]# ll /usr/bin/fdfs*

-rwxr-xr-x 1 root root  317424 12月 20 18:01 /usr/bin/fdfs_appender_test

-rwxr-xr-x 1 root root  317200 12月 20 18:01 /usr/bin/fdfs_appender_test1

-rwxr-xr-x 1 root root  304056 12月 20 18:01 /usr/bin/fdfs_append_file

-rwxr-xr-x 1 root root  303784 12月 20 18:01 /usr/bin/fdfs_crc32

-rwxr-xr-x 1 root root  304112 12月 20 18:01 /usr/bin/fdfs_delete_file

-rwxr-xr-x 1 root root  304840 12月 20 18:01 /usr/bin/fdfs_download_file

-rwxr-xr-x 1 root root  304440 12月 20 18:01 /usr/bin/fdfs_file_info

-rwxr-xr-x 1 root root  322336 12月 20 18:01 /usr/bin/fdfs_monitor

-rwxr-xr-x 1 root root 1111584 12月 20 18:01 /usr/bin/fdfs_storaged

-rwxr-xr-x 1 root root  327328 12月 20 18:01 /usr/bin/fdfs_test

-rwxr-xr-x 1 root root  326536 12月 20 18:01 /usr/bin/fdfs_test1

-rwxr-xr-x 1 root root  453848 12月 20 18:01 /usr/bin/fdfs_trackerd

-rwxr-xr-x 1 root root  305040 12月 20 18:01 /usr/bin/fdfs_upload_appender

-rwxr-xr-x 1 root root  306064 12月 20 18:01 /usr/bin/fdfs_upload_file

[root@centos_7_fastdfs01 fastdfs-6.12.2]#

  • 查看FastDFS的配置文件

[root@centos_7_fastdfs01 fastdfs-6.12.2]# ll /etc/fdfs/

总用量 24

-rw-r--r-- 1 root root 1461 12月 20 18:01 client.conf.sample

-rw-r--r-- 1 root root 7927 12月 20 18:01 storage.conf.sample

-rw-r--r-- 1 root root  105 12月 20 18:01 storage_ids.conf.sample

-rw-r--r-- 1 root root 7389 12月 20 18:01 tracker.conf.sample

[root@centos_7_fastdfs01 fastdfs-5.11]#

  • 解压后将fastdfs-6.12.2/conf目录下的两个文件拷贝到/etc/fdfs/

[root@centos_7_fastdfs01 conf]# pwd

/root/fastdfs-6.12.2/conf

[root@centos_7_fastdfs01 conf]# cp -av http.conf /etc/fdfs/

"http.conf" -> "/etc/fdfs/http.conf"

[root@centos_7_fastdfs01 conf]# cp -av mime.types /etc/fdfs/

"mime.types" -> "/etc/fdfs/mime.types"

[root@centos_7_fastdfs01 conf]#

FastDFS配置

  • 去掉/etc/fdfs/目录下FastDFS配置文件的后缀名 .sample

[root@centos_7_fastdfs01 conf]# cd /etc/fdfs/

[root@centos_7_fastdfs01 fdfs]# ll

\总用量 60

-rw-r--r-- 1 root root  1461 12月 20 18:01 client.conf.sample

-rw-rw-r-- 1 root root   955 6月   3 2017 http.conf

-rw-rw-r-- 1 root root 31172 6月   3 2017 mime.types

-rw-r--r-- 1 root root  7927 12月 20 18:01 storage.conf.sample

-rw-r--r-- 1 root root   105 12月 20 18:01 storage_ids.conf.sample

-rw-r--r-- 1 root root  7389 12月 20 18:01 tracker.conf.sample

[root@centos_7_fastdfs01 fdfs]# mv -v ./tracker.conf.sample ./tracker.conf

"./tracker.conf.sample" -> "./tracker.conf"

[root@centos_7_fastdfs01 fdfs]# mv -v ./storage.conf.sample ./storage.conf

"./storage.conf.sample" -> "./storage.conf"

[root@centos_7_fastdfs01 fdfs]# ll

总用量 60

-rw-r--r-- 1 root root  1461 12月 20 18:01 client.conf.sample

-rw-rw-r-- 1 root root   955 6月   3 2017 http.conf

-rw-rw-r-- 1 root root 31172 6月   3 2017 mime.types

-rw-r--r-- 1 root root  7927 12月 20 18:01 storage.conf

-rw-r--r-- 1 root root   105 12月 20 18:01 storage_ids.conf.sample

-rw-r--r-- 1 root root  7389 12月 20 18:01 tracker.conf

[root@centos_7_fastdfs01 fdfs]#

  • 修改tracker.conf文件

[root@localhost fdfs]# grep 'base_path' /etc/fdfs/tracker.conf

base_path = /opt/fastdfs

[root@localhost fdfs]# sed -i 's@base_path = \/opt\/fastdfs@base_path = \/opt\/fastdfs\/tracker@g' /etc/fdfs/tracker.conf

[root@localhost fdfs]# grep 'base_path' /etc/fdfs/tracker.conf

base_path = /opt/fastdfs/tracker

[root@localhost fdfs]#

  • 修改storage.conf文件

[root@localhost fdfs]# grep 'base_path' /etc/fdfs/storage.conf

base_path = /opt/fastdfs

# if store_path0 not exists, it's value is base_path (NOT recommended)

#       the base_path should be independent (different) of the store paths

[root@localhost fdfs]# sed -i 's@base_path = \/opt\/fastdfs@base_path = \/opt\/fastdfs\/storage@g' /etc/fdfs/storage.conf

[root@localhost fdfs]# grep 'base_path' /etc/fdfs/storage.conf

base_path = /opt/fastdfs/storage

# if store_path0 not exists, it's value is base_path (NOT recommended)

#       the base_path should be independent (different) of the store paths

[root@localhost fdfs]#

[root@centos_7_fastdfs01 fdfs]# mkdir -pv /opt/fastdfs/storage

[root@centos_7_fastdfs01 fdfs]# ll /opt/fastdfs/storage

总用量 0

[root@centos_7_fastdfs01 fdfs]#

[root@centos_7_fastdfs01 fdfs]# grep 'store_path_count' /etc/fdfs/storage.conf

store_path_count=1

[root@centos_7_fastdfs01 fdfs]#

[root@localhost fdfs]# grep 'store_path0' /etc/fdfs/storage.conf

# if store_path0 not exists, it's value is base_path (NOT recommended)

store_path0 = /opt/fastdfs

[root@localhost storage]# sed -i 's@store_path0 = \/opt\/fastdfs\/storage\/files@store_path0 = \/opt\/fastdfs\/storage@' /etc/fdfs/storage.conf

[root@localhost storage]#  grep 'store_path0' /etc/fdfs/storage.conf

# if store_path0 not exists, it's value is base_path (NOT recommended)

store_path0 = /opt/fastdfs/storage

[root@localhost storage]#

[root@localhost fdfs]# grep 'tracker_server' /etc/fdfs/storage.conf

# tracker_server can ocur more than once for multi tracker servers.

# the value format of tracker_server is "HOST:PORT",

tracker_server = 192.168.209.121:22122

tracker_server = 192.168.209.122:22122

[root@localhost fdfs]# sed -i 's@tracker_server = 192.168.209.121:22122@tracker_server=192.168.80.69:22122@' /etc/fdfs/storage.conf

[root@localhost fdfs]# grep 'tracker_server' /etc/fdfs/storage.conf

# tracker_server can ocur more than once for multi tracker servers.

# the value format of tracker_server is "HOST:PORT",

tracker_server=192.168.80.69:22122

tracker_server = 192.168.209.122:22122

[root@localhost fdfs]# sed -i 's@tracker_server = 192.168.209.122:22122@tracker_server=192.168.80.69:22122@' /etc/fdfs/storage.conf

[root@localhost fdfs]# grep 'tracker_server' /etc/fdfs/storage.conf

# tracker_server can ocur more than once for multi tracker servers.

# the value format of tracker_server is "HOST:PORT",

tracker_server=192.168.80.69:22122

tracker_server=192.168.80.69:22122

[root@localhost fdfs]#

[root@centos_7_fastdfs01 fdfs]# mkdir -pv /opt/fastdfs/storage/files

mkdir: 已创建目录 "/opt/fastdfs/storage/files"

[root@centos_7_fastdfs01 fdfs]#

 FastDFS启动

启动tracker服务

[root@centos_7_fastdfs01 fdfs]# fdfs_trackerd /etc/fdfs/tracker.conf

[root@centos_7_fastdfs01 fdfs]#

启动storage服务

[root@centos_7_fastdfs01 fdfs]# fdfs_storaged /etc/fdfs/storage.conf

[root@centos_7_fastdfs01 fdfs]#

查看storage是否已经注册到了tracker下

[root@centos_7_fastdfs01 fdfs]# fdfs_monitor /etc/fdfs/storage.conf

[2024-12-20 18:39:04] DEBUG - base_path=/opt/fastdfs/storage, connect_timeout=30, 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

server_count=1, server_index=0

tracker server is 192.168.80.69:22122

group count: 1

Group 1:

group name = group1

disk total space = 30705 MB

disk free space = 28376 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.80.69

              ip_addr = 192.168.80.69 (centos_7_fastdfs01)  ACTIVE

              http domain =

              version = 5.11

              join time = 2024-12-20 18:38:13

              up time = 2024-12-20 18:38:13

              total storage = 30705 MB

              free storage = 28376 MB

              upload priority = 10

              store_path_count = 1

              subdir_count_per_path = 256

              storage_port = 23000

              storage_http_port = 8888

              current_write_path = 0

              source storage id =

              if_trunk_server = 0

              connection.alloc_count = 256

              connection.current_count = 0

              connection.max_count = 0

              total_upload_count = 0

              success_upload_count = 0

              total_append_count = 0

              success_append_count = 0

              total_modify_count = 0

              success_modify_count = 0

              total_truncate_count = 0

              success_truncate_count = 0

              total_set_meta_count = 0

              success_set_meta_count = 0

              total_delete_count = 0

              success_delete_count = 0

              total_download_count = 0

              success_download_count = 0

              total_get_meta_count = 0

              success_get_meta_count = 0

              total_create_link_count = 0

              success_create_link_count = 0

              total_delete_link_count = 0

              success_delete_link_count = 0

              total_upload_bytes = 0

              success_upload_bytes = 0

              total_append_bytes = 0

              success_append_bytes = 0

              total_modify_bytes = 0

              success_modify_bytes = 0

              stotal_download_bytes = 0

              success_download_bytes = 0

              total_sync_in_bytes = 0

              success_sync_in_bytes = 0

              total_sync_out_bytes = 0

              success_sync_out_bytes = 0

              total_file_open_count = 0

              success_file_open_count = 0

              total_file_read_count = 0

              success_file_read_count = 0

              total_file_write_count = 0

              success_file_write_count = 0

              last_heart_beat_time = 2024-12-20 18:38:44

              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@centos_7_fastdfs01 fdfs]#

查看存储文件的目录

[root@centos_7_fastdfs01 fdfs]# cd /opt/fastdfs/storage/

[root@centos_7_fastdfs01 storage]# ls

data  files  logs

[root@centos_7_fastdfs01 storage]# cd data/

[root@centos_7_fastdfs01 data]# ls

fdfs_storaged.pid  storage_stat.dat  sync

[root@centos_7_fastdfs01 data]# cd ../logs/

[root@centos_7_fastdfs01 logs]# ls

storaged.log

[root@centos_7_fastdfs01 logs]# cd ../files/

[root@centos_7_fastdfs01 files]# ls

data

[root@centos_7_fastdfs01 files]# cd data/

[root@centos_7_fastdfs01 data]# ls

00  0C  18  24  30  3C  48  54  60  6C  78  84  90  9C  A8  B4  C0  CC  D8  E4  F0  FC

01  0D  19  25  31  3D  49  55  61  6D  79  85  91  9D  A9  B5  C1  CD  D9  E5  F1  FD

02  0E  1A  26  32  3E  4A  56  62  6E  7A  86  92  9E  AA  B6  C2  CE  DA  E6  F2  FE

03  0F  1B  27  33  3F  4B  57  63  6F  7B  87  93  9F  AB  B7  C3  CF  DB  E7  F3  FF

04  10  1C  28  34  40  4C  58  64  70  7C  88  94  A0  AC  B8  C4  D0  DC  E8  F4

05  11  1D  29  35  41  4D  59  65  71  7D  89  95  A1  AD  B9  C5  D1  DD  E9  F5

06  12  1E  2A  36  42  4E  5A  66  72  7E  8A  96  A2  AE  BA  C6  D2  DE  EA  F6

07  13  1F  2B  37  43  4F  5B  67  73  7F  8B  97  A3  AF  BB  C7  D3  DF  EB  F7

08  14  20  2C  38  44  50  5C  68  74  80  8C  98  A4  B0  BC  C8  D4  E0  EC  F8

09  15  21  2D  39  45  51  5D  69  75  81  8D  99  A5  B1  BD  C9  D5  E1  ED  F9

0A  16  22  2E  3A  46  52  5E  6A  76  82  8E  9A  A6  B2  BE  CA  D6  E2  EE  FA

0B  17  23  2F  3B  47  53  5F  6B  77  83  8F  9B  A7  B3  BF  CB  D7  E3  EF  FB

[root@centos_7_fastdfs01 data]#

FastDFS重启

  • 重启tracker

[root@centos_7_fastdfs01 data]# fdfs_trackerd /etc/fdfs/tracker.conf restart

waiting for pid [12493] exit ...

starting ...

[root@centos_7_fastdfs01 data]#

  • 重启storage

[root@centos_7_fastdfs01 data]# fdfs_storaged /etc/fdfs/storage.conf restart

waiting for pid [12502] exit ...

starting ...

[root@centos_7_fastdfs01 data]#

FastDFS关闭

  • 关闭tracker执行命令

[root@centos_7_fastdfs01 data]# fdfs_trackerd /etc/fdfs/tracker.conf stop

waiting for pid [12525] exit ...

pid [12525] exit.

[root@centos_7_fastdfs01 data]#

  • 关闭storage执行命令

[root@centos_7_fastdfs01 data]# fdfs_storaged /etc/fdfs/storage.conf stop

waiting for pid [12536] exit ...

pid [12536] exit.

[root@centos_7_fastdfs01 data]#

使用fdfs_test进行测试

修改client.conf配置文件,修改两个配置

[root@localhost data]# find / -name client.conf

/etc/fdfs/client.conf

/root/fastdfs-6.12.2/conf/client.conf

/root/fastdfs-6.12.2/docker/dockerfile_local-v6.0.9/build_image-v6.0.8/conf/client.conf

/root/fastdfs-6.12.2/docker/dockerfile_local-v6.0.9/build_image-v6.0.9/conf/client.conf

/root/fastdfs-6.12.2/docker/dockerfile_local-v6.0.9/fastdfs-conf/conf/client.conf

/root/fastdfs-6.12.2/docker/dockerfile_local/conf/client.conf

/root/fastdfs-6.12.2/docker/dockerfile_network/conf/client.conf

[root@localhost data]# grep 'base_path' /root/fastdfs-6.12.2/conf/client.conf

base_path = /opt/fastdfs

[root@localhost data]# sed -i 's@base_path = \/opt\/fastdfs@base_path = \/opt\/fastdfs\/client@' /root/fastdfs-6.12.2/conf/client.conf

[root@localhost data]# grep 'base_path' /root/fastdfs-6.12.2/conf/client.conf

base_path = /opt/fastdfs/client

[root@localhost data]# [root@centos_7_fastdfs01 data]#

[root@localhost data]# grep 'tracker_server' /root/fastdfs-6.12.2/conf/client.conf

# tracker_server can ocur more than once for multi tracker servers.

# the value format of tracker_server is "HOST:PORT",

tracker_server = 192.168.0.196:22122

tracker_server = 192.168.0.197:22122

http.tracker_server_port = 80

[root@localhost data]# sed -i 's@tracker_server = 192.168.0.196:22122@tracker_server = 192.168.80.69:22122@' /root/fastdfs-6.12.2/conf/client.conf

[root@localhost data]# sed -i 's@tracker_server = 192.168.0.197:22122@tracker_server = 192.168.80.69:22122@' /root/fastdfs-6.12.2/conf/client.conf

[root@localhost data]# grep 'tracker_server' /root/fastdfs-6.12.2/conf/client.conf

# tracker_server can ocur more than once for multi tracker servers.

# the value format of tracker_server is "HOST:PORT",

tracker_server = 192.168.80.69:22122

tracker_server = 192.168.80.69:22122

http.tracker_server_port = 80

[root@localhost data]#

创建base_path指定的目录

[root@centos_7_fastdfs01 data]# mkdir -pv /opt/fastdfs/client

mkdir: 已创建目录 "/opt/fastdfs/client"

[root@centos_7_fastdfs01 data]#

fdfs命令格式

  • 上传文件:fdfs_test <config_file> <operation> <local_filename>

  • config_file:配置文件的位置
  • operation:upload,download,getmeta,setmeta,delete and query_servers,上传使用的是upload
  • local_filename:要上传的文件名字

[root@localhost data]# touch /opt/1.txt

[root@localhost data]# /usr/bin/fdfs_test /root/fastdfs-6.12.2/conf/client.conf upload /opt/1.txt

This is FastDFS client test program v6.12.2

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.

tracker_query_storage_store_list_without_group:

       server 1. group_name=, ip_addr=192.168.80.69, port=23000

group_name=group1, ip_addr=192.168.80.69, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKhQRWdmHnKAfVHQAAAAAAAAAAA048.txt

source ip address: 192.168.80.69

file timestamp=2024-12-21 09:48:34

file size=0

file crc32=0

example file url: http://192.168.80.69/group1/M00/00/00/wKhQRWdmHnKAfVHQAAAAAAAAAAA048.txt

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKhQRWdmHnKAfVHQAAAAAAAAAAA048_big.txt

source ip address: 192.168.80.69

file timestamp=2024-12-21 09:48:34

file size=0

file crc32=0

example file url: http://192.168.80.69/group1/M00/00/00/wKhQRWdmHnKAfVHQAAAAAAAAAAA048_big.txt

[root@localhost data]#

  • 下载文件命令:fdfs_test <config_file> download <group_name> <remote_filename>

  • group_name: 要下载的文件所在的组名
  • remote_filename:要下载的文件名(要指定在fastDFS中存储的名字)

  • 删除文件命令:fdfs_test <config_file> delete <group_name> <remote_filename>

FastDFS的HTTP访问

安装Nginx并且添加FastDFS模块

  • 检查并安装 Nginx 依赖的库

[root@centos_7_fastdfs01 opt]# yum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel –y

  • 压缩包下载链接:https://pan.baidu.com/s/1oyAGij2RxO5fE89Rn2hDXA 提取码: 9vhm
  • 将Fastdfs的Nginx扩展模块源代码上传到Linux上,并解压

[root@centos_7_fastdfs01 ~]# ll fastdfs-nginx-module-1.24.tar.gz

-rw-r--r-- 1 root root 23002 12月 20 19:15 fastdfs-nginx-module-1.24.tar.gz

[root@centos_7_fastdfs01 ~]# tar xf fastdfs-nginx-module-1.24.tar.gz

[root@centos_7_fastdfs01 ~]# ll fastdfs-nginx-module-1.24

总用量 16

-rw-rw-r-- 1 root root 3208 12月  5 2023 HISTORY

-rw-rw-r-- 1 root root 2584 12月  5 2023 INSTALL

-rw-rw-r-- 1 root root 7816 12月  5 2023 LICENSE

drwxrwxr-x 2 root root  109 12月  5 2023 src

[root@centos_7_fastdfs01 ~]#

  • 压缩包下载链接:https://pan.baidu.com/s/1IvqllSyAUkI1OQRp0FIMjg 提取码: gjmb
  • 将Nginx的tar包上传到Linux上,并解压

[root@centos_7_fastdfs01 ~]# ll nginx-1.26.2.tar.gz

-rw-r--r-- 1 root root 1244789 12月 20 19:19 nginx-1.26.2.tar.gz

[root@centos_7_fastdfs01 ~]# tar xf nginx-1.26.2.tar.gz

[root@centos_7_fastdfs01 ~]# ll nginx-1.26.2

总用量 828

drwxr-xr-x 6 502 games    326 12月 20 19:19 auto

-rw-r--r-- 1 502 games 327851 8月  13 00:39 CHANGES

-rw-r--r-- 1 502 games 501527 8月  13 00:39 CHANGES.ru

drwxr-xr-x 2 502 games    168 12月 20 19:19 conf

-rwxr-xr-x 1 502 games   2611 8月  12 22:28 configure

drwxr-xr-x 4 502 games     72 12月 20 19:19 contrib

drwxr-xr-x 2 502 games     40 12月 20 19:19 html

-rw-r--r-- 1 502 games   1397 8月  12 22:28 LICENSE

drwxr-xr-x 2 502 games     21 12月 20 19:19 man

-rw-r--r-- 1 502 games     49 8月  12 22:28 README

drwxr-xr-x 9 502 games     91 8月  13 00:39 src

[root@centos_7_fastdfs01 ~]#

  • 切换至解压后的Nginx主目录,执行配置操作

[root@centos_7_fastdfs01 src]# pwd

/root/fastdfs-nginx-module-1.24/src

[root@centos_7_fastdfs01 src]# ll

总用量 84

-rw-rw-r-- 1 root root 43458 12月  5 2023 common.c

-rw-rw-r-- 1 root root  3995 12月  5 2023 common.h

-rw-rw-r-- 1 root root  1078 12月  5 2023 config

-rw-rw-r-- 1 root root  3725 12月  5 2023 mod_fastdfs.conf

-rw-rw-r-- 1 root root 28668 12月  5 2023 ngx_http_fastdfs_module.c

[root@localhost src]# grep 'CORE_INCS' config

    CORE_INCS="$CORE_INCS /usr/local/include"

[root@localhost src]# sed -i 's@CORE_INCS="$CORE_INCS /usr/local/include"@CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"@' config

[root@localhost src]# grep 'CORE_INCS' config

    CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"

[root@localhost src]#

[root@centos_7_fastdfs01 src]# grep 'CORE_LIBS=' config

    CORE_LIBS="$CORE_LIBS -lfastcommon -lserverframe -lfdfsclient"

[root@centos_7_fastdfs01 src]# sed -i 's@CORE_LIBS="$CORE_LIBS -lfastcommon -lserverframe -lfdfsclient"@CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"@' config

[root@centos_7_fastdfs01 src]# grep 'CORE_LIBS=' config

    CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"

[root@centos_7_fastdfs01 src]#

  • 复制fastdfs-nginx-module/src/mod_fastdfs.conf 到/etc/fdfs目录下

[root@centos_7_fastdfs01 src]# cd /root/fastdfs-nginx-module-1.24/src/

[root@centos_7_fastdfs01 src]# cp -av mod_fastdfs.conf /etc/fdfs

"mod_fastdfs.conf" -> "/etc/fdfs/mod_fastdfs.conf"

[root@centos_7_fastdfs01 src]#

  • 在/etc/fdfs目录下修改mod_dastdfs.conf文件

[root@centos_7_fastdfs01 src]# grep 'tracker_server=' /etc/fdfs/mod_fastdfs.conf

tracker_server=tracker:22122

[root@centos_7_fastdfs01 src]# grep 'storage_server_port=' /etc/fdfs/mod_fastdfs.conf

storage_server_port=23000

#storage_server_port=23000

#storage_server_port=23000

[root@centos_7_fastdfs01 src]# grep 'group_name=' /etc/fdfs/mod_fastdfs.conf

group_name=group1

#group_name=group1

#group_name=group2

[root@centos_7_fastdfs01 src]# grep 'url_have_group_name =' /etc/fdfs/mod_fastdfs.conf

url_have_group_name = false

[root@centos_7_fastdfs01 src]# sed -i 's@url_have_group_name = false@url_have_group_name = true@' /etc/fdfs/mod_fastdfs.conf

[root@centos_7_fastdfs01 src]# grep 'url_have_group_name =' /etc/fdfs/mod_fastdfs.conf

url_have_group_name = true

[root@centos_7_fastdfs01 src]#

[root@centos_7_fastdfs01 src]# grep 'store_path0=' /etc/fdfs/mod_fastdfs.conf

store_path0=/home/yuqing/fastdfs

#store_path0=/home/yuqing/fastdfs

#store_path0=/home/yuqing/fastdfs

[root@centos_7_fastdfs01 src]# sed -i 's@store_path0=\/home\/yuqing\/fastdfs@store_path0=\/opt\/fastdfs\/storage@' /etc/fdfs/mod_fastdfs.conf

[root@centos_7_fastdfs01 src]# grep 'store_path0=' /etc/fdfs/mod_fastdfs.conf

store_path0=/opt/fastdfs/storage

#store_path0=/opt/fastdfs/storage

#store_path0=/opt/fastdfs/storage

[root@centos_7_fastdfs01 src]#

  • store_path0=你上面设置的默认数据存储目录(我这里是/opt/fastdfs/storage)

[root@centos_7_fastdfs01 src]# grep -nE -B2 '^tracker_server|^storage_server_port|^group_name|^url_have_group_name|^store_path0' /etc/fdfs/mod_fastdfs.conf

38-#  "host:port", host can be hostname or ip address

39-# valid only when load_fdfs_parameters_from_tracker is true

40:tracker_server=tracker:22122

--

42-# the port of the local storage server

43-# the default value is 23000

44:storage_server_port=23000

45-

46-# the group name of the local storage server

47:group_name=group1

--

51-# set to true when uri like ${group_name}/M00/00/00/xxx, such as group1/M00/xxx

52-# default value is false

53:url_have_group_name = true

--

60-# the paths must be exist

61-# must same as storage.conf

62:store_path0=/opt/fastdfs/storage

[root@centos_7_fastdfs01 src]#

nginx安装

[root@centos_7_fastdfs01 nginx-1.26.2]# ./configure --add-module=/root/fastdfs-nginx-module-1.24/src/ ; echo $?

[root@localhost nginx-1.26.2]# make ; echo $?

[root@localhost nginx-1.26.2]# make install ; echo $?

将编译好的Nginx替换原有的Nginx

[root@localhost nginx-1.26.2]# cp -av ./objs/nginx /usr/local/nginx/sbin/

cp:是否覆盖"/usr/local/nginx/sbin/nginx"? y

"./objs/nginx" -> "/usr/local/nginx/sbin/nginx"

[root@localhost nginx-1.26.2]#

修改Nginx配置文件

[root@localhost nginx-1.26.2]# vim /usr/local/nginx/conf/nginx.conf

[root@localhost nginx-1.26.2]#

  • 编辑内容如下:

location /group1/M00/{

            ngx_fastdfs_module;

        }

  • 检测配置语法:

[root@localhost nginx-1.26.2]# /usr/local/nginx/sbin/nginx -t

ngx_http_fastdfs_set pid=48551

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-1.26.2]#

[root@localhost nginx-1.26.2]# /usr/local/nginx/sbin/nginx

ngx_http_fastdfs_set pid=48588

[root@localhost nginx-1.26.2]#

[root@localhost nginx-1.26.2]# ps aux | grep nginx

root      48589  0.0  0.0  30500   672 ?        Ss   10:07   0:00 nginx: master process /usr/local/nginx/sbin/nginx

root      48615  0.0  0.0 112824   988 pts/0    S+   10:07   0:00 grep --color=auto nginx

[root@localhost nginx-1.26.2]#

[root@localhost nginx-1.26.2]# grep -Ev '^$|#' /usr/local/nginx/conf/nginx.conf

worker_processes  1;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  localhost;

       

        location /group1/M00/{

            ngx_fastdfs_module;

        }

        location / {

            root   html;

            index  index.html index.htm;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

}

[root@localhost nginx-1.26.2]#

重启Nginx

  • 重启Nginx

[root@localhost storage]# /usr/local/nginx/sbin/nginx -s reload

ngx_http_fastdfs_set pid=1892

  • 访问这个随机生成的URL地址

  • 查看上传文件

[root@localhost ~]# find / ! -path "/usr/share/*" ! -path "/home/*" -type f -name '*.jpg'

/root/fastdfs-6.12.2/conf/anti-steal.jpg

/root/fastdfs-6.12.2/docker/dockerfile_local-v6.0.9/build_image-v6.0.9/conf/anti-steal.jpg

/root/fastdfs-6.12.2/docker/dockerfile_local-v6.0.9/fastdfs-conf/conf/anti-steal.jpg

/opt/fastdfs/storage/files/data/00/00/wKhQRWdmJpiAfePhAALWLpLaytE611.jpg

/opt/fastdfs/storage/files/data/00/00/wKhQRWdmJpiAfePhAALWLpLaytE611_big.jpg

/opt/fastdfs/storage/files/data/00/00/wKhQRWdmKlyAaTPUAALWLpLaytE578.jpg

/opt/fastdfs/storage/files/data/00/00/wKhQRWdmKlyAaTPUAALWLpLaytE578_big.jpg

/opt/fastdfs/storage/data/00/00/wKhQRWdmLPCAEuWyAALWLpLaytE221.jpg

/opt/fastdfs/storage/data/00/00/wKhQRWdmLPCAEuWyAALWLpLaytE221_big.jpg

/opt/1.jpg

[root@localhost ~]#

设置开机自启

[root@localhost storage]# cat >>/etc/rc.d/rc.local<<EOF

>

> ### hanyw $(date +%F_%T)

> /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

> /usr/bin/fdfs_storaged /etc/fdfs/storage.conf

> /usr/local/nginx/sbin/nginx

> ### hanyw $(date +%F_%T)

> EOF

[root@localhost storage]# cat /etc/rc.d/rc.local

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

touch /var/lock/subsys/local

### hanyw 2024-12-21_11:06:54

/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf

/usr/bin/fdfs_storaged /etc/fdfs/storage.conf

/usr/local/nginx/sbin/nginx

### hanyw 2024-12-21_11:06:54

[root@localhost storage]#

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

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

相关文章

【WRF教程第3.1期】预处理系统 WPS 详解:以4.5版本为例

预处理系统 WPS 详解&#xff1a;以4.5版本为例 每个 WPS 程序的功能程序1&#xff1a;geogrid程序2&#xff1a;ungrib程序3&#xff1a;metgrid WPS运行&#xff08;Running the WPS&#xff09;步骤1&#xff1a;Define model domains with geogrid步骤2&#xff1a;Extract…

Flutter组件————FloatingActionButton

FloatingActionButton 是Flutter中的一个组件&#xff0c;通常用于显示一个圆形的按钮&#xff0c;它悬浮在内容之上&#xff0c;旨在吸引用户的注意力&#xff0c;并代表屏幕上的主要动作。这种按钮是Material Design的一部分&#xff0c;通常放置在页面的右下角&#xff0c;但…

在Windows11上编译C#的实现Mono的步骤

在Windows11上编译Mono的步骤 1、 在win11打开开发者模式,在更新和安全选项里,如下图: 2、下载并安装64位的cygwin, 下载网站:www.cygwin.com 3、 安装 Visual Studio 2015 or later 的社区版本。 4、 下载Mono的windows最新版本。 5、 在cmd.exe里运行下面的命令来安…

[HNCTF 2022 Week1]你想学密码吗?

下载附件用记事本打开 把这些代码放在pytho中 # encode utf-8 # python3 # pycryptodemo 3.12.0import Crypto.PublicKey as pk from hashlib import md5 from functools import reducea sum([len(str(i)) for i in pk.__dict__]) funcs list(pk.__dict__.keys()) b reduc…

【记录50】uniapp安装uview插件,样式引入失败分析及解决

SassError: Undefined variable: "$u-border-color". 表示样式变量$u-border-color没定义&#xff0c;实际是定义的 首先确保安装了scss/sass 其次&#xff0c;根目录下 app.vue中是否全局引入 <style lang"scss">import /uni_modules/uview-ui/in…

如何写申请essay

俗话说&#xff1a;万事开头难。英国留学申请essay也是如此。申请essay怎么写呢&#xff1f;一篇essay的开头是否精彩直接关系到导师能否被你的文字吸引。一把而言&#xff0c;招生官每天阅读的essay在200封以上&#xff0c;每篇阅读在12分钟以内&#xff0c;所以你的essay开头…

14-zookeeper环境搭建

0、环境 java&#xff1a;1.8zookeeper&#xff1a;3.5.6 1、下载 zookeeper下载点击这里。 2、安装 下载完成后解压&#xff0c;放到你想放的目录里。先看一下zookeeper的目录结构&#xff0c;如下图&#xff1a; 进入conf目录&#xff0c;复制zoo_sample.cfg&#xff0…

【UE5】pmx导入UE5,套动作。(防止“气球人”现象。

参考视频&#xff1a;UE5Animation 16: MMD模型與動作導入 (繁中自動字幕) 问题所在&#xff1a; 做法记录&#xff08;自用&#xff09; 1.导入pmx&#xff0c;删除这两个。 2.转换给blender&#xff0c;清理节点。 3.导出时&#xff0c;内嵌贴图&#xff0c;选“复制”。 …

yolo 视频流播放并进行目标识别

根据视频流&#xff0c;实时的进行目标识别 一、下载 [lal](https://github.com/q191201771/lal/releases/tag/v0.37.4)二、安装 [FFmpeg](https://ffmpeg.org/)三、完整代码演示 需要前置了解YOLO的完整操作 使用labelImg标注&#xff0c;YOLO进行目标训练 一、下载 lal 下载…

分类模型的预测概率解读:3D概率分布可视化的直观呈现

背景 在分类模型中&#xff0c;预测概率不仅是结果&#xff0c;更是模型决策的关键依据。为了更直观地理解这些概率分布&#xff0c;3D可视化提供了一种生动的展示方式&#xff0c;本文通过3D概率分布图&#xff0c;直观展示分类模型的预测概率 代码实现 基于时间序列的3D分…

【Spring】获取Bean对象需要哪些注解

阿华代码&#xff0c;不是逆风&#xff0c;就是我疯 你们的点赞收藏是我前进最大的动力&#xff01;&#xff01; 希望本文内容能够帮助到你&#xff01;&#xff01; 目录 一&#xff1a;Service&#xff08;服务存储&#xff09; 1&#xff1a;存储bean的代码 2&#xff1…

【C++】哈希表实现

目录 一、哈希概念 1.1 直接定址法 1.2 哈希冲突 1.3 负载因子 1.4 将关键字转为整数 二、哈希函数 2.1 除法散列法/除留余数法 2.2 乘法散列图&#xff08;了解即可&#xff09; 2.3 全域散列法&#xff08;了解即可&#xff09; ​编辑 三、处理哈希冲突 3.1 开放…

Android-相对布局RelativeLayout

相对布局在摆放子视图位置时&#xff0c;按照指定的参考系来摆放子视图的位置&#xff0c;默认以屏幕左上角(0,0)位置作为参考系摆放位置 了解一下接下来都会以代码的方式可视化出来 属性 可选值 说明 layout_alignParentTop true/false 是否让控件相对于父容器顶部对齐 …

Intellij配置scala运行环境

文章目录 Intellij配置scala运行环境下载地址安装插件设置sdk与scala scala项目创建安装可能出现的错误 Intellij配置scala运行环境 下载地址 在centos7上安装intellij https://www.jetbrains.com/idea/download/other.html解压后进入文件夹启动打开ide ./idea-IC-232.1033…

【批量生成WORD和PDF文件】根据表格内容和模板文件批量创建word文件,一次性生成多个word文档和批量创建PDF文件

如何按照Word模板和表格的数据快速制作5000个word文档 &#xff1f; 在与客户的合作的中需要创建大量的合同&#xff0c;这些合同的模板大概都是一致的&#xff0c;是不是每次我们都需要填充不一样的数据来完成&#xff1f; 今天用表格数据完成合同模板的填充&#xff0c;批量…

深度网络结构中的梯度消失与爆炸原理分析

原理 梯度消失的定义 在深度神经网络中&#xff0c;梯度消失是指在误差反向传播过程中&#xff0c;接近输入层的层次上梯度趋近于零的现象。这导致网络权重的更新非常缓慢&#xff0c;甚至停止&#xff0c;使得训练过程变得极其困难。主要发生在使用Sigmoid或Tanh等饱和激活函…

请求go web后端接口 java安卓端播放视频

前端代码 添加gradle依赖 implementation com.squareup.retrofit2:retrofit:2.9.0 implementation com.squareup.retrofit2:converter-gson:2.9.0 添加访问网络权限 <uses-permission android:name"android.permission.INTERNET" />允许http 请求请求 andro…

乐凡信息智能安全管控方案:助力油气田行业安全管控多方位升级

我国油田地域广阔&#xff0c;分布着大量各种油井&#xff0c;油井开采设备的连续稳定运行是保证石油开采的首要条件。然而&#xff0c;由于油田多位于特殊地理环境中&#xff0c;因而实现油井之间的通信首要问题就是要克服地理环境所带来的限制&#xff0c;传统通信系统的建设…

编辑, 抽成组件

问题 错误思路&#xff1a; 1 dept不能修改&#xff0c; 用watch监听一下&#xff1a;赋值给新的变量进行修改&#xff0c; 问题&#xff1a; currentDept 发生改变&#xff0c; depth也发生了改变&#xff0c;因为是浅拷贝&#xff0c; 用了json.pase(json.stringify(value…

<项目代码>YOLO Visdrone航拍目标识别<目标检测>

项目代码下载链接 &#xff1c;项目代码&#xff1e;YOLO Visdrone航拍目标识别&#xff1c;目标检测&#xff1e;https://download.csdn.net/download/qq_53332949/90163918YOLOv8是一种单阶段&#xff08;one-stage&#xff09;检测算法&#xff0c;它将目标检测问题转化为一…