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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

通用导出任何对象列表数据的excel工具类

在工作中经常会遇到列表数据的导出&#xff0c;每次需要的时候都要去开发一次&#xff0c;且数据不断在变化&#xff0c;于是就有了下述的工具类&#xff0c;可传入各种实体对象的List&#xff0c;最终以指定格式导出excel&#xff0c;废话不多说&#xff0c;上代码~ 控制层代…

前端:改变鼠标点击物体的颜色

需求&#xff1a; 需要改变图片中某一物体的颜色&#xff0c;该物体是纯色&#xff1b; 鼠标点击哪个物体&#xff0c;哪个物体的颜色变为指定的颜色&#xff0c;利用canvas实现。 演示案例 代码Demo <!DOCTYPE html> <html lang"en"><head>&l…

AI口播数字人系统快速搭建方法来袭!零经验小白也能学会!

随着AI口播数字人的身影在短视频和直播中的出现频率持续升高&#xff0c;越来越多的创业者都察觉到了AI口播数字人系统所蕴含着的巨大潜在用户规模和广阔收益前景&#xff0c;并打听起了AI口播数字人系统怎么搭建相关的各种消息。 毕竟&#xff0c;根据当前的使用情况来看&…

中小学生心理健康测评系统:精准洞察,助力成长!

随着社会的发展&#xff0c;中小学生的心理健康问题日益受到关注。国家出台了一系列政策&#xff0c;强调要加强学生心理健康教育。然而&#xff0c;在实际的校园环境中&#xff0c;中小学生面临着各种各样的心理挑战&#xff0c;课程增多、难度加大&#xff0c;考试频繁&#…

2024年12月英语六级CET6写作与翻译笔记

目录 1 写作 1.1 大学为学生提供了探索各种可能性 1.2 自律在个人成长中的重要性 1.3 切实可行的目标 2 翻译 2.1 洋山港(Yangshan Port) 2.2 中国航天事业 2.3 北斗卫星导航系统 1 写作 1.1 大学为学生提供了探索各种可能性 1.2 自律在个人成长中的重要性 1.3 切实可…

Unity性能优化 --- 减少OverDraw

OverDraw(过度绘制)就是GPU多次重复绘制同一像素点的操作。在Unity 中渲染的图像由数百万个像素组成&#xff0c;如果这些像素被多次绘制&#xff0c;那么会造成GPU极大的性能损耗。例如下图多个物体叠加放在一起 注&#xff1a;棕色越深的地方&#xff0c;过度绘制的次数越多。…

PostgreSQL 的历史

title: PostgreSQL 的历史 date: 2024/12/23 updated: 2024/12/23 author: cmdragon excerpt: PostgreSQL 是一款功能强大且广泛使用的开源关系型数据库管理系统。其历史可以追溯到1986年,当时由加州大学伯克利分校的一个研究团队开发。文章将深入探讨 PostgreSQL 的起源、…

python学opencv|读取图像(二十一)使用cv2.circle()绘制圆形进阶

【1】引言 前序已经掌握了使用cv2.circle()绘制圆形的基本操作&#xff0c;相关链接为&#xff1a; python学opencv|读取图像&#xff08;二十&#xff09;使用cv2.circle()绘制圆形-CSDN博客 由于圆形本身绘制起来比较简单&#xff0c;因此可以自由操作的空间也就大&#x…

大数据-256 离线数仓 - Atlas 数据仓库元数据管理 正式安装 启动服务访问 Hive血缘关系导入

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; Java篇开始了&#xff01; 目前开始更新 MyBatis&#xff0c;一起深入浅出&#xff01; 目前已经更新到了&#xff1a; Hadoop&#xff0…

保险科技“数智化+”赋能险企高质量发展

文 / 太保科技有限公司人工智能服务事业群资深产品经理 娄昕盛 中国太平洋保险(集团)股份有限公司数智研究院人工智能首席专家 徐国强 中国太平洋保险(集团)股份有限公司数智研究院执行院长 王磊 近年来,保险科技正处在“数字化+”向“数智化+”发展的过渡阶段,…

AI科研助手开发总结:向量与数据权应用(二)

一、前言 继上篇文章&#xff1a;AI科研助手开发总结&#xff1a;向量与数据权限的应用&#xff08;一&#xff09; 本章根据向量库内存储数据及权限&#xff0c;向量库统一维护和管理数据权限方案讨论。 二、方案分析-基于向量Fields 2.1 思路 结合橙语AI科研助手的业务场…

数字逻辑(七)——逻辑运算中三种基本运算及其符合运算

目录 1 三种基本逻辑运算 1.1 与&#xff08;AND&#xff09; 1.2 或&#xff08;OR&#xff09; 1.3 非&#xff08;NOT&#xff09; 2 由基本门电路组成的其他门电路 2.1 异或 2.2. 同或 2.3 与非 2.4 或非 用于分析数字电路中逻辑功能的数学方法——逻辑代数&#…

分布式事务的解决方案(欢迎讨论~)

目录 背景 CAP定理 BASE理论 场景重现​编辑 分布式事务常见的解决分案 1.二段提交 2.三段提交 3.TCC模式 4.分布式补偿事务&#xff08;Saga&#xff09; 5.Seata分布式框架-XA模式 6.Seata分布式框架-AT模式 XA AT TCC SAGA 的对比 背景 首先必须介绍一下分布式中…

汽车IVI中控开发入门及进阶(43):NanoVG

NanoVG:基于OpenGL的轻量级抗锯齿2D矢量绘图库 NanoVG是一个跨平台、基于OpenGL的矢量图形渲染库。它非常轻量级,用C语言实现,代码不到5000行,非常精简地实现了一套HTML5 Canvas API,做为一个实用而有趣的工具集,用来构建可伸缩的用户界面和可视化效果。NanoVG-Library为…

从0到1实现一个RS蓝图系统-概念提出技术栈选型

请不要自我设限&#xff0c;真正好的人生态度&#xff0c;是现在就做&#xff0c;不等、不靠、不懒惰。 ——小野《改变力》 一、什么是蓝图&#xff1f; 蓝图(BluePrint) 是Epic Games 针对虚幻4引擎开发的可视化脚本语言。当你使用蓝图的时候&#xff0c;其实就是在编写代码…

【C++ 类和对象 基础篇】—— 抽象思维的巅峰舞者,演绎代码的深邃华尔兹

C学习笔记&#xff1a; C 进阶之路__Zwy的博客-CSDN博客 各位于晏&#xff0c;亦菲们&#xff0c;请点赞关注&#xff01; 我的个人主页&#xff1a; _Zwy-CSDN博客 目录 1、类 1.1、类的定义 1.2、访问限定符 1.2.1、public 1.2.2、private 1.2.3、protected 1.3、…

(高可用版本)Kubeadm+Containerd+keepalived部署高可用k8s(v1.28.2)集群

KubeadmContainerdkeepalived部署高可用k8s(v1.28.2)集群 一.环境准备&#xff0c;二.容器运行时Containerd安装请参照前文。KubeadmContainerd部署k8s(v1.28.2)集群&#xff08;非高可用版&#xff09;-CSDN博客 文章目录 KubeadmContainerdkeepalived部署高可用k8s(v1.28.2)集…

联合目标检测与图像分类提升数据不平衡场景下的准确率

联合目标检测与图像分类提升数据不平衡场景下的准确率 在一些数据不平衡的场景下&#xff0c;使用单一的目标检测模型很难达到99%的准确率。为了优化这一问题&#xff0c;适当将其拆解为目标检测模型和图像分类模型的组合&#xff0c;可以更有效地控制最终效果&#xff0c;尤其…

C++之红黑树模拟实现

目录 红黑树的概念 红黑树的性质 红黑树的查找效率 红黑树的实现 红黑树的定义 红黑树节点的插入 红黑树的平衡调整 判断红黑树是否平衡 红黑树整体代码 测试代码 上期我们学习了AVL树的模拟实现&#xff0c;在此基础上&#xff0c;我们本期将学习另一个数据结构-…

机器学习常用术语

目录 概要 机器学习常用术语 1、模型 2、数据集 3、样本与特征 4、向量 5、矩阵 6、假设函数与损失函数 7、拟合、过拟合与欠拟合 8、激活函数(Activation Function) 9、反向传播(Backpropagation) 10、基线(Baseline) 11、批量(Batch) 12、批量大小(Batch Size)…