Centos6.5安装FastDFS

1.创建新的虚拟机。

查看连接:

1:创建新的虚拟机步骤_心如猛虎细嗅蔷薇的博客-CSDN博客_创建新虚拟机的步骤   创建新的虚拟机步骤

2:虚拟机安装linux_心如猛虎细嗅蔷薇的博客-CSDN博客   虚拟机安装linux

3:linux系统 设置网卡ping通主机连上外网_心如猛虎细嗅蔷薇的博客-CSDN博客 linux系统 设置网卡ping通主机连上外网

获取资源

wget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz
wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz
wget http://nginx.org/download/nginx-1.12.1.tar.gz

安装包资源:

FastDFS是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境。

   安装FastDFS需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:yum install gcc-c++

FastDFS依赖libevent库,需要安装:

yum -y install libevent

libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。

将libfastcommonV1.0.7.tar.gz拷贝至/usr/local/下

cd /usr/local

tar -zxvf libfastcommonV1.0.7.tar.gz

cd libfastcommon-1.0.7

./make.sh

./make.sh install

注意:libfastcommon安装好后会自动将库文件拷贝至/usr/lib64下,由于FastDFS程序引用usr/lib目录所以需要将/usr/lib64下的库文件拷贝至/usr/lib下。

要拷贝的文件如下:

拷贝命令:cp usr/lib64/ libfastcommon.so /usr/lib

或者切换到lib64目录下:

SecureCRT显示乱码的解决办法_心如猛虎细嗅蔷薇的博客-CSDN博客_securecrt 显示乱码   SecureCRT显示乱码的解决办法

将FastDFS_v5.05.tar.gz拷贝至/usr/local/下

tar -zxvf FastDFS_v5.05.tar.gz

cd FastDFS

./make.sh

./make.sh install

拷贝FastDFS/conf下面所有配置文件到etc/fdfs/

拷贝命令:[root@localhost conf]# cp * /etc/fdfs/

安装tracker,由于tracker运行程序就是fasfdfs,fastDFS安装成功,只需要修改etc/fdfs  tracker.conf配置文件即可。

修改tracker.conf

vi tracker.conf

修改base_path存储基本路径

将:base_path=/home/yuqing/fastdfs

改为:

base_path=/home/fastdfs

修改存在组

store_group=group1

配置http端口:

http.server_port=80

在home目录下创建fastdfs

创建命令:mkdir fastdfs

测试启动tracker

运行命令:/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

注意:如果没有显示上图要注意是否正常停止原有进程。

安装storage

由于storage和tracker运行的都是fastDFS程序,每一台服务器都部署一台fasfDFS,一台服务器是tracker,一台是storage。

此机器:tracker和fastDFS都是使用同一个程序。只需要配置storage配置文件即可。

配置storage.conf

配置组名

group_name=group1 //必须和tracker的组名相同。

配置基本存储路径base_path     

base_path=/home/fastdfs

配置文件存储路径

store_path0=/home/fastdfs/storage_path //storage_path需要手动创建

#store_path1=/home/yuqing/fastdfs2

如果有多个存储路径,就可以依次往下顺延。

修改连接tracker服务器地址

​​​​​​​tracker_server=192.168.248.120:22122

创建文件存储路径storage_path

​​​​​​​/home/fastdfs此目录下面创建   mkdir storage_path

启动storage测试

​​​​​​​启动命令:/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

​​​​​​​测试图片上传

Tracker和storage都已经安装完成,使用命令测试文件上传:

FastDFS提供一个文件上传命令:usr/bin/fdfs_test 测试文件上传

测试上传需要连接tracker服务器,连接storage服务器。

因此需要指定一个配置文件:client.conf配置文件,通过Client.conf连接tracker服务器。

第一步:修改Client.conf    vim client.conf

base_path=/home/yuqing/fastdfs改为:base_path=/home/fastdfs

修改 tracker_server

测试命令:/usr/bin/fdfs_test 客户端配置文件地址  upload  上传文件  

比如将/home下的图片上传到FastDFS中:

/usr/bin/fdfs_test /etc/fdfs/client.conf upload /home/FastDFS.png

example file url: http://192.168.248.120/group1/M00/00/00/wKj4eFx2pFaAQdfcAADG7Yype_Y236_big.png

就是文件的下载路径。

对应storage服务器上的/home/fastdfs/storage_path/data/00/00/wKj4eFx2pFaAQdfcAADG7Yype_Y236_big.png

由于现在还没有和nginx整合无法使用http下载。无法访问。

FastDFS-nginx-module整合nginx和fastDFS。

  1. 导入FastDFS-nginx-module到usr/local/

解压fastdfs-nginx-module_v1.16.tar.gz

tar -zxvf fastdfs-nginx-module_v1.16.tar.gz

修改config文件

vim config

将/usr/local/路径改为/usr/      注意:去掉错误路径,usr/local/include改为usr/include

拷贝mod_fastdfs.conf到etc/fdfs

cp mod_fastdfs.conf /etc/fdfs/

修改mod_fastdfs.conf

vim /etc/fdfs/mod_fastdfs.conf

​​​​​​​base_path=/home/fastdfs/storage_path //此处必须是存储路径

tracker_server=192.168.248.120:22122

url_have_group_name=true//允许使用组名

​​​​​​​store_path0=/home/fastdfs/storage_path //M00

​​​​​​​group_name=group1 //和前面配置组名保持一致

拷贝usr/lib64/libfdfsclient.so 库文件 到 usr/lib目录下。cp /usr/lib64/libfdfsclient.so /usr/lib/

安装Nginx

安装Nginx所需的pcre库

yum -y install pcre-devel


yum install -y zlib-devel

tar -zxvf nginx-1.8.0.tar.gz

cd nginx-1.8.0(进入解压目录中,执行下面的脚本)

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/usr/local/fastdfs-nginx-module/src

需要从新编译安装:

make


make install

修改nginx配置文件nginx.conf配置文件:

vim /usr/local/nginx/conf/nginx.conf

说明:

server_name指定本机ip

location /group1/M00/:group1为nginx 服务FastDFS的分组名称,M00是FastDFS自动生成编号,对应store_path0=/home/fastdfs/storage_path //M00  #####,如果FastDFS定义store_path1,这里就是M01#####

关闭防火墙

service iptables stop
chkconfig iptables off

/usr/local/nginx/sbin/nginx  // 启动Nginx

nginx: [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or directory)_心如猛虎细嗅蔷薇的博客-CSDN博客   nginx: [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or directory)

设置开机启动
vim /etc/rc.d/rc.local
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart
/usr/local/nginx/sbin/nginx

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值