更新脚本
parent
8723890f95
commit
5dc233fd79
|
@ -110,7 +110,7 @@ store_path_count=1
|
|||
store_path0=/home/fdfs
|
||||
#store_path1=/home/fdfs2
|
||||
|
||||
# subdir_count * subdir_count directories will be auto created under each
|
||||
# subdir_count * subdir_count directories will be auto created under each
|
||||
# store_path (disk), value can be 1 to 256, default value is 256
|
||||
subdir_count_per_path=256
|
||||
|
||||
|
@ -129,7 +129,7 @@ tracker_server=127.0.0.1:22122
|
|||
### debug
|
||||
log_level=info
|
||||
|
||||
#unix group name to run this program,
|
||||
#unix group name to run this program,
|
||||
#not set (empty) means run by the group of current user
|
||||
run_by_group=
|
||||
|
||||
|
@ -152,7 +152,7 @@ allow_hosts=*
|
|||
# 1: random, distributted by hash code
|
||||
file_distribute_path_mode=0
|
||||
|
||||
# valid when file_distribute_to_path is set to 0 (round robin),
|
||||
# valid when file_distribute_to_path is set to 0 (round robin),
|
||||
# when the written file count reaches this number, then rotate to next path
|
||||
# default value is 100
|
||||
file_distribute_rotate_count=100
|
||||
|
@ -210,8 +210,8 @@ key_namespace=FastDFS
|
|||
# default value is 0 (short connection)
|
||||
keep_alive=0
|
||||
|
||||
# you can use "#include filename" (not include double quotes) directive to
|
||||
# load FastDHT server list, when the filename is a relative path such as
|
||||
# you can use "#include filename" (not include double quotes) directive to
|
||||
# load FastDHT server list, when the filename is a relative path such as
|
||||
# pure filename, the base path is the base path of current/this config file.
|
||||
# must set FastDHT server list when check_file_duplicate is true / on
|
||||
# please see INSTALL of FastDHT for detail
|
||||
|
@ -282,5 +282,4 @@ connection_pool_max_idle_time = 3600
|
|||
http.domain_name=
|
||||
|
||||
# the port of the web server on this storage server
|
||||
http.server_port=9999
|
||||
|
||||
http.server_port=7001
|
||||
|
|
|
@ -71,8 +71,8 @@ store_path=0
|
|||
download_server=0
|
||||
|
||||
# reserved storage space for system or other applications.
|
||||
# if the free(available) space of any stoarge server in
|
||||
# a group <= reserved_storage_space,
|
||||
# if the free(available) space of any stoarge server in
|
||||
# a group <= reserved_storage_space,
|
||||
# no file can be uploaded to this group.
|
||||
# bytes unit can be one of follows:
|
||||
### G or g for gigabyte(GB)
|
||||
|
@ -93,7 +93,7 @@ reserved_storage_space = 10%
|
|||
### debug
|
||||
log_level=info
|
||||
|
||||
#unix group name to run this program,
|
||||
#unix group name to run this program,
|
||||
#not set (empty) means run by the group of current user
|
||||
run_by_group=
|
||||
|
||||
|
@ -139,7 +139,7 @@ storage_sync_file_max_time = 300
|
|||
# if use a trunk file to store several small files
|
||||
# default value is false
|
||||
# since V3.00
|
||||
use_trunk_file = false
|
||||
use_trunk_file = false
|
||||
|
||||
# the min slot size, should <= 4KB
|
||||
# default value is 256 bytes
|
||||
|
@ -174,7 +174,7 @@ trunk_create_file_time_base = 02:00
|
|||
trunk_create_file_interval = 86400
|
||||
|
||||
# the threshold to create trunk file
|
||||
# when the free trunk file size less than the threshold, will create
|
||||
# when the free trunk file size less than the threshold, will create
|
||||
# the trunk files
|
||||
# default value is 0
|
||||
# since V3.06
|
||||
|
@ -184,7 +184,7 @@ trunk_create_file_space_threshold = 20G
|
|||
# the occupied spaces will be ignored
|
||||
# default value is false
|
||||
# since V3.09
|
||||
# NOTICE: set this parameter to true will slow the loading of trunk spaces
|
||||
# NOTICE: set this parameter to true will slow the loading of trunk spaces
|
||||
# when startup. you should set this parameter to true when neccessary.
|
||||
trunk_init_check_occupying = false
|
||||
|
||||
|
@ -258,7 +258,7 @@ use_connection_pool = false
|
|||
connection_pool_max_idle_time = 3600
|
||||
|
||||
# HTTP port on this tracker server
|
||||
http.server_port=8080
|
||||
http.server_port=7000
|
||||
|
||||
# check storage HTTP server alive interval seconds
|
||||
# <= 0 for never check
|
||||
|
@ -266,7 +266,7 @@ http.server_port=8080
|
|||
http.check_alive_interval=30
|
||||
|
||||
# check storage HTTP server alive type, values are:
|
||||
# tcp : connect to the storge server with HTTP port only,
|
||||
# tcp : connect to the storge server with HTTP port only,
|
||||
# do not request and get response
|
||||
# http: storage check alive url must return http status 200
|
||||
# default value is tcp
|
||||
|
@ -275,4 +275,3 @@ http.check_alive_type=tcp
|
|||
# check storage HTTP server alive uri/url
|
||||
# NOTE: storage embed HTTP server support uri: /status.html
|
||||
http.check_alive_uri=/status.html
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
server {
|
||||
listen 7001; ## 该端口为storage.conf中的http.server_port相同
|
||||
server_name localhost;
|
||||
location ~/group[0-9]/ {
|
||||
ngx_fastdfs_module;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root html;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
worker_processes 1;
|
||||
|
||||
#error_log logs/error.log;
|
||||
#error_log logs/error.log notice;
|
||||
#error_log logs/error.log info;
|
||||
pid /usr/local/nginx/logs/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
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/nginx-http-access.log;
|
||||
sendfile on;
|
||||
rewrite_log on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
client_max_body_size 20m;
|
||||
client_body_buffer_size 128k;
|
||||
|
||||
#common header set
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
include mime.types;
|
||||
include conf/*.conf;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
[Unit]
|
||||
Description=The NGINX HTTP and reverse proxy server
|
||||
After=syslog.target network.target remote-fs.target nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/usr/local/nginx/logs/nginx.pid
|
||||
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
|
||||
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
|
||||
ExecReload=/usr/local/nginx/sbin/nginx -s reload
|
||||
ExecStop=/bin/kill -s QUIT $MAINPID
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
# console color
|
||||
BLACK="\033[1;30m"
|
||||
RED="\033[1;31m"
|
||||
GREEN="\033[1;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
BLUE="\033[1;34m"
|
||||
PURPLE="\033[1;35m"
|
||||
CYAN="\033[1;36m"
|
||||
RESET="$(tput sgr0)"
|
||||
##############################################################################
|
||||
|
||||
printf "${PURPLE}"
|
||||
cat << EOF
|
||||
|
||||
###################################################################################
|
||||
# 安装 FastDFS 脚本
|
||||
# FastDFS 会被安装到 /opt/fdfs 路径。
|
||||
# @system: 适用于 CentOS
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
EOF
|
||||
printf "${RESET}"
|
||||
|
||||
command -v yum >/dev/null 2>&1 || { echo >&2 -e "${RED}Require yum but it's not installed. Aborting.${RESET}"; exit 1; }
|
||||
command -v git >/dev/null 2>&1 || { echo >&2 -e "${RED}Require git but it's not installed. Aborting.${RESET}"; exit 1; }
|
||||
|
||||
yum install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y
|
||||
|
||||
root=/opt/fdfs
|
||||
if [[ -n $1 ]]; then
|
||||
root=$1
|
||||
fi
|
||||
|
||||
version=1.16.0
|
||||
if [[ -n $2 ]]; then
|
||||
version=$2
|
||||
fi
|
||||
|
||||
nginx_path=/opt/nginx
|
||||
if [[ -n $3 ]]; then
|
||||
root=$3
|
||||
fi
|
||||
|
||||
mkdir -p ${root}
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> 安装 libfastcommon${RESET}"
|
||||
mkdir -p ${root}/libfastcommon
|
||||
git clone https://github.com/happyfish100/libfastcommon.git "${root}/libfastcommon"
|
||||
cd ${root}/libfastcommon
|
||||
./make.sh && ./make.sh install
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> 安装 fastdfs${RESET}"
|
||||
mkdir -p ${root}/fastdfs
|
||||
git clone https://github.com/happyfish100/fastdfs.git "${root}/fastdfs"
|
||||
cd ${root}/fastdfs
|
||||
./make.sh && ./make.sh install
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> 安装 fastdfs-nginx-module${RESET}"
|
||||
mkdir -p ${root}/fastdfs-nginx-module
|
||||
git clone https://github.com/happyfish100/fastdfs-nginx-module.git "${root}/fastdfs-nginx-module"
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> 安装 nginx${RESET}"
|
||||
mkdir -p ${nginx_path}
|
||||
wget -O ${nginx_path}/nginx-${version}.tar.gz http://nginx.org/download/nginx-${version}.tar.gz
|
||||
tar zxf ${nginx_path}/nginx-${version}.tar.gz -C ${nginx_path}
|
||||
cd ${nginx_path}/nginx-${version}
|
||||
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --add-module=${root}/fastdfs-nginx-module/src/
|
||||
make && make install
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> fastdfs 配置文件准备${RESET}"
|
||||
# 配置修改参考:https://github.com/happyfish100/fastdfs/wiki
|
||||
|
||||
cp ${root}/fastdfs/conf/http.conf /etc/fdfs/ #供nginx访问使用
|
||||
cp ${root}/fastdfs/conf/mime.types /etc/fdfs/ #供nginx访问使用
|
||||
cp ${root}/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/fastdfs/tracker.conf -O /etc/fdfs/tracker.conf
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/fastdfs/storage.conf -O /etc/fdfs/storage.conf
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/fastdfs/client.conf -O /etc/fdfs/client.conf
|
||||
# fdfs 存储路径和服务端口(以默认形式配置)
|
||||
fdfs_store_path=/home/fdfs
|
||||
fdfs_server_port=7001
|
||||
ip=$(ip addr | awk '/^[0-9]+: / {}; /inet.*global/ {print gensub(/(.*)\/(.*)/, "\\1", "g", $2)}')
|
||||
echo -e "\n${GREEN} - 修改 tracker.conf 配置${RESET}"
|
||||
sed -i "s#^base_path=.*#base_path=${fdfs_store_path}#g" /etc/fdfs/tracker.conf
|
||||
echo -e "\n${GREEN} - 修改 storage.conf 配置${RESET}"
|
||||
sed -i "s#^base_path=.*#base_path=${fdfs_store_path}#g" /etc/fdfs/storage.conf
|
||||
sed -i "s#^store_path0=.*#store_path0=${fdfs_store_path}#g" /etc/fdfs/storage.conf
|
||||
sed -i "s#^tracker_server=.*#tracker_server=${ip}:22122#g" /etc/fdfs/storage.conf
|
||||
sed -i "s#^http.server_port=.*#http.server_port=${fdfs_server_port}#g" /etc/fdfs/storage.conf
|
||||
echo -e "\n${GREEN} - 修改 client.conf 配置${RESET}"
|
||||
sed -i "s#^base_path=.*#base_path=${fdfs_store_path}#g" /etc/fdfs/client.conf
|
||||
sed -i "s#^tracker_server=.*#tracker_server=${ip}:22122#g" /etc/fdfs/client.conf
|
||||
echo -e "\n${GREEN} - 修改 mod_fastdfs.conf 配置${RESET}"
|
||||
sed -i "s#^url_have_group_name=.*#url_have_group_name=true#g" /etc/fdfs/mod_fastdfs.conf
|
||||
sed -i "s#^tracker_server=.*#tracker_server=${ip}:22122#g" /etc/fdfs/mod_fastdfs.conf
|
||||
sed -i "s#^store_path0=.*#store_path0=${fdfs_store_path}#g" /etc/fdfs/mod_fastdfs.conf
|
||||
echo -e "\n${GREEN} - 修改 nginx.conf 配置${RESET}\n"
|
||||
mkdir -p /usr/local/nginx/conf/conf
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/nginx/nginx.conf -O /usr/local/nginx/conf/nginx.conf
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/nginx/conf/fdfs.conf -O /usr/local/nginx/conf/conf/fdfs.conf
|
||||
|
||||
echo -e "\n${GREEN}>>>>>>>>> 启动 fastdfs ${RESET}"
|
||||
/etc/init.d/fdfs_trackerd start #启动tracker服务
|
||||
#/etc/init.d/fdfs_trackerd restart #重启动tracker服务
|
||||
#/etc/init.d/fdfs_trackerd stop #停止tracker服务
|
||||
chkconfig fdfs_trackerd on #自启动tracker服务
|
||||
|
||||
/etc/init.d/fdfs_storaged start #启动storage服务
|
||||
#/etc/init.d/fdfs_storaged restart #重动storage服务
|
||||
#/etc/init.d/fdfs_storaged stop #停止动storage服务
|
||||
chkconfig fdfs_storaged on #自启动storage服务
|
||||
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/nginx/nginx.service -O /usr/lib/systemd/system/nginx.service
|
||||
chmod +x /usr/lib/systemd/system/nginx.service
|
||||
#设置nginx.service为系统服务
|
||||
systemctl enable nginx.service
|
||||
##通过系统服务操作nginx
|
||||
systemctl start nginx.service
|
||||
#systemctl reload nginx.service
|
||||
#systemctl restart nginx.service
|
||||
#systemctl stop nginx.service
|
||||
|
||||
echo -e "\n>>>>>>>>> add fastdfs port"
|
||||
firewall-cmd --zone=public --add-port=${fdfs_server_port}/tcp --permanent
|
||||
firewall-cmd --zone=public --add-port=22122/tcp --permanent
|
||||
firewall-cmd --reload
|
|
@ -41,5 +41,15 @@ tar zxf ${root}/nginx-${version}.tar.gz -C ${root}
|
|||
cd ${root}/nginx-${version}
|
||||
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
|
||||
make && make install
|
||||
/usr/local/nginx/sbin/nginx -v
|
||||
|
||||
# 设置 service
|
||||
wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/soft/config/nginx/nginx.service -O /usr/lib/systemd/system/nginx.service
|
||||
chmod +x /usr/lib/systemd/system/nginx.service
|
||||
#设置nginx.service为系统服务
|
||||
systemctl enable nginx.service
|
||||
##通过系统服务操作nginx
|
||||
systemctl start nginx.service
|
||||
#systemctl reload nginx.service
|
||||
#systemctl restart nginx.service
|
||||
#systemctl stop nginx.service
|
||||
cd -
|
||||
|
|
Loading…
Reference in New Issue