Centos7安装FastDFS

安装FastDFS

本次安装需要用到的包libfastcommon.tar.gz,fastdfs-5.11,fastdfs-nginx-module,nginx-1.12.1
需要用到的库gcc,gcc-c++,pcre,zlib
如果提示缺少gcc-c++看我的这一篇文章https://blog.csdn.net/qq_39299328/article/details/131108703

pcre安装包链接: https://pan.baidu.com/s/1HAyagHImBf7tbLYVIwFDew 提取码: eihm
zlib安装包连接: https://pan.baidu.com/s/1nwYn5P1mngwScsJ_g7gEtQ 提取码: insp
libfastcommon链接: https://pan.baidu.com/s/1fO89kJyKgSXRo-aFMyPGzw 提取码: hgg3
fastdfs-nginx-module链接: https://pan.baidu.com/s/1PMGJLDqd8iwZQxjbdZL7bA 提取码: peie
fastdfs链接: https://pan.baidu.com/s/1oBiW10FtuOSeGUCxcRDf1Q 提取码: evtm
nginx链接: https://pan.baidu.com/s/1BL4CenXYWIvrK7BC94N9Jw 提取码: f729
安装包缺哪个自己下载,如果失效,私信获取

drwxrwxr-x. 10 root root    258 Jun  1 11:04 fastdfs-5.11
drwxr-xr-x.  3 root root     47 Apr 14  2017 fastdfs-nginx-module
drwxr-xr-x.  2 root root   4096 Jun  1 10:53 gcc-c++依赖库
drwxr-xr-x.  2 root root   4096 Jun  1 10:53 gcc依赖库
drwxrwxr-x.  5 root root    135 Jun  1 11:03 libfastcommon-1.0.39
drwxr-xr-x.  9 1001  1001   186 Jun  1 11:05 nginx-1.12.1
drwxr-xr-x.  9 1169  1169 12288 Jun  1 11:01 pcre-8.45
drwxr-xr-x. 14  501 games  4096 Jun  1 11:01 zlib-1.2.13

1.安装libfastcommon

将libfastcommon.tar.gz上传至/usr/local/src下,解压,编译,安装

[root@localhost src]# mv /root/libfastcommon.tar.gz /usr/local/src/
[root@localhost src]# tar -xf libfastcommon.tar.gz 
[root@localhost libfastcommon-1.0.39]# ll
total 32
drwxrwxr-x. 2 root root  114 Jul 31  2018 doc
-rw-rw-r--. 1 root root 9099 Jul 31  2018 HISTORY
-rw-rw-r--. 1 root root  566 Jul 31  2018 INSTALL
-rw-rw-r--. 1 root root 1607 Jul 31  2018 libfastcommon.spec
-rwxrwxr-x. 1 root root 3248 Jul 31  2018 make.sh
drwxrwxr-x. 2 root root  191 Jul 31  2018 php-fastcommon
-rw-rw-r--. 1 root root 2763 Jul 31  2018 README
drwxrwxr-x. 3 root root 4096 Jul 31  2018 src
[root@localhost libfastcommon-1.0.39]# 
[root@localhost libfastcommon-1.0.39]# ./make.sh
[root@localhost libfastcommon-1.0.39]#
[root@localhost libfastcommon-1.0.39]# ./make.sh install

2.编译,安装FastDFS

[root@localhost libfastcommon-1.0.39]# cd /usr/local/src/fastdfs-5.11/
[root@localhost fastdfs-5.11]# ./make.sh 
[root@localhost fastdfs-5.11]#
[root@localhost fastdfs-5.11]# ./make.sh install

3.安装nginx

[root@localhost fdfs]# cd /usr/local/src
[root@localhost src]# mv /root/nginx-1.12.1.tar.gz ./
[root@localhost src]# 
[root@localhost src]# tar -xf nginx-1.12.1.tar.gz
[root@localhost src]#
[root@localhost src]# cd nginx-1.12.1/
[root@localhost nginx-1.12.1]# ll
total 704
drwxr-xr-x. 6 1001 1001   4096 Jun  1 09:36 auto
-rw-r--r--. 1 1001 1001 277349 Jul 11  2017 CHANGES
-rw-r--r--. 1 1001 1001 422542 Jul 11  2017 CHANGES.ru
drwxr-xr-x. 2 1001 1001    168 Jun  1 09:36 conf
-rwxr-xr-x. 1 1001 1001   2481 Jul 11  2017 configure
drwxr-xr-x. 4 1001 1001     72 Jun  1 09:36 contrib
drwxr-xr-x. 2 1001 1001     40 Jun  1 09:36 html
-rw-r--r--. 1 1001 1001   1397 Jul 11  2017 LICENSE
drwxr-xr-x. 2 1001 1001     21 Jun  1 09:36 man
-rw-r--r--. 1 1001 1001     49 Jul 11  2017 README
drwxr-xr-x. 9 1001 1001     91 Jun  1 09:36 src
[root@localhost nginx-1.12.1]# 
[root@localhost nginx-1.12.1]# ./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module/src
[root@localhost nginx-1.12.1]# make && make install

4.配置启动FastDFS

Tracker.conf 修改的地方

store_group = group1

base_path = /eshop/fdfs/tracker

Storage.conf修改的地方

base_path=/eshop/fdfs/storage

store_path0=/eshop/fdfs/storage

tracker_server=192.168.2.9:22122
[root@localhost fastdfs-5.11]# mkdir -p /eshop/fdfs/tracker
[root@localhost fastdfs-5.11]# mkdir -p /eshop/fdfs/storage
[root@localhost fastdfs-5.11]# mkdir -p /eshop/fdfs/client
[root@localhost fastdfs-5.11]# mkdir -p /eshop/fdfs/module
[root@localhost fastdfs-5.11]# 
[root@localhost fastdfs-5.11]# cd /etc/fdfs/
[root@localhost fdfs]# ll
total 64
-rw-r--r--. 1 root root  1461 Jun  1 11:04 client.conf.sample
-rw-r--r--. 1 root root   955 Jun  1 11:12 http.conf
-rw-r--r--. 1 root root 31172 Jun  1 11:12 mime.types
-rw-r--r--. 1 root root  3725 Jun  1 11:13 mod_fastdfs.conf
-rw-r--r--. 1 root root  7927 Jun  1 11:04 storage.conf.sample
-rw-r--r--. 1 root root   105 Jun  1 11:04 storage_ids.conf.sample
-rw-r--r--. 1 root root  7389 Jun  1 11:04 tracker.conf.sample
[root@localhost fdfs]# cp client.conf{.sample,}
[root@localhost fdfs]# cp storage.conf{.sample,}
[root@localhost fdfs]# cp tracker.conf{.sample,}
[root@localhost fdfs]# ll
total 84
-rw-r--r--. 1 root root  1461 Jun  1 11:16 client.conf
-rw-r--r--. 1 root root  1461 Jun  1 11:04 client.conf.sample
-rw-r--r--. 1 root root   955 Jun  1 11:12 http.conf
-rw-r--r--. 1 root root 31172 Jun  1 11:12 mime.types
-rw-r--r--. 1 root root  3725 Jun  1 11:13 mod_fastdfs.conf
-rw-r--r--. 1 root root  7927 Jun  1 11:17 storage.conf
-rw-r--r--. 1 root root  7927 Jun  1 11:04 storage.conf.sample
-rw-r--r--. 1 root root   105 Jun  1 11:04 storage_ids.conf.sample
-rw-r--r--. 1 root root  7389 Jun  1 11:17 tracker.conf
-rw-r--r--. 1 root root  7389 Jun  1 11:04 tracker.conf.sample
[root@localhost fdfs]# vim tracker.conf
[root@localhost fdfs]# vim storage.conf
[root@localhost fdfs]# 
[root@localhost fdfs]# service fdfs_trackerd start
Reloading systemd:                                         [  OK  ]
[root@localhost fdfs]# service fdfs_storaged start
Starting fdfs_storaged (via systemctl):                    [  OK  ]
[root@localhost fdfs]# 
[root@localhost fdfs]# tail -f /eshop/fdfs/tracker/logs/trackerd.log 
[2023-06-01 11:21:02] INFO - FastDFS v5.11, base_path=/eshop/fdfs/tracker, run_by_group=, run_by_user=, connect_timeout=30s, network_timeout=60s, port=22122, bind_addr=, max_connections=256, accept_threads=1, work_threads=4, min_buff_size=8192, max_buff_size=131072, store_lookup=2, store_group=, store_server=0, store_path=0, reserved_storage_space=10.00%, download_server=0, allow_ip_count=-1, sync_log_buff_interval=10s, check_active_interval=120s, thread_stack_size=64 KB, storage_ip_changed_auto_adjust=1, storage_sync_file_max_delay=86400s, storage_sync_file_max_time=300s, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, use_storage_id=0, id_type_in_filename=ip, storage_id_count=0, rotate_error_log=0, error_log_rotate_time=00:00, rotate_error_log_size=0, log_file_keep_days=0, store_slave_file_use_link=0, use_connection_pool=0, g_connection_pool_max_idle_time=3600s
[2023-06-01 11:24:05] INFO - file: tracker_relationship.c, line: 389, selecting leader...
[2023-06-01 11:24:05] INFO - file: tracker_relationship.c, line: 407, I am the new tracker leader 192.168.2.9:22122
^C
[root@localhost fdfs]# tail -f /eshop/fdfs/storage/logs/storaged.log 
mkdir data path: FB ...
mkdir data path: FC ...
mkdir data path: FD ...
mkdir data path: FE ...
mkdir data path: FF ...
data path: /eshop/fdfs/storage/data, mkdir sub dir done.
[2023-06-01 11:24:04] INFO - file: storage_param_getter.c, line: 191, use_storage_id=0, id_type_in_filename=ip, storage_ip_changed_auto_adjust=1, store_path=0, reserved_storage_space=10.00%, use_trunk_file=0, slot_min_size=256, slot_max_size=16 MB, trunk_file_size=64 MB, trunk_create_file_advance=0, trunk_create_file_time_base=02:00, trunk_create_file_interval=86400, trunk_create_file_space_threshold=20 GB, trunk_init_check_occupying=0, trunk_init_reload_from_binlog=0, trunk_compress_binlog_min_interval=0, store_slave_file_use_link=0
[2023-06-01 11:24:04] INFO - file: storage_func.c, line: 257, tracker_client_ip: 192.168.2.9, my_server_id_str: 192.168.2.9, g_server_id_in_filename: 151169216
[2023-06-01 11:24:05] INFO - file: tracker_client_thread.c, line: 310, successfully connect to tracker server 192.168.2.9:22122, as a tracker client, my ip is 192.168.2.9
[2023-06-01 11:24:35] INFO - file: tracker_client_thread.c, line: 1263, tracker server 192.168.2.9:22122, set tracker leader: 192.168.2.9:22122

5.配置fastdfs-nginx-modle和nginx

mode_fastdfs.conf修改的地方

tracker_server=192.168.2.9:22122

store_path0=/eshop/fdfs/module

group_count = 1

url_have_group_name = true

[group1]
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/eshop/fdfs/storage

nginx.conf配置修改的地方

location ~ /group[1-9]/M0[0-9]{
	ngx_fastdfs_module;
}
[root@localhost nginx-1.12.1]# cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
[root@localhost nginx-1.12.1]# cp /usr/local/src/fastdfs-5.11/conf/http.conf /etc/fdfs/
[root@localhost nginx-1.12.1]# cp /usr/local/src/fastdfs-5.11/conf/mime.types /etc/fdfs/
[root@localhost nginx-1.12.1]# 
[root@localhost nginx-1.12.1]# ll /etc/fdfs/
total 64
-rw-r--r--. 1 root root  1461 Jun  1 11:04 client.conf.sample
-rw-r--r--. 1 root root   955 Jun  1 11:12 http.conf
-rw-r--r--. 1 root root 31172 Jun  1 11:12 mime.types
-rw-r--r--. 1 root root  3725 Jun  1 11:13 mod_fastdfs.conf
-rw-r--r--. 1 root root  7927 Jun  1 11:04 storage.conf.sample
-rw-r--r--. 1 root root   105 Jun  1 11:04 storage_ids.conf.sample
-rw-r--r--. 1 root root  7389 Jun  1 11:04 tracker.conf.sample
[root@localhost nginx-1.12.1]# 
[root@localhost nginx-1.12.1]# vim /etc/fdfs/mod_fastdfs.conf
[root@localhost nginx-1.12.1]# 
[root@localhost nginx-1.12.1]# vim /usr/local/nginx/conf/nginx.conf
[root@localhost nginx-1.12.1]# /usr/local/nginx/sbin/nginx

6.上传测试

client.conf需要修改的地方

base_path=/eshop/fdfs/client
tracker_server=192.168.2.9:22122
[root@localhost ~]# vim /etc/fdfs/client.conf
[root@localhost ~]# 
[root@localhost ~]# touch test.txt
[root@localhost ~]# echo sucess > test.txt 
[root@localhost ~]# 
[root@localhost ~]# /usr/local/src/fastdfs-5.11/client/fdfs_upload_file /etc/fdfs/client.conf ~/test.txt
group1/M00/00/00/wKgCCWR4NtmADmmqAAAAB4RYT9k668.txt
[root@localhost ~]# 
[root@localhost ~]# curl http://localhost/group1/M00/00/00/wKgCCWR4NtmADmmqAAAAB4RYT9k668.txt
sucess
[root@localhost ~]# 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值