centOs7.0 下部署 fastdfs 集群 并配置负载均衡

4台机器 129 tracker 130、131storage 132nginx负载均衡

1、先下载安装libfastcommon类库

wget https://github.com/happyfish100/libfastcommon/archive/master.zip 
unzip master.zip 
cd libfastcommon-master 
./make.sh 
./make.sh install

2、安装fastdfs

wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz 
tar -zxvf V5.05.tar.gz 
cd fastdfs-5.05/ 
./make.sh 
./make.sh install

3、配置storage 130、131

cd /etc/fdfs/
mv storage.conf.sample storage.conf
vi storage.conf 
    base_path=/data/fastdfs
    store_path0=/data/fastdfs
    tracker_server=192.168.1.129:22122
mkdir /data/fastdfs
/bin/fdfs_storaged /etc/fdfs/storage.conf 

4、配置tracker

cd /etc/fdfs/
mv tracker.conf.sample tracker.conf
vi tracker.conf 
    base_path=/data/fastdfs
mkdir /data/fastdfs
/bin/fdfs_trackerd /etc/fdfs/tracker.conf 

3、安装nginx

wget http://jaist.dl.sourceforge.net/project/fastdfs/FastDFS%20Nginx%20Module%20Source%20Code/fastdfs-nginx-module_v1.15.tar.gz 
tar -zxvf fastdfs-nginx-module_v1.15.tar.gz 
wget http://nginx.org/download/nginx-1.6.3.tar.gz 可自行到官网下载最新的 必须是这个版本下的 Legacy versions
tar -zxvf nginx-1.6.3.tar.gz 
mv nginx-1.6.3 nginx
cd nginx/
yum install pcre-devel openssl openssl-devel
./configure --prefix=/data/nginx --with-http_stub_status_module --add-module=/usr/local/fastdfs-nginx-module/src
make
make install

4、配置nginx和fastdfs

cd /etc/fdfs/
cp /data/nginx/conf/mime.types /etc/fdfs/
cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/http.conf /etc/fdfs/

修改配置文件

vi mod_fastdfs.conf 
connect_timeout=10
base_path=/data/fastdfs
tracker_server=192.168.1.129:22122
store_path0=/data/fastdfs
url_have_group_name = true
cd /data/nginx/
vi ./conf/nginx.conf

在server块中添加

location /group1/M00/ {
 root /data/fastdfs/data;
 ngx_fastdfs_module;
}

5、启动nginx

./sbin/nginx 

6、负载均衡处理 132机器

wget http://nginx.org/download/nginx-1.6.3.tar.gz
tar -zxvf nginx-1.6.3.tar.gz 
mv nginx-1.6.3 nginx
cd nginx/
./configure --prefix=/data/nginx --with-http_stub_status_module
vi /data/nginx/conf/nginx.conf
    worker_processes  2;
    events {
        use epoll;
        worker_connections  1024;
    }

http{}中添加

upstream mysvr {
        server 192.168.1.130:80 weight=5;
        server 192.168.1.131:80 weight=5;
    }  

server中添加

     location / {
            proxy_pass http://mysvr;
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
            client_max_body_size 10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_buffer_size 4k;
            proxy_buffers 4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
            proxy_read_timeout 90;
            proxy_send_timeout 90;
        }
    location /NginxStatus {
        stub_status on;
        access_log on;
        auth_basic "NginxStatus";
    }

最后启动nginx。负载均衡在这也算是配置好了。这里只是用来记录下我的大致配置过程。其他的也就不详细叙述了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值