当前位置: 首页 > news >正文

CentOS 7 安装、测试和部署FastDFS

目录

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

相关文章:

CentOS 7 安装、测试和部署FastDFS

目录 FastDFS环境搭建 安装 libfastcommon 库 安装FastDFS 查看编译后的文件 FastDFS配置 FastDFS启动 启动tracker服务 启动storage服务 查看storage是否已经注册到了tracker下 查看存储文件的目录 FastDFS重启 FastDFS关闭 使用fdfs_test进行测试 修改client.co…...

全志H618 Android12修改doucmentsui选中图片资源详情信息

背景: 由于当前的文件管理器在我们的产品定义当中,某些界面有改动的需求,所以需要在Android12 rom中进行定制以符合当前产品定义。 需求: 进入file文件管理器后,点击选中图片资源,选中功能按钮,获取信息,不显示“调试信息(仅开发者)”;现状是,获取信息,显示“调试信…...

【083】基于51单片机智能烘手器【Proteus仿真+Keil程序+报告+原理图】

☆、设计硬件组成&#xff1a;51单片机最小系统LCD1602液晶显示DS18B20温度传感器TCRT5000红外感应传感器AT24C02存储芯片风扇加热片继电器LED灯按键设置。 1、设计采用STC89C51/52、AT89C51/52、AT89S51/52作为主控芯片&#xff1b; 2、系统采用DS18B20温度传感器感应当前环…...

uniApp使用腾讯地图提示未添加maps模块

uniApp使用腾讯地图&#xff0c;打包提示未添加maps模块解决方案 这是报错信息&#xff0c;在标准基座运行的时候是没问题的&#xff0c;但是打包后会提示未添加&#xff0c;可以通过在mainfest里面把地图插件上腾讯地图的key更换高德地图的key&#xff0c;定位服务可以继续用腾…...

未来趋势系列 篇五:自主可控科技题材解析和股票梳理

文章目录 系列文章自主可控科技题材分析国产算力信创(信息技术应用创新)华为鸿蒙军工信息化半导体芯片卫星互联网工业软件股票梳理系列文章 未来趋势系列 篇一:AI题材解析和股票梳理 未来趋势系列 篇一(加更):AI医疗题材解析和股票梳理 未来趋势系列 篇二:HBM题材解析和…...

Springboot 学习 之 logback-spring.xml 日志压缩 .tmp 临时文件问题

文章目录 前言功能简述1. 自定义日志文件名2. 归档规则 && 压缩2.1. 归档配置2.2. 归档压缩2.3. 日志格式 && 编码 现象原因解决办法 前言 在 Springboot 应用中&#xff0c;默认使用 logback-spring.xml 配置日志相关 功能简述 1. 自定义日志文件名 <fi…...

maven-resources-production:ratel-fast: java.lang.IndexOutOfBoundsException

Maven生产环境中遇到java.lang.IndexOutOfBoundsException的问题&#xff0c;尝试了重启电脑、重启IDEA等常规方法无效&#xff0c;最终通过直接重建工程解决了问题。 Rebuild Project 再启动OK...

K8s docker-compose的入门

一、Docker Compose 简介 什么是 Docker Compose&#xff1f; 用于定义和运行多容器 Docker 应用的工具。Docker Compose 的主要功能 使用 docker-compose.yml 文件定义服务。一键启动和管理多容器环境。安装与环境准备 安装 Docker 和 Docker Compose。检查版本&#xff1a;d…...

去雾Cycle-GAN损失函数

文章目录 GAN-LossIdentity-LossDP-lossCycle-Loss G和F都是生成器 G是hazy → \to → gt F是gt → \to → hazy D y D_y Dy​判别无雾图是真实还是生成的&#xff1f; D x D_x Dx​判别有雾图是真实还是生成的&#xff1f; GAN-Loss 在 DAM-CCGAN 中存在两个判别器 D x D_x D…...

word实现两栏格式公式居中,编号右对齐

