环境管理DFS分布式文件系统环境搭建.docx

上传人:b****2 文档编号:1039818 上传时间:2023-04-30 格式:DOCX 页数:37 大小:942.70KB
下载 相关 举报
环境管理DFS分布式文件系统环境搭建.docx_第1页
第1页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第2页
第2页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第3页
第3页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第4页
第4页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第5页
第5页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第6页
第6页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第7页
第7页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第8页
第8页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第9页
第9页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第10页
第10页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第11页
第11页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第12页
第12页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第13页
第13页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第14页
第14页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第15页
第15页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第16页
第16页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第17页
第17页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第18页
第18页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第19页
第19页 / 共37页
环境管理DFS分布式文件系统环境搭建.docx_第20页
第20页 / 共37页
亲,该文档总共37页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

环境管理DFS分布式文件系统环境搭建.docx

《环境管理DFS分布式文件系统环境搭建.docx》由会员分享,可在线阅读,更多相关《环境管理DFS分布式文件系统环境搭建.docx(37页珍藏版)》请在冰点文库上搜索。

环境管理DFS分布式文件系统环境搭建.docx

环境管理DFS分布式文件系统环境搭建

fastDFS环境搭建

1、单服务器搭建fastDFS环境

1.1环境

本文系统环境是LinuxCentOS6.5系统。

CentOS以root用户登陆,安装1个Tracker和1个Storage,不考虑复杂情况,后面再考虑搭建分布式环境以及性能优化。

#cat/proc/version,uname–a,cat/etc/issue

1.2工具

1.2.1服务器

Server1:

172.17.210.229

1.2.2相关压缩包

●fastdfs-5.08.tar.gz

●libfastcommon-1.0.13.tar.gz

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

1.3安装

将上述三个压缩包拷贝到/root/shitao/fastDFS目录下

1.3.1libfastcommon-1.0.13安装

∙解压缩并编译

1、解压:

#tarzxvflibfastcommon-1.0.7.tar.gz

2、切换到解压后文件夹:

#cdlibfastcommon-1.0.7

3、编译:

#./make.sh

一般编译libfastcommon辅助包不会存在问题,主要是会影响到fastdfs。

∙安装

1、#./make.shinstall

∙将/usr/lib64/libfastcommon.so文件向/usr/lib/下复制一份

1、#cp/usr/lib64/libfastcommon.so/usr/lib

1.3.2fastdfs-5.08安装

∙解压缩并编译

1、#tarzxvffastdfs-5.08.tar.gz

2、#cdfastdfs-5.08

3、#./make.sh

这里第一次安装时用的libfastcommon-1.0.7+fastdfs-5.08集成,在fastdfs-5.08编译时会发生错误,错误信息如下:

ibfastcommon-1.0.7改成较新版本libfastcommon-1.0.35,fastdfs-5.08编译正常。

∙安装

#./make.shinstall

安装后在/usr/bin/目录下有以fdfs开头的文件都是编译出来的;配置文件都放到/etc/fdfs文件夹。

把/root/FastDFS/conf目录下的所有的配置文件都复制到/etc/fdfs下(亦可通过配置/root/FastDFS/conf目录下的三个.sample的示例配置文件来配置。

这三个文件和/etc/fdfs下没有带后缀的同名文件,内容是一样的,并不影响)

#cp-r/root/shitao/fastDFS/fastdfs-5.08/conf/*/etc/fdfs/

主要包含一下文件:

anti-steal.jpgclient.confhttp.confmime.typesstorage.confstorage_ids.conftracker.conf

1.4服务配置

配置文件tracker.conf、storage.conf、client.conf需要授权才能读写,授权指令:

#chmod777***.conf

1.4.1tacker服务配置:

●Tracker.conf:

vim/etc/fdfs/tracker.conf

disabled=false

bind_addr=172.17.210.229

port=22122

base_path=/root/Data/fastdfs/tracker

1.4.2storage服务配置:

●Storage.conf:

vim/etc/fdfs/storage.conf

disable=fasle

group_name=group1

bind_addr=172.17.210.229

port=23000

buff_size=256KB

