FastDFS分布式文件系统环境介绍
系统:centos6.5_64_mini
FastDFS版本:FastDFS_v5.01
实验节点如下:(注:以下两个节点的安装及配置完全相同)
SERVER1 IP:192.168.100.250
SERVER2 IP:192.168.100.251
1:安装定时同步相关
# yum install -y ntpdate
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# ntpdate us.pool.ntp.org2:配置时间同步
# crontab -e3:输入以下代码
*/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP4:安装相关依赖包
# yum -y install gcc gcc-c++ openssl openssl-devel pcre-devel perl wget
# mkdir /yunwei8/soft# cd /yunwei8/soft
5:下载所需的安装包至soft文件夹下
# wget http://down.yunwei8.com/soft/linux/libevent-2.0.21-stable.tar.gz
# wget http://down.yunwei8.com/soft/linux/FastDFS_v5.01.tar.gz
# wget http://down.yunwei8.com/soft/linux/fastdfs-nginx-module_v1.15.tar.gz
# wget http://down.yunwei8.com/soft/linux/nginx-1.6.0.tar.gz6:删除自带libevent
# rpm -qa libevent
# rpm -e --nodeps libevent-1.4.13-4.el6.x86_64
7:安装libevent-2.0.21
# cd /yunwei8/soft/
# tar -zxvf libevent-2.0.21-stable.tar.gz
# cd libevent-2.0.21-stable
# ./configure
# make && make install
8:为libevent创建软链接到/lib库下,64位系统对应/lib64
# ln -s /usr/local/lib/libevent* /lib64/
# ln -s /usr/local/lib/libevent* /lib/9:安装FastDFS_v5.01
# cd /yunwei8/soft
# tar -zxvf FastDFS_v5.01.tar.gz
# cd FastDFS/
# ./make.sh
# ./make.sh install10:配置跟踪器tracker server
10.1建立文件夹
# mkdir -p /yunwei8/data/fastdfs
10.2修改tracker参数,找到base_path=/home/yuqing/fastdfs修改如下
# vi /etc/fdfs/tracker.confbase_path=/yunwei8/data/fastdfs
11:启动tracker服务
# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
# echo '/usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf' >> /etc/rc.local12:配置存储服务storage server,并修改相关参数
# mkdir -p /yunwei8/data/fastdfs 注:(若tracker和storage在不同服务器则需建立)
# mkdir /yunwei8/data/p_w_picpaths
# vi /etc/fdfs/storage.conf找到base_path=/home/yuqing/fastdfs,修改如下
base_path=/yunwei8/data/fastdfs
找到store_path0=/home/yuqing/fastdfs,修改如下
store_path0=/yunwei8/data/p_w_picpaths找到tracker_server=192.168.209.121:22122,修改如下
tracker_server=192.168.100.251:22122
tracker_server=192.168.100.250:22122
13:启动storage服务
# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
会显示一长串如下的内容
mkdir data path: 00 ...
mkdir data path: 01 ...
mkdir data path: 02 ...
mkdir data path: 03 ...
mkdir data path: 04 ...
mkdir data path: 05 ...
mkdir data path: 06 ...写入开机自启动
# echo '/usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf' >> /etc/rc.local14:在storage server安装nginx模块
# cd /yunwei8/soft/
# tar -zxvf fastdfs-nginx-module_v1.15.tar.gz
# tar -zxvf nginx-1.6.0.tar.gz
# cd nginx-1.6.0
# ./configure --prefix=/yunwei8/server/nginx --add-module=../fastdfs-nginx-module/src# make && make install
15:修改nginx参数配置如下
# vi /yunwei8/server/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 {
alias /data/p_w_picpaths/data;
ngx_fastdfs_module;
}
}
}16:编写nginx 启动脚本
# vi /etc/init.d/nginx输入以下代码并保存
#!/bin/sh## nginx - this script starts and stops the nginx daemin## chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \# proxy and IMAP/POP3 proxy server# processname: nginx# config: /yunwei8/server/nginx/conf/nginx.conf# pidfile: /yunwei8/server/nginx/logs/nginx.pid # Source function library.. /etc/rc.d/init.d/functions # Source networking configuration.. /etc/sysconfig/network # Check that networking is up.[ "$NETWORKING" = "no" ] && exit 0 nginx="/yunwei8/server/nginx/sbin/nginx"prog=$(basename $nginx) NGINX_CONF_FILE="/yunwei8/server/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval} stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval} restart() { configtest || return $? stop start} reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo} configtest() { $nginx -t -c $NGINX_CONF_FILE} rh_status() { status $prog} rh_status_q() { rh_status >/dev/null 2>&1} case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" exit 2esac
17:保存后,设置权限并添加到启动服务列表中
# chmod 755 /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig --level 345 nginx on
18:启动nginx服务
# service nginx start
19:给storage的存储目录做一个软连接
# ln -s /yunwei8/data/p_w_picpaths/data/ /yunwei8/data/p_w_picpaths/data/M00
20:拷贝mod_fastdfs.conf到/etc/fdfs/
# cp /yunwei8/soft/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
21:修改mod_fastdfs.conf配置
# vi /etc/fdfs/mod_fastdfs.conf找到base_path=/tmp,修改为如下
base_path=/yunwei8/data/fastdfs找到store_path0=/home/yuqing/fastdfs,修改如下
store_path0=/yunwei8/data/p_w_picpaths找到url_have_group_name = fasle,修改如下
url_have_group_name = true
找到tracker_server=tracker:22122,修改如下
tracker_server=192.168.100.251:22122
tracker_server=192.168.100.250:22122
22:在tracker server上配置client# vi /etc/fdfs/client.conf
修改client参数,找到base_path=/home/yuqing/fastdfs,修改如下
base_path=/yunwei8/data/fastdfs找到tracker_server=192.168.0.197:22122,修改如下
tracker_server=192.168.100.250:22122
tracker_server=192.168.100.251:2212223:防火墙开放相应端口
# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# /sbin/iptables -I INPUT -p tcp --dport 22122-j ACCEPT
# /etc/rc.d/init.d/iptables save
24:创建测试文件
# cd /yunwei8/创建网页名为yunwei8.html
# vi yuwnei8.html输入网页内容
yunwei825:退出和重启
25.1退出
直接kill即可让server进程正常退出,可以使用killall命令,例如:
# killall fdfs_trackerd
# killall fdfs_storaged也可以使用FastDFS自带的stop.sh脚本,如:
# /usr/local/bin/stop.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
# /usr/local/bin/stop.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
stop.sh只会停止命令行(包括参数)完全相同的进程。
千万不要使用-9参数强杀,否则可能会导致binlog数据丢失的问题。25.2重启
可以kill掉server进程后,执行启动命令行。如:
# killall fdfs_trackerd# killall fdfs_storaged
# /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf# /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
或者直接使用FastDFS自带的restart.sh脚本,如:
# /usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf# /usr/local/bin/restart.sh /usr/local/bin/fdfs_storaged /etc/fdfs/storage.conf
26:上传测试 /usr/local/bin/restart.sh /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
# /usr/local/bin/fdfs_test /etc/fdfs/client.conf upload /yunwei8/yunwei8.html (绝对路径)
27:访问上传输出的测试地址
http://192.168.100.250/group1/M00/00/00/wKhk-lNC56-ABoAZAAAAd6SYAsE45_yunwei8.html
http://192.168.100.251/group1/M00/00/00/wKhk-lNC56-ABoAZAAAAd6SYAsE45_yunwei8.html
centos6.5下搭建fastdfs分布式存储
精选 转载上一篇:Nginx+Tomcat+Memcached 实现集群部署时Session共享
下一篇:实战 Centos6.5下 Nginx-1.6.0 +keepalived-1.2.12 +tomcat-7.0.54 实现高可用+负载均衡
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群
分布式存储 CentOS6.5虚拟机环境搭建FastDFS-5.0.5集群
安装配置 fastDFS cenost -
分布式文件存储-FastDFS环境搭建
FastDFS是什么?我们这里可以看一下度娘的解释。FastDFS是一个开源的轻量级分布式文件
FastDfs nginx 服务器 默认值 -
Linux 搭建分布式文件存储FastDFS
分布式文件存储FastDFS软件下载安装FastDFS1. 上传文件到2. 安装依赖安装FastDFS启动tracker启动storage安装FastDFS的Nginx模块安装Nginx关闭防火墙spring Cloud 整合文件存储微服务添加依赖FastDFS配置application.yml配置文件上传软件下载链接:https://pan.baidu.com/s/1Cle7VaKBUce6K3xxBFcxFg提取码:737r安装FastDFS1. 上传文件到将资料中的文件上传到linux下的
linux fastdfs nginx 文件上传 spring