1、确定分栏的宽度 选定一段文字 点击分栏&#xff1a;如本文的宽度为22.08字符 2、将公式设置为 两端对齐&#xff0c;首行无缩进。 将光标放在 公式前面 点击 格式-->段落-->制表位 在“制表位位置”输入-->11.04字符&#xff08;22.08/211.04字符&#xff09;&…...

vtie项目中使用到了TailwindCSS,如何打包成一个单独的CSS文件(优化、压缩)

在不依赖 Vite 或其他构建工具的情况下&#xff0c;使用 TailwindCSS CLI 快速生成独立的 CSS 文件是一种简单高效的方法&#xff0c;适合需要纯样式文件的场景。 这个项目中&#xff0c;使用到了tailwindCss, 需要把里面的样式打包出来&#xff0c;给其他项目用。 使用命令生…...

shell脚本案例

脚本一&#xff1a;打印当前系统登录用户列表 #!/bin/bash # 使用 who 命令获取当前登录用户信息并输出 who解释&#xff1a;who 命令用于显示当前登录系统的用户信息&#xff0c;包括用户名、登录终端、登录时间等。此脚本直接执行 who 命令并将结果输出到终端。 脚本二&…...

完整微服务设计 功能实现

我们将以一个简单的电商系统为例&#xff0c;实现微服务架构&#xff0c;逐步用Java代码详细实现每个模块&#xff0c;并配合注释帮助小白理解。在这个实现中&#xff0c;我们使用以下工具和框架&#xff1a; Spring Boot&#xff1a;用于构建微服务。Spring Cloud&#xff1a…...

JWT令牌与微服务

1. 什么是JWT JWT&#xff08;JSON Web Token&#xff09;是一种开放标准(RFC 7519)&#xff0c;它定义了一种紧凑且自包含的方式&#xff0c;用于作为JSON对象在各方之间安全地传输信息。JWT通常用于身份验证和信息交换。 以下是JWT的一些关键特性&#xff1a; 紧凑&#xff…...

C# WinForm移除非法字符的输入框

C# WinForm移除非法字符的输入框 文章目录 namespace System.Windows.Forms {using System.ComponentModel;/// <summary>/// 支持移除 非法字符 的输入框。/// </summary>public class RemoveInvalidCharTextBox : TextBox{/// <summary>/// 测试代码&#…...

智慧商城:基于请求数据动态渲染购物车列表

进入购物车列表页面&#xff0c;当即触发请求&#xff0c;打印出解构出来的data.list 查看数据是否添加到 vuex 中。 将物品加入购物车&#xff0c;点击购物车进入购物车列表页&#xff0c;点击 vue 调试工具&#xff0c;可以看到 cart 模块state中新增添加的几个物品信息 渲染…...

医疗信息化浪潮下 SSM+Vue 医院预约挂号系统的崛起

2相关技术 2.1 MYSQL数据库 MySQL是一个真正的多用户、多线程SQL数据库服务器。 是基于SQL的客户/服务器模式的关系数据库管理系统&#xff0c;它的有点有有功能强大、使用简单、管理方便、安全可靠性高、运行速度快、多线程、跨平台性、完全网络化、稳定性等&#xff0c;非常…...

QScreen在Qt5.15与Qt6.8版本下的区别

简述 QScreen主要用于提供与屏幕相关的信息。它可以获取有关显示设备的分辨率、尺寸、DPI&#xff08;每英寸点数&#xff09;等信息。本文主要是介绍Qt5.15与Qt6环境下&#xff0c;QScreen的差异&#xff0c;以及如何判断高DPI设备。 属性说明 logicalDotsPerInch&#xff1…...

模具生产过程中的标签使用流程图

①NFC芯片嵌入周转筐&#xff0c;通过读卡器读取CK_Label_v3的数据&#xff0c;并将这些信息上传至服务器进行存储&#xff1b; ②服务器随后与客户的WMS&#xff08;仓库管理系统&#xff09;进行交互&#xff0c;记录和同步注塑机的原始数据&#xff1b; ③当周转筐内的模具…...