base_path=/root/Data/fastdfs/storage

base_path0=/root/Data/fastdfs/storage

tracker_server=172.17.210.229:

22122

1.4.3client服务配置:

●client.conf:

vim/etc/fdfs/client.conf

base_path=/root/Data/fastdfs/client

tracker_server=172.17.210.229:

22122

在启动storage时候,发现无法启动,/root/Data/fastdfs/storage目录下查看storage日志如下:

Storage需要配置group_name,以及存在buff_size过小,设置group_name=group1

,buff_size=256KB,完成后启动Storage,启动正常。

1.5服务启动

1.5.1tracker服务启动:

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

如果有文件夹不存在错误,则手动创建文件夹:

#mkdir-p/root/Data/fastdfs/tracker

1.5.2storage服务启动

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

1.5.3重启命令如下:

1、#/usr/bin/fdfs_trackerd/etc/fdfs/tracker.confrestart

2、#/usr/bin/fdfs_storaged/etc/fdfs/storage.confrestart

1.5.4停止命令如下:

1、#/usr/bin/fdfs_trackerd/etc/fdfs/tracker.confstop

2、#/usr/bin/fdfs_storaged/etc/fdfs/storage.confstop

1.5.4服务启动情况:

#netstat-unltp|grepfdfs

●查看客户端信息:

1、#fdfs_monitor/etc/fdfs/client.conf

如果提示/root/Data/fastdfs/client路径不存在,则需要手动创建。

●查看storage是否注册到tracker中:

#/usr/bin/fdfs_monitor/etc/fdfs/storage.conf

●设置开机启动:

#vim/etc/rc.d/rc.local

在开机启动中添加tracker服务或者storage重启命令,如下。

1.6上传下载测试:

这里我们使用fastDFS自带的测试图片进行测试,也可以自己自建文件。

1.6.1上传文件

Linux上传指令:

#/usr/bin/fdfs_test/etc/fdfs/client.confupload/etc/fdfs/conf/anti-steal.jpg

如下图所示上传成功:

1.6.2查看文件:

Linux查看指令:

#fdfs_file_info/etc/fdfs/client.confgroup1/M00/00/00/rBHS5VmSSVGAcJnCAABdrZgsqUU570_big.jpg

1.6.3下载文件

Linux下载指令:

#fdfs_download_file/etc/fdfs/client.confgroup1/M00/00/00/rBHS5VmSSVGAcJnCAABdrZgsqUU570_big.jpg

当我们在浏览器输入上传成功图片url时,发现浏览器无法访问此地址,如下图。

因为我们还缺少Nginx服务器提供http服务。

所以接下来需要安装Nginx相关软件,并做必要的配置。

1.7Nginx和fastdfs-nginx-module配置:

正式安装Nginx之前,需要确认下Linux系统是否有编译环境gccg++开发库,Centos下的g++安装包的名字叫做gcc-c++,这是与Centos与Ubuntu不同的地方。

安装命令如下:

#yuminstallgccgcc-c++

执行完该命令后,g++/gfortran都被安装成功了,或者更新需要执行更新。

安装Ngnix需要安装一些依赖lib包:

(1)pcre:

重写rewrite;

(2)zlib:

gzip压缩;

(3)openssl:

使用ssl;

1.7.1pcre安装

(1)下载:

(也可以通过Windows下载上传到Linux系统,用rz指令)

#wget 

(2)解压:

#tarzxvfpcre-8.41.tar.gz

(3)切换目录:

#cdpcre-8.41

(4)配置安装路径:

#./configure--prefix=/usr/local/related/pcre

(5)编译

#make

(6)安装

#makeinstall

1.7.2zlib安装

(1)下载:

(也可以通过Windows下载上传到Linux系统,用rz指令)

#wget

(2)解压:

#tarzxvfzlib-1.2.11.tar.gz

(3)切换目录:

#cdzlib-1.2.11

(4)配置安装路径:

#./configure--prefix=/usr/local/related/zlib

(5)编译

#make

(6)安装

#makeinstall

1.7.3openssl安装

(1)下载:

