fastDFS快速部署

自己学习分布式文件系统,部署时找到了这个最快捷的方式,感谢大佬 陈旭猿
原博客地址:https://blog.csdn.net/q1298252589/article/details/104534792/
特此只为保留方便以后使用

#!/bin/bash
#关闭防火墙
systemctl stop firewalld.service

#安装编译环境
yum install -y git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim
#创建数据存储目录
data_path=/data/dfs
mkdir -p ${data_path}

#下载包存放目录
cd /usr/local/src
#安装libfatscommon
git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
#编译安装
./make.sh && ./make.sh install

cd ../

#安装fastdfs
git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
#编译安装
./make.sh && ./make.sh install
#配置文件准备
cp /etc/fdfs/tracker.conf.sample /etc/fdfs/tracker.conf
cp /etc/fdfs/storage.conf.sample /etc/fdfs/storage.conf
#客户端文件
cp /etc/fdfs/client.conf.sample /etc/fdfs/client.conf
#供nginx访问使用
cp /usr/local/src/fastdfs/conf/http.conf /etc/fdfs/
#供nginx访问使用
cp /usr/local/src/fastdfs/conf/mime.types /etc/fdfs/

cd ../

#安装fastdfs-nginx-module
git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

#安装nginx
wget http://nginx.org/download/nginx-1.15.4.tar.gz
#解压
tar -zxvf nginx-1.15.4.tar.gz
cd nginx-1.15.4/
#添加fastdfs-nginx-module模块
./configure --add-module=/usr/local/src/fastdfs-nginx-module/src/
#编译安装
make && make install

#内网ip
ip=`ip addr|grep inet|grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|grep -v 127.0.0.1|head -n 1`

#tracker配置
sed -i 's#/home/yuqing/fastdfs#'$data_path'#g' /etc/fdfs/tracker.conf

#storage配置
sed -i 's#/home/yuqing/fastdfs#'$data_path'#g' /etc/fdfs/storage.conf
sed -i 's#192.168.209.121#'$ip'#g' /etc/fdfs/storage.conf
sed -i 's#tracker_server = 192.168.209.122:22122#''#g' /etc/fdfs/storage.conf

#配置client
sed -i 's#/home/yuqing/fastdfs#'$data_path'#g' /etc/fdfs/client.conf
sed -i 's#192.168.0.196#'$ip'#g' /etc/fdfs/client.conf
sed -i 's#tracker_server = 192.168.0.197:22122#''#g' /etc/fdfs/client.conf

#配置nginx访问
sed -i 's#base_path=/tmp#base_path='$data_path'#g' /etc/fdfs/mod_fastdfs.conf
sed -i 's#tracker_server=tracker:22122#tracker_server='$ip':22122#g' /etc/fdfs/mod_fastdfs.conf
sed -i 's#url_have_group_name = false#url_have_group_name = true#g' /etc/fdfs/mod_fastdfs.conf
sed -i 's#store_path0=/home/yuqing/fastdfs#store_path0='$data_path'#g' /etc/fdfs/mod_fastdfs.conf

echo '#user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    #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  logs/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    gzip  on;
    server {
        listen       8888;
        server_name  localhost;
        #access_log  logs/host.access.log  main;
        location ~/group[0-9]/ {
            ngx_fastdfs_module;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}' > /usr/local/nginx/conf/nginx.conf

systemctl daemon-reload

#启动tracker
/etc/init.d/fdfs_trackerd start
#启动storage
/etc/init.d/fdfs_storaged start
#启动nginx
/usr/local/nginx/sbin/nginx

#查看启动状态
ps -aux | grep fdfs_trackerd
ps -aux | grep fdfs_storaged
ps -aux | grep nginx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值