fastdfs集群部署
来源:互联网 发布:淘宝店铺类别 编辑:程序博客网 时间:2024/06/13 13:14
fastdfs集群部署
准备工作:
fastdfs-5.10.tar.gz
https://github.com/happyfish100/fastdfs/archive/V5.10.tar.gz
fastdfs-nginx-module_v1.16.tar.gz
https://nchc.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.16.tar.gz
libevent-2.0.22-stable.tar.gz
https://github.com/libevent/libevent/archive/release-2.0.22-stable.tar.gz
libfastcommon.zip 下载地址
https://github.com/happyfish100/libfastcommon/archive/V1.0.35.tar.gz
nginx-1.13.2.tar.gz
http://nginx.org/download/nginx-1.13.2.tar.gz
pcre-8.40.tar.gz
https://nchc.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz
安装:libfastcommon
解压libfastcommon
unzip libfastcommon.zip
安装 libfastcommon
cd libfastcommon/
./make.sh
./make.sh install
添加软链接
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
安装:libevent
解压libevent
tar -zxvf libevent-2.0.22-stable.tar.gz
安装 libevent
cd libevent/
./configure --prefix=/usr/local/
make clean
make && make install
添加软链接
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
安装:pcre
解压pcre到指定目录
tar -zxvf pcre-8.40.tar.gz
安装:fastdfs
解压fastdfs
tar -zxvf fastdfs-5.10.tar.gz
安装 fastdfs
cd fastdfs-5.10/
./make.sh
./make.sh install
文件存储目录
mkdir -p /var/fastdfs/tracker
mkdir -p /var/fastdfs/storage
mkdir -p /var/fastdfs/client
修改配置文件
cd /etc/fdfs/
#查看目录下文件是否齐全,应该有client.conf http.conf mime.types storage.conf tracker.conf 5个文件,如果没有,libevent安装有问题
vim /etc/fdfs/tracker.conf #编辑tracker配置文件
disabled=false #启用配置文件
bind_addr= #解析主机地址,空则解析所有主机
port=22122 #tracker服务端口
connect_timeout=30 #连接超时时间30S
network_timeout=60 #网络超时时间60S
base_path=/var/fastdfs/tracker #tracker基础数据存储路径及日志存放路径
max_connections=256 #最大并发连接数
work_threads=4 #工作线程数,最好和cpu核数保持一致
store_lookup=0 #选择上传文件模式0代表group轮询1指定特定group 2选择空间最大的group
#store_group= #上传文件组,如果模式为1,则必须设置成核特定group一致的组名
store_server=0 #选择存储服务器上传文件0代表轮询,1根据通过IP第的顺序2通过优先级
store_path=0 #选择哪块存储盘上传文件0代表轮询,2代表优先最大存储空间盘(路径)
download_server=0 #选择哪台存储服务器下载文件0代表轮询,1代表当前文件上传的源服务器
reserved_storage_space = 10% #系统保留存储空间10%
vim /etc/fdfs/storage.conf #编辑存储配置文件
group_name=group1 #存储组名
client_bind=true #当连接其他服务器时解析该主机地址
port=23000 #storage端口23000
base_path=/var/fastdfs/storage #基础存储数据和日志文件
store_path0=/usr/share/fastdfs/storage #group所占用的目录或硬盘,有几个写几个
tracker_server=172.18.4.217:22122 #指定tracker1服务器
tracker_server=172.18.4.218:22122 #指定tracker2服务器
vim /etc/fdfs/client.conf
base_path=/var/fastdfs/client #基础数据和日志文件
tracker_server=fastfds01:22122 #tracker1服务器
tracker_server=fastfds02:22122 #tracker2服务器
安装:fastdfs-nginx-module
解压fastdfs-nginx-module
tar -zxvf fastdfs-nginx-module_v1.16.tar.gz
配置 fastdfs-nginx-module
cp mod_fastdfs.conf /etc/fdfs/
#将mod_fastdfs.conf拷贝到fdfs下进行配置
文件存储目录
mkdir -p /var/fastdfs/tracker
mkdir -p /var/fastdfs/storage
mkdir -p /var/fastdfs/client
修改配置文件
vim /etc/fdfs/mod_fastdfs.conf #编辑tracker配置文件
base_path=/var/fastdfs/storage #修改成和storage存放路径一致
tracker_server=fastdfs01:22122 #配置成tracker server地址和端口
url_have_group_name = true #url 中是否包组名
store_path0=/var/fastdfs/storage #文件存放路径,与storage一致
group_count = 0 #0代表单组,非零代表多组,一般设置几就为几组
group_count = 1
group_name=group1
storage_server_port=23000
store_path_count=1
store_path0=/var/fastdfs/storage
安装:nginx
解压nginx
tar -zxvf nginx-1.13.2.tar.gz
安装 nginx
cd nginx-1.13.2
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre-8.12 --add-module=/usr/local/fastdfs-nginx-module/src
make #编译错误 出现make[1]: * [objs/addon/src/ngx_http_fastdfs_module.o] Error 1
vi /usr/local/fastdfs-nginx-module/src/config
去掉local
CORE_INCS="$CORE_INCS /usr/local/fastdfs/include/fastdfs /usr/local/fastdfs/include/fastcommon/"
CORE_LIBS="$CORE_LIBS -L/usr/lib -lfastcommon -lfdfsclient"
make install
修改配置文件
vim /usr/local/nginx/nginx.conf#编辑nginx配置文件
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
error_log /usr/local/nginx/logs/error.log;
pid /usr/local/nginx/logs/nginx.pid;
http {
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /usr/local/nginx/logs/access.log main;
upstream fdfs_group1 {
server rocketmq01:8080 weight=1 max_fails=2 fail_timeout=30s;
}
upstream fdfs_group2 {
server rocketmq02:8080 weight=1 max_fails=2 fail_timeout=30s;
}
include /usr/local/nginx/conf.d/*.conf;
}
vim /usr/local/nginx/conf.d/storage.conf#编辑storage配置文件
server {
listen 8080;
server_name rocketmq01;
location ~ /group01/M00 {
root /var/fastdfs/storage/data;
index index.html index.htm;
ngx_fastdfs_module;
}
}
vim /usr/local/nginx/conf.d/tracker.conf#编辑tracker配置文件
server {
listen 80;
server_name rocketmq01;
location ~ /group01/M00 {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://fdfs_group1;
expires 30d;
}
location ~ /group02/M00 {
proxy_next_upstream http_502 http_504 error timeout invalid_header;
proxy_pass http://fdfs_group2;
expires 30d;
}
}
启动 nginx
cd nginx
./sbin/nginx -c conf/nginx.conf
#启动错误 出现http.conf找不到
拷贝fastdfs/conf下面的http.conf与mime.types到/etc/fdfs/目录
重新启动
添加数据链接
ln -s /var/fastdfs/storage/data /var/fastdfs/storage/data/M00
命令:
#tracker命定
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start/stop/restart
#storage命定
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start/stop/restart
测试:
/usr/bin/fdfs_test /etc/fdfs/client.conf upload /opt/1.txt
#返回结果中会把上传完成的url打印出来,看三个上传的url group是否轮询变化,如果停掉fastdfs01 的tracker返回url是不是地址变成fastdfs02,如都成功则复制URL在浏览器中打开看是否正常
- FastDFS之集群部署
- fastdfs集群部署
- FastDFS使用小结(单节点部署和集群部署)
- centOs7.0 下部署 fastdfs 集群 并配置负载均衡
- fastdfs集群配置
- FastDFS集群服务器搭建
- fastdfs集群的安装
- fastdfs集群搭建
- fastDfS集群(8节点)
- CentOS安装FastDFS集群
- FastDFS集群搭建
- 安装部署fastdfs
- FastDFS安装与部署
- fastdfs + nginx 安装部署
- FastDFS + nginx 单点部署
- 单机安装部署FastDFS
- FastDFS安装部署文档
- FastDFS : 开启钻牛角尖模式搞FastDFS集群
- 允许api支持跨域方法
- 日志数据的关键字统计与报警实践指南
- 任意文件下载
- JSP中out.print()、out.println()以及out.write()的区别
- jmeter基础概念
- fastdfs集群部署
- Spring配置多数据源以及基于Atomikos的事务一致性配置
- 在11g中使用ASM功能实现两个存储做镜像的方法
- C#反射动态调用dll中的方法及使用QuartZ.net实现作业调度
- 写给自己的Java程序员学习路线图
- 注解式开发
- json调用
- android6.0屏蔽声音加减
- TF Learn入门 —— 简单使用举例