当前位置: 游戏平台 > 互联网科技 > 正文

CentOS下搭建FastDFS

时间:2019-11-08 22:33来源:互联网科技
背景描述 OS CentOS-6.3_x86-64 FastDFS布满式文件系统的设置及配置-单服务器版 生龙活虎、在安装法斯特DFS以前必需先安装libevent,安装libevent步骤如下: tracker 192.168.0.10   1.下载libevent: w

背景描述
OS
CentOS-6.3_x86-64

FastDFS布满式文件系统的设置及配置-单服务器版

生龙活虎、在安装法斯特DFS以前必需先安装libevent,安装libevent步骤如下:

tracker
192.168.0.10

 

1.下载libevent:

wgethttps://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

storage
192.168.0.11

安装蒙受及其配置目录

2.解压libevent:

tar -zxvpf libevent-2.0.21-stable.tar.gz

1,安装libevent

风姿洒脱台服务器集成一个Tracker Server + 八个Storage Server

3.步向解压目录:

cd libevent-2.0.21-stable

  1. wget    
  2. tar xvzf libevent-2.0.20-stable.tar.gz   
  3. ./configure   
  4. make   
  5. make install   
  6.   
  7. 将库文件链接到/lib64   
  8. ln -s /usr/local/lib/libevent-2.0.so.5 /lib64/libevent-2.0.so.5  

1

4.指定安装目录:

./configure --prefix=/usr/local/libevent-2.0.21

2,安装FastDFS

环境IP:192.168.127.6

5.安装libevent:

make

make install

  1. wget    
  2. tar xvzf FastDFS_v3.11.tar.gz   
  3.   
  4. 修改 make.sh   
  5. #WITH_HTTPD --> WITH_HTTPD   
  6.   
  7. ./make.sh   
  8. ./make.sh install  

2

二、安装法斯特DFS步骤如下:

3,启动FastDFS-->tracker

Tracker Server base_path:/home/fastdfs/tracker        端口:22122  http端口:9090

1.下载FastDFS:

wgethttp://fastdfs.googlecode.com/files/FastDFS_v4.06.tar.gz

成立目录/opt/fastdfs

3

2.解压FastDFS:

tar xvf FastDFS_v4.06.tar.gz

[root@ www.linuxidc.com ~]# mkdir /opt/fastdfs  

storage Server base_path:/home/fastdfs/fdfs_storage   端口:23000  http端口:8887  group:group2

3.跻身解压目录:

cd FastDFS

修改tracker.conf配置

4

4.更正法斯特DFS的安装文件:

vi make.sh

TARGET_PREFIX=/usr/local/法斯特DFS  ---安装路线

TARGET_CONF_PATH=/etc/fdfs  ---配置文件路线

WITH_LINUX_SERVICE=1   ---是否为linux服务

  1. [root@ www.linuxidc.com ~]# vim /etc/fdfs/tracker.conf   
  2. base_path=/home/yuqing/fastdfs -> base_path=/opt/fastdfs   
  3. ##include http.conf -> #include http.conf  

storage Server base_path:/home/fastdfs/fdfs_storage1  端口:23001  http端口:8889  group:group3

5.指定libevent的lib目录:

./make.sh C_INCLUDE_PATH=/usr/local/libevent-2.0.21/include LIBRARY_PATH=/usr/local/libevent-2.0.21/lib

启动tracker

01

6.安装FastDFS:

./make.sh install

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

#软件安装包存款和储蓄:

7.安装软连接(不然编写翻译nginx时会出错)

ln -sv /usr/local/FastDFS/include/fastcommon /usr/local/include/fastcommon

ln -sv /usr/local/FastDFS/include/fastdfs /usr/local/include/fastdfs

ln -sv /usr/local/FastDFS/lib/libfastcommon.so /usr/local/lib/libfastcommon.so

ln -sv /usr/local/FastDFS/lib/libfastcommon.so.1 /usr/local/lib/libfastcommon.so.1

ln -sv /usr/local/FastDFS/lib/libfdfsclient.so /usr/local/lib/libfdfsclient.so

ln -sv /usr/local/FastDFS/lib/libfdfsclient.so.1 /usr/local/lib/libfdfsclient.so.1

重启

02

三、在安装Nginx在此之前,供给设置gcc、 openssl-devel、 pcre-devel和zlib-devel软件库,具体如下:

yum install gcc-c++

yum install openssl-devel

yum install pcre-devel

yum install zlib-devel

/usr/local/bin/restart.sh  /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf

/usr/local/src

四、安装Nginx和fastdfs-nginx-module

wgethttp://nginx.org/download/nginx-1.6.0.tar.gz

wgethttp://fastdfs.googlecode.com/files/fastdfs-nginx-module_v1.15.tar.gz

将安装包文件上传到/usr/local中施行以下操作:

4,启动FastDFS-->storage

03

1.进来文件目录:

cd /usr/local

开创目录/opt/fastdfs

/etc/fdfs/*     #tracker,storage ·· 配置文件

2.解压安装包:

tar -zxv -f nginx-1.6.0.tar.gz

tar -xvf fastdfs-nginx-module_v1.15.tar.gz

[root@ www.linuxidc.com ~]# mkdir /opt/fastdfs 

04

3.改造安装包目录名称:

mv nginx-1.6.0 nginx

修改storage.conf配置

 

4.跻身安装包目录:

cd /usr/local/nginx

  1. [root@ www.linuxidc.com ~]# vim /etc/fdfs/storage.conf   
  2. base_path=/home/yuqing/fastdfs --> /opt/fastdfs   
  3. store_path0=/home/yuqing/fastdfs --> store_path0=/opt/fastdfs   
  4. group_name=group1   
  5. tracker_server=192.168.209.121:22122 --> tracker_server=192.168.0.10:22122  
  6. ##include http.conf --> #include http.conf  

05

5.布局安装目录:

./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf  --add-module=/usr/local/fastdfs-nginx-module/src

启动storage

#着力目录列表:

6.安装Nginx:

make

make install

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

06

7.退换防火墙:

vi + /etc/sysconfig/iptables

5,上传测验

/home/fastdfs/tracker      #创立tracker目录保存运转日志

8.增多配置项

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

修改client.conf

07

9.重启防火墙:

service iptables restart

  1. [root@ www.linuxidc.com ~]# vim /etc/fdfs/client.conf   
  2. vi /etc/fdfs/client.conf   
  3. base_path=/home/yuqing/fastdfs-> base_path=/opt/fastdfs   
  4. tracker_server=192.168.209.121:22122 -> tracker_server=192.168.0.10:22122  
  5. ##include http.conf ->#include http.conf  

/home/fastdfs/fdfs_storage  #创办Storage目录保存运维日志及其data数据

10.将libfastcommon.so、libfastcommon.so.1、libfdfsclient.so、libfdfsclient.so.1复制到/usr/lib,否则nginx运营会报错。

Nginx的操作:

启动:

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

或者

cd /usr/local/nginx/sbin

./nginx

假使开发银行找不到

error while loading shared libraries: libfdfsclient.so: cannot open shared object file: No such file or directory

error while loading shared libraries: libfastcommon.so: cannot open shared object file: No such file or directory

请使用以下软连接

[root@localhost lib]# ln -s /usr/local/FastDFS/lib/libfastcommon.so /usr/lib/libfastcommon.so

[root@localhost lib]# ln -s /usr/local/FastDFS/lib/libfastcommon.so /usr/lib64/libfastcommon.so

[root@localhost lib]# ln -s /usr/local/FastDFS/lib/libfastcommon.so /usr/lib64/libfastcommon.so

[root@localhost lib]# ln -s /usr/local/FastDFS/lib/libfdfsclient.so /usr/lib/libfdfsclient.so

[root@localhost lib]# ln -s /usr/local/FastDFS/lib/libfdfsclient.so /usr/lib64/libfdfsclient.so

截止服务:

#查询nginx主进度号

ps -ef | grep nginx

#停止进程

kill -QUIT 主进度号

#急忙截止

kill -TERM 主进程号

#强制甘休

pkill -9 nginx

重启:

/usr/local/nginx/sbin/nginx -s reload

上传

08

五、配置tracker server:

  1. [root@ www.linuxidc.com ~]# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload FastDFS_v3.03.tar.gz   
  2. This is FastDFS client test program v3.11  
  3.   
  4. Copyright (C) 2008, Happy Fish / YuQing   
  5.   
  6. FastDFS may be copied only under the terms of the GNU General   
  7. Public License V3, which may be found in the FastDFS source kit.   
  8. Please visit the FastDFS Home Page     
  9. for more detail.   
  10.   
  11. [2012-09-12 15:43:03] DEBUG - base_path=/opt/fastdfs, connect_timeout=30, network_timeout=60, tracker_server_count=1, anti_steal_token=0, anti_steal_secret_key length=0  
  12.   
  13. tracker_query_storage_store_list_without_group:    
  14.         server 1. group_name=group1, ip_addr=192.168.0.11, port=23000  
  15.   
  16. group_name=group1, ip_addr=192.168.0.11, port=23000  
  17. storage_upload_by_filename   
  18. group_name=group1, remote_filename=M00/00/00/CAAAC1BQPQqy0zXVAAWp7X_1XGc.tar.gz   
  19. source ip address: 192.168.0.11  
  20. file timestamp=2012-09-12 15:43:06  
  21. file size=371181  
  22. file crc32=2146786407  
  23. file url:    
  24. storage_upload_slave_by_filename   
  25. group_name=group1, remote_filename=M00/00/00/CAAAC1BQPQqy0zXVAAWp7X_1XGc_big.tar.gz   
  26. source ip address: 8.0.0.11  
  27. file timestamp=2012-09-12 15:43:06  
  28. file size=371181  
  29. file crc32=2146786407  
  30. file url:   

/home/fastdfs/fdfs_storage1 #创造Storage1目录保存运转日志及其data数据

1. vi /etc/fdfs/tracker.conf

bind_addr=192.168.227.128

base_path=/home/tracker/fastdfs

vi /etc/fdfs/client.conf

base_path=/home/tracker/fastdfs

tracker_server=192.168.20.200:22122

http.tracker_server_port=8080

图片 1

09

2.计划防火墙:

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22122 -j

 

3.封存配置:

/etc/init.d/iptables save

10

4. 启动 tracker

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

在运维时报错:

/usr/local/bin/fdfs_trackerd: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory

试行上面包车型大巴命令就可以符合规律运营:

echo '/usr/local/libevent-2.0.21/include/' >> /etc/ld.so.conf

echo '/usr/local/libevent-2.0.21/lib/' >> /etc/ld.so.conf

ldconfig

一声令下汇总:mkdir -p /home/fastdfs/tracker;mkdir -p /home/fastdfs/fdfs_storage;mkdir -p /home/fastdfs/fdfs_storage1;

5. 查看监听程序:

netstat -ntpl | grep fdfs

11

6. 查看日志文件:

cat /home/tracker/fastdfs/logs/trackerd.log

 

7.增加开机运营命令行:

vim /etc/rc.d/rc.local

/usr/local/FastDFS/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

12

六、配置storage server

为便于寻觅目录,设置变量

1. vi /etc/fdfs/storage.conf

group_name=group1

bind_addr=192.168.227.130

base_path=/home/storage/fastdfs

store_path0=/home/storage/fastdfs

tracker_server=192.168.227.130:22122

http.server.port=80

13

2. cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/

# vi .bashrc

3. vi /etc/fdfs/mod_fastdfs.conf

base_path=/home/storage1/fastdfs

group_name=group1

store_path0=/home/stroage1/fastdfs

tracker_server=192.168.227.128:22122

url_have_group_name = true

group_count = 0

14

4. vi /usr/local/nginx/conf/nginx.conf

location /group1/M00 {

root /home/storage1/fastdfs/data;

ngx_fastdfs_module;

}

alias  worksrc='cd /usr/local/src'

5.陈设防火墙:

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 23000 -j ACCEPT

15

6.封存配置:

/etc/init.d/iptables save

安排生效

7.启动 storage

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

16

8. 翻看监听程序:

netstat -ntpl | grep fdfs

# source .bashrc

9. 翻看日志文件:

cat /home/storage/fastdfs/logs/storaged.log

安装FastDFS

七、测试:

/usr/local/FastDFS/bin/fdfs_test /etc/fdfs/client.conf upload /etc/passwd

结果如下:

This is FastDFS client test program v4.06

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 Pagehttp://www.csource.org/

for more detail.

[2014-06-03 20:26:21] DEBUG - base_path=/home/client/fastdfs, 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

tracker_query_storage_store_list_without_group:

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

group_name=group1, ip_addr=192.168.227.130, port=23000

storage_upload_by_filename

group_name=group1, remote_filename=M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851

source ip address: 192.168.227.130

file timestamp=2014-06-03 20:26:21

file size=1438

file crc32=218985275

file url:http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851

storage_upload_slave_by_filename

group_name=group1, remote_filename=M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big

source ip address: 192.168.227.130

file timestamp=2014-06-03 20:26:21

file size=1438

file crc32=218985275

file url:http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big

在浏览器上开发http://192.168.227.130/group1/M00/00/00/wKjjglOOkd2AdZiiAAAFng0Nczs9728851_big

测验成功!!!

参考:

http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html

http://blog.csdn.net/yl_wh/article/details/8784569

率先安装libevent,法斯特DFS 内部绑定了 libevent 作为 http 服务器

01

##卸载系统自带libevent,自带版本过低,安装fastdfs会出错

02

rpm -qa|grep libevent;yum remove libevent*

03

 

04

worksrc;

05

wget ;

06

tar -zxvf libevent-2.0.19-stable.tar.gz;

07

cd libevent-2.0.19-stable;

08

make clean;

09

./configure --prefix=/usr/local/libevent

10

make && make install;

11

 

12

##为libevent创造软链接到/lib库下,六15人系统对应/lib64

13

ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5

14

ln -s /usr/local/libevent/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

15

 

16

一声令下汇总:worksrc;wget -zxvf libevent-2.0.19-stable.tar.gz;cd libevent-2.0.19-stable;make clean;./configure --prefix=/usr/local/libevent;make && make install;cd ../

安装FastDFS的步骤

1

wget

2

tar -zxvf FastDFS_v3.08.tar.gz

3

cd FastDFS

4

vim make.sh

5

#将 #WITH_HTTPD=1 修改成WITH_HTTPD=1 以支持 http

6

./make.sh C_INCLUDE_PATH=/usr/local/libevent/include LIBRARY_PATH=/usr/local/libevent/lib

7

./make.sh install

FastDFS的配置

安顿及运转Tracker Server,选取9090端口,和常用的80、8080常用http端口分开

1

#修改tracker.conf配置

2

vim /etc/fdfs/tracker.conf

3

base_path=/home/yuqing/fastdfs -> base_path=/home/fastdfs/tracker #日记目录

4

http.server_port=8080 -> http.server_port=9090       #http端口

5

##include http.conf -> #include http.conf            #张开自带http服务

6

reserved_storage_space = 4GB -> reserved_storage_space = 1GB

7

 

8

#启动Tracker Server

编辑:互联网科技 本文来源:CentOS下搭建FastDFS

关键词:

  • 上一篇:没有了
  • 下一篇:没有了