(也可以通过Windows下载上传到Linux系统,用rz指令)

#wgethttps:

//www.openssl.org/source/openssl-1.0.1t.tar.gz

(2)解压:

#tarzxvfopenssl-1.0.1t.tar.gz

(3)切换目录:

#cdopenssl-1.0.1t

(4)配置安装路径:

#./config--prefix=/usr/local/related/openssl

(5)编译

#make

(6)安装

#makeinstall

1.7.4fastdfs-nginx-module安装

首先下载fastdfs-nginx-module,下载地址:

解压fastdfs-nginx-module包,并修改fastdfs-nginx-module/src/config下配置文件,把其中的一共三处的local路径去掉。

(即删掉/local)

CORE_INCS="$CORE_INCS/usr/local/include/fastdfs/usr/local/include/fastcommon/"

改成

CORE_INCS="$CORE_INCS/usr/include/fastdfs/usr/include/fastcommon/"

这个是很重要的,不然在nginx编译的时候会报错的。

1、#tarzxvffastdfs-nginx-module_v1.16.tar.gz

2、#cpfastdfs-nginx-module/src/mod_fastdfs.conf/etc/fdfs/

3、#cd/etc/fdfs

4、#vimmod_fastdfs.conf

配置如下:

#thebasepathtostorelogfiles

base_path=/root/Data/fastdfs/storage/logs

#validonlywhenload_fdfs_parameters_from_trackeristrue

tracker_server=172.17.210.229:

22122

#theportofthelocalstorageserver

#thedefaultvalueis23000

storage_server_port=23000

#thegroupnameofthelocalstorageserver

group_name=group1

#iftheurl/uriincludingthegroupname

#settofalsewhenurilike/M00/00/00/xxx

#settotruewhenurilike${group_name}/M00/00/00/xxx,suchasgroup1/M00/xxx

#defaultvalueisfalse

url_have_group_name=true

#store_path#,based0,ifstore_path0notexists,it'svalueisbase_path

#thepathsmustbeexist

#mustsameasstorage.conf

store_path0=/root/Data/fastdfs/storage

然后进入FastDFS安装时的解压过的目录,将http.conf和mime.types拷贝到/etc/fdfs目录下:

1、cd/root/shitao/fastDFS/fastdfs-5.08/conf/

2、cphttp.conf/etc/fdfs/

3、cpmime.types/etc/fdfs/

在Nginx启动时,需要加载http.conf,不然会报错。

然后再按如下步骤安装Nginx(也可以先安装Nginx,再做fastdfs-nginx-module相关配置)。

1.7.5Nginx安装

(1)下载:

(也可以通过Windows下载上传到Linux系统,用rz指令)

#wgethttp:

//nginx.org/download/nginx-1.12.1.tar.gz

(2)解压:

#tarzxvfnginx-1.12.1.tar.gz

(3)切换目录:

#cdnginx-1.12.1

(4)配置安装路径:

#./configure--sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf--pid-path=/usr/local/nginx/nginx.pid--with-http_ssl_module--with-pcre=/root/shitao/fastDFS/pcre-8.41--with-zlib=/root/shitao/fastDFS/zlib-1.2.11--with-openssl=/root/shitao/fastDFS/openssl-1.0.1t--lock-path=/usr/lock/nginx.lock--error-log-path=/usr/log/nginx/error.log--http-log-path=/usr/log/nginx/access.log--with-http_gzip_static_module--http-client-body-temp-path=/usr/tmp/nginx/client--http-proxy-temp-path=/usr/tmp/nginx/proxy--http-fastcgi-temp-path=/usr/tmp/nginx/fastcgi--http-uwsgi-temp-path=/usr/tmp/nginx/uwsgi--http-scgi-temp-path=/usr/tmp/nginx/scgi--add-module=/root/shitao/fastDFS/fastdfs-nginx-module/src

备注:

/root/shitao/fastDFS/zlib-1.2.11是lib包的安装路径

这里注意需要添加fastdfs-nginx-module模块

--add-module=/root/shitao/fastDFS/fastdfs-nginx-module/src

(5)编译

#make

(6)安装

#makeinstall

●配置storagenginx:

在配置时更改了nginx相关的路径,如上图,这里配置文件的路径是:

/usr/local/nginx/nginx.conf,默认安装路径是:

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

1、#cd/usr/local/nginx

2、#vimnginx.conf

userroot;

server{

listen80;

server_namelocalhost;

location/group1/M00/{

root/root/Data/fastdfs/storage/data;

ngx_fastdfs_module;

}

}

配置文件中需要修改user权限为userroot,不然在启动Nginx会发生权限不够,启动失败。

如果发生mkdir()"/usr/tmp/nginx/client"failed(2:

Nosuchfileordirectory)这样错误,手动创建:

mkidr–p/usr/tmp/nginx/client文件夹即可。

●启动Nginx:

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

●查看Nginx进程:

#ps-ef|grepnginx

●测试Nginx

在浏览器输入服务器地址:

端口号,回车即可看到如下页面,说明Nginx配置成功。

上传图片测试:

使用fastdfs客户端上传一张图片至服务器:

指令如下:

#/usr/bin/fdfs_test/etc/fdfs/client.confupload/etc/fdfs/testpic/bede9491825e8bace1d5043caed018fa.jpg

上传成功fastDFS会返回图片具体信息,图片大小、上传时间、服务器地址、分组、储存的url路径等等信息,详细见下图。

在浏览器输入fastdfs返回的url地址:

http:

//172.17.210.229/group1/M00/00/00/rBHS5VmSwMWAYXajAABTH22sHOU188.jpg

浏览器:

2、分布式fastDFS系统搭建

在之前单服务搭建fastDFS系统中已经介绍如何搭建tracker和storage服务,现在有三台服务:

Server1:

172.17.210.217,作为tracker、Nginx负载均衡以及缓存;

Server2:

172.17.210.229,作为分组group_name=group1的storage;

Server3:

172.17.210.216,作为分组group_name=group2的storage2;

FastDFS分布式系统结构图,如下:

总共1台tracker,2台storage(2个group),在CentOS6.5下测试通过。

FastDFS使用5.08,nginx为1.12.1,nginxcachepurge为2.3。

2.1依赖包安装:

下载如下需要的软件包,前面第一节已经完成

FastDFS源代码:

fastdfs_v5.08.tar.gz

nginx模块源代码:

fastdfs-nginx-module_v1.16.tar.gz

nginx服务器源代码:

nginx-1.4.7.tar.gz

nginxcachepurge插件源代码:

ngx_cache_purge-2.3.tar.gz

nginx依赖的pcre库源代码:

pcre-8.41.tar.gz

nginx依赖的zlib库源代码:

zlib-1.2.11.tar.gz

nginx依赖的openssl库源代码:

openssl-1.0.1t.tar.gz

2.1tracker安装

在服务器上172.17.210.217上安装tracker,作为tracker服务器。

具体请参考1.3,1.4节tracker内容。

一般只需改动以下几个参数即可:

disabled=false#启用配置文件

port=22122#设置tracker的端口号

base_path=/root/data/fastdfs/tracker#设置tracker的数据文件和日志目录(需预先创建)

http.server_port=80#设置http端口号

●启动tracker之前需要关闭防火墙:

#serviceiptablesstatus#查看防火墙状态

#serviceiptablesstop#关闭防火墙

●启动tracker服务:

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

●查看tracker服务:

#netstat-unltp|grepfdfs

●查看tracker服务日志:

#cat/root/data/fastdfs/tracker/logs/trackerd.log

●设置开机启动:

#vim/etc/rc.d/rc.local

在开机启动中添加tracker服务重启命令,如下。

2.3stroage安装

在服务器上172.17.210.216、172.17.210.229上分别安装storage,作为storage服务器。

具体请参考1.3,1.4节storage内容。

172.17.210.229作为group1,配置文件如下:

disabled=false

group_name=group1

port=23000

base_path=/root/Data/fastdfs/storage

store_path0=/root/Data/fastdfs/storage

tracker_server=172.17.210.217:

22122#tracker服务器ip,端口号

http.server_

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2