Unity-URP设置单独渲染UI相机

Unity-URP设置单独渲染UI相机 1、设置主相机层级&#xff0c;剔除UI层 2、新建UICamera&#xff0c;设置RenderType为Overiay&#xff1b;显示层级只选择UI层 3、选择主相机&#xff0c;Stack参数添加UICamera 4、Canvas设置成ScreenSpace-Camera&#xff0c;并指定UICamera渲…...

Appium+python自动化(十六)- ADB命令

简介 Android 调试桥(adb)是多种用途的工具&#xff0c;该工具可以帮助你你管理设备或模拟器 的状态。 adb ( Android Debug Bridge)是一个通用命令行工具&#xff0c;其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利&#xff0c;如安装和调试…...

关于nvm与node.js

1 安装nvm 安装过程中手动修改 nvm的安装路径&#xff0c; 以及修改 通过nvm安装node后正在使用的node的存放目录【这句话可能难以理解&#xff0c;但接着往下看你就了然了】 2 修改nvm中settings.txt文件配置 nvm安装成功后&#xff0c;通常在该文件中会出现以下配置&…...

Docker 本地安装 mysql 数据库

Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker &#xff1b;并安装。 基础操作不再赘述。 打开 macOS 终端&#xff0c;开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...

android RelativeLayout布局

<?xml version"1.0" encoding"utf-8"?> <RelativeLayout xmlns:android"http://schemas.android.com/apk/res/android"android:layout_width"match_parent"android:layout_height"match_parent"android:gravity&…...

Vue3 PC端 UI组件库我更推荐Naive UI

一、Vue3生态现状与UI库选择的重要性 随着Vue3的稳定发布和Composition API的广泛采用&#xff0c;前端开发者面临着UI组件库的重新选择。一个好的UI库不仅能提升开发效率&#xff0c;还能确保项目的长期可维护性。本文将对比三大主流Vue3 UI库&#xff08;Naive UI、Element …...

2.2.2 ASPICE的需求分析

ASPICE的需求分析是汽车软件开发过程中至关重要的一环&#xff0c;它涉及到对需求进行详细分析、验证和确认&#xff0c;以确保软件产品能够满足客户和用户的需求。在ASPICE中&#xff0c;需求分析的关键步骤包括&#xff1a; 需求细化&#xff1a;将从需求收集阶段获得的高层需…...

CppCon 2015 学习:Reactive Stream Processing in Industrial IoT using DDS and Rx

“Reactive Stream Processing in Industrial IoT using DDS and Rx” 是指在工业物联网&#xff08;IIoT&#xff09;场景中&#xff0c;结合 DDS&#xff08;Data Distribution Service&#xff09; 和 Rx&#xff08;Reactive Extensions&#xff09; 技术&#xff0c;实现 …...

react-pdf(pdfjs-dist)如何兼容老浏览器(chrome 49)

之前都是使用react-pdf来渲染pdf文件&#xff0c;这次有个需求是要兼容xp环境&#xff0c;xp上chrome最高支持到49&#xff0c;虽然说iframe或者embed都可以实现预览pdf&#xff0c;但为了后续的定制化需求&#xff0c;还是需要使用js库来渲染。 chrome 49测试环境 能用的测试…...

MeanFlow:何凯明新作,单步去噪图像生成新SOTA

1.简介 这篇文章介绍了一种名为MeanFlow的新型生成模型框架&#xff0c;旨在通过单步生成过程高效地将先验分布转换为数据分布。文章的核心创新在于引入了平均速度的概念&#xff0c;这一概念的引入使得模型能够通过单次函数评估完成从先验分布到数据分布的转换&#xff0c;显…...

MCP和Function Calling

MCP MCP&#xff08;Model Context Protocol&#xff0c;模型上下文协议&#xff09; &#xff0c;2024年11月底&#xff0c;由 Anthropic 推出的一种开放标准&#xff0c;旨在统一大模型与外部数据源和工具之间的通信协议。MCP 的主要目的在于解决当前 AI 模型因数据孤岛限制而…...