update scripts
parent
2b73cbc127
commit
b3290172d3
|
@ -11,6 +11,8 @@
|
|||
## 软件运维
|
||||
|
||||
> 本章节内容介绍日常开发中常见的一些软件、工具的安装、配置。
|
||||
>
|
||||
> 配套安装脚本:🐚 [软件运维配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft)
|
||||
|
||||
- 开发环境
|
||||
- [JDK 安装](docs/linux/soft/jdk-install.md)
|
||||
|
@ -38,7 +40,6 @@
|
|||
## 运维和脚本
|
||||
|
||||
- [系统运维脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/sys)
|
||||
- [软件运维配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft)
|
||||
- [工具脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft)
|
||||
- [Vim 应用指南](docs/linux/ops/vim.md)
|
||||
- [Zsh 应用指南](docs/linux/ops/zsh.md)
|
||||
|
|
|
@ -97,36 +97,33 @@ wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/mo
|
|||
|
||||
## Redis 安装配置
|
||||
|
||||
说明:
|
||||
**安装说明**
|
||||
|
||||
- 下载 redis `5.0.4` 并解压安装到 `/opt/redis` 路径下。
|
||||
- 替换配置,使得 Redis 可以远程访问,并设置默认密码为 123456。
|
||||
- 注册 redis 服务,并设置为开机自启动
|
||||
- 采用编译方式安装 Redis, 并将其注册为 systemd 服务
|
||||
- 安装路径为:`/usr/local/redis`
|
||||
- 默认下载安装 `5.0.4` 版本,端口号为:`6379`,密码为空
|
||||
|
||||
使用方法:
|
||||
**使用方法**
|
||||
|
||||
执行以下任意命令即可按照默认配置安装脚本。
|
||||
- 默认安装 - 执行以下任意命令即可:
|
||||
|
||||
```sh
|
||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/redis-install.sh | bash
|
||||
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/redis-install.sh | bash
|
||||
```
|
||||
|
||||
定制化配置
|
||||
- 自定义安装 - 下载脚本到本地,并按照以下格式执行:
|
||||
|
||||
|
||||
```sh
|
||||
# 下载脚本到本地
|
||||
wget https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/redis-install.sh
|
||||
chmod +x redis-install.sh
|
||||
./redis-install.sh 5.0.4 /opt/redis 6379 123456
|
||||
sh redis-install.sh [version] [port] [password]
|
||||
```
|
||||
|
||||
说明:
|
||||
参数说明:
|
||||
|
||||
- 第一个参数是 redis 版本号;
|
||||
- 第二个参数是 redis 安装路径;
|
||||
- 第三个参数是 redis 服务端口号;
|
||||
- 第四个参数是访问密码
|
||||
- `version` - redis 版本号
|
||||
- `port` - redis 服务端口号
|
||||
- `password` - 访问密码
|
||||
|
||||
## Tomcat8 安装
|
||||
|
||||
|
@ -195,19 +192,28 @@ wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/zo
|
|||
|
||||
## Nginx 安装
|
||||
|
||||
说明:
|
||||
**安装说明**
|
||||
|
||||
采用编译方式安装 Nginx
|
||||
- 采用编译方式安装 Nginx, 并将其注册为 systemd 服务
|
||||
- 安装路径为:`/usr/local/nginx`
|
||||
- 默认下载安装 `1.16.0` 版本
|
||||
|
||||
下载 nginx `1.16.0` 并解压安装到 `/opt/nginx` 路径下。
|
||||
**使用方法**
|
||||
|
||||
- 默认安装 - 执行以下任意命令即可:
|
||||
|
||||
使用方法:执行以下任意命令即可执行脚本。
|
||||
|
||||
```sh
|
||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/nginx-install.sh | bash
|
||||
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/nginx-install.sh | bash
|
||||
```
|
||||
|
||||
- 自定义安装 - 下载脚本到本地,并按照以下格式执行:
|
||||
|
||||
```bash
|
||||
sh nginx-install.sh [version]
|
||||
```
|
||||
|
||||
## Fastdfs 安装
|
||||
|
||||
说明:
|
||||
|
|
|
@ -85,7 +85,7 @@ bind 0.0.0.0
|
|||
# you are sure you want clients from other hosts to connect to Redis
|
||||
# even if no authentication is configured, nor a specific set of interfaces
|
||||
# are explicitly listed using the "bind" directive.
|
||||
protected-mode yes
|
||||
protected-mode no
|
||||
|
||||
# Accept connections on the specified port, default is 6379 (IANA #815344).
|
||||
# If port 0 is specified Redis will not listen on a TCP socket.
|
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Redis
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
PIDFile=/var/run/redis_6379.pid
|
||||
ExecStart=/usr/local/bin/redis-server /usr/local/redis/redis.conf
|
||||
ExecReload=/bin/kill -s HUP $MAINPID
|
||||
ExecStop=/bin/kill -s QUIT $MAINPID
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 nginx 脚本
|
||||
# 仅适用于 CentOS 发行版本。
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install nginx"
|
||||
|
||||
# Centos7 rpm 地址:http://nginx.org/packages/rhel/7/x86_64/RPMS/
|
||||
# CentOS6 rpm 地址:http://nginx.org/packages/rhel/6/x86_64/RPMS/
|
||||
|
||||
mkdir -p /opt/nginx
|
||||
curl -o /opt/nginx/nginx.rpm http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.14.0-1.el7_4.ngx.x86_64.rpm
|
||||
rpm -ivh /opt/nginx/nginx.rpm
|
||||
nginx -v
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 nginx 脚本
|
||||
# 仅适用于 CentOS 发行版本。
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install nginx"
|
||||
|
||||
yum -y install make nginx.x86_64
|
|
@ -12,68 +12,70 @@ CYAN="\033[1;36m"
|
|||
RESET="$(tput sgr0)"
|
||||
###################################################################################
|
||||
|
||||
printf "${BLUE}"
|
||||
printf "${BLUE}\n"
|
||||
cat << EOF
|
||||
|
||||
###################################################################################
|
||||
# 采用编译方式安装 nginx 脚本
|
||||
# nginx 会被安装到 /usr/local/nginx 路径。
|
||||
# @system: 适用于所有 linux 发行版本。
|
||||
# 采用编译方式安装 Nginx, 并将其注册为 systemd 服务
|
||||
# 默认下载安装 1.16.0 版本,安装路径为:/usr/local/nginx
|
||||
# @system: 适用于 CentOS7+
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
EOF
|
||||
printf "${RESET}"
|
||||
printf "${RESET}\n"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install maven begin.${RESET}\n"
|
||||
command -v yum > /dev/null 2>&1 || {
|
||||
printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
printf "\n${GREEN}>>>>>>>> install nginx begin${RESET}\n"
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]]; then
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
printf "\t sh nginx-install.sh [version] [path]\n"
|
||||
printf "\t Example: sh nginx-install.sh 1.16.0 /opt/nginx\n"
|
||||
printf "\t Usage: sh nginx-install.sh [version] \n"
|
||||
printf "\t Default: sh nginx-install.sh 1.16.0 \n"
|
||||
printf "\t Example: sh nginx-install.sh 1.16.0 \n"
|
||||
printf "${RESET}\n"
|
||||
fi
|
||||
|
||||
temp=/opt/nginx
|
||||
version=1.16.0
|
||||
if [[ -n $1 ]]; then
|
||||
version=$1
|
||||
fi
|
||||
|
||||
path=/opt/nginx
|
||||
if [[ -n $2 ]]; then
|
||||
path=$2
|
||||
fi
|
||||
|
||||
# install info
|
||||
printf "${PURPLE}[Info]\n"
|
||||
printf "${PURPLE}[Install Info]\n"
|
||||
printf "\t version = ${version}\n"
|
||||
printf "\t path = ${path}\n"
|
||||
printf "${RESET}\n"
|
||||
|
||||
printf "${GREEN}>>>>>>>> install required libs.${RESET}\n"
|
||||
printf "${CYAN}>>>> install required libs${RESET}\n"
|
||||
yum install -y zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre
|
||||
|
||||
# download and decompression
|
||||
mkdir -p ${path}
|
||||
curl -o ${path}/nginx-${version}.tar.gz http://nginx.org/download/nginx-${version}.tar.gz
|
||||
tar zxf ${path}/nginx-${version}.tar.gz -C ${path}
|
||||
printf "${CYAN}>>>> download nginx${RESET}\n"
|
||||
mkdir -p ${temp}
|
||||
curl -o ${temp}/nginx-${version}.tar.gz http://nginx.org/download/nginx-${version}.tar.gz
|
||||
tar zxf ${temp}/nginx-${version}.tar.gz -C ${temp}
|
||||
|
||||
# configure and makefile
|
||||
cd ${path}/nginx-${version}
|
||||
printf "${CYAN}>>>> compile nginx${RESET}\n"
|
||||
cd ${temp}/nginx-${version}
|
||||
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
|
||||
make && make install
|
||||
rm -rf ${temp}
|
||||
cd -
|
||||
|
||||
# setting service
|
||||
# setting systemd service
|
||||
printf "${CYAN}>>>> set nginx as a systemd service${RESET}\n"
|
||||
wget -N https://gitee.com/turnon/linux-tutorial/raw/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为系统服务
|
||||
|
||||
# boot nginx
|
||||
printf "${CYAN}>>>> start nginx${RESET}\n"
|
||||
systemctl enable nginx.service
|
||||
##通过系统服务操作nginx
|
||||
systemctl start nginx.service
|
||||
#systemctl reload nginx.service
|
||||
#systemctl restart nginx.service
|
||||
#systemctl stop nginx.service
|
||||
printf "${GREEN}<<<<<<<< install nginx end.${RESET}\n"
|
||||
|
||||
printf "\n${GREEN}<<<<<<<< install nginx end${RESET}\n"
|
||||
printf "\n${PURPLE}nginx service status: ${RESET}\n"
|
||||
systemctl status nginx
|
||||
|
|
|
@ -10,26 +10,31 @@ BLUE="\033[1;34m"
|
|||
PURPLE="\033[1;35m"
|
||||
CYAN="\033[1;36m"
|
||||
RESET="$(tput sgr0)"
|
||||
###################################################################################
|
||||
##########################################################################cd#########
|
||||
|
||||
printf "${BLUE}"
|
||||
printf "${BLUE}\n"
|
||||
cat << EOF
|
||||
|
||||
###################################################################################
|
||||
# 安装 Redis 脚本
|
||||
# @system: 适用于 CentOS
|
||||
# 采用编译方式安装 Redis
|
||||
# @system: 适用于 CentOS7+
|
||||
# @author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
EOF
|
||||
printf "${RESET}"
|
||||
printf "${RESET}\n"
|
||||
|
||||
command -v yum > /dev/null 2>&1 || { printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1; }
|
||||
command -v yum > /dev/null 2>&1 || {
|
||||
printf "${RED}Require yum but it's not installed.${RESET}\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
printf "\n${GREEN}>>>>>>>> install redis begin${RESET}\n"
|
||||
|
||||
if [[ $# -lt 1 ]] || [[ $# -lt 2 ]] || [[ $# -lt 3 ]] || [[ $# -lt 4 ]]; then
|
||||
echo "Usage: sh redis-install.sh [version] [path] [port] [password]"
|
||||
echo -e "Example: sh redis-install.sh 5.0.4 /opt/redis 6379 123456\n"
|
||||
printf "${PURPLE}[Hint]\n"
|
||||
printf "\t Usage: sh redis-install.sh [version] [port] [password] \n"
|
||||
printf "\t Default: sh redis-install.sh 5.0.4 6379 <null> \n"
|
||||
printf "\t Example: sh redis-install.sh 5.0.4 6379 123456 \n"
|
||||
printf "${RESET}\n"
|
||||
fi
|
||||
|
||||
version=5.0.4
|
||||
|
@ -37,56 +42,65 @@ if [[ -n $1 ]]; then
|
|||
version=$1
|
||||
fi
|
||||
|
||||
root=/opt/redis
|
||||
if [[ -n $2 ]]; then
|
||||
root=$2
|
||||
fi
|
||||
|
||||
port=6379
|
||||
if [[ -n $3 ]]; then
|
||||
port=$3
|
||||
if [[ -n $2 ]]; then
|
||||
port=$2
|
||||
fi
|
||||
|
||||
password=
|
||||
if [[ -n $4 ]]; then
|
||||
password=$4
|
||||
if [[ -n $3 ]]; then
|
||||
password=$3
|
||||
fi
|
||||
|
||||
printf "${GREEN}>>>>>>>> install redis begin.${RESET}\n"
|
||||
# install info
|
||||
printf "${PURPLE}[Install Info]\n"
|
||||
printf "\t version = ${version}\n"
|
||||
printf "\t port = ${port}\n"
|
||||
printf "\t password = ${password}\n"
|
||||
printf "${RESET}\n"
|
||||
|
||||
printf "\t${GREEN}Current execution: install redis ${version} to ${root}, service port = ${port}, password = ${password}${RESET}\n"
|
||||
printf "${CYAN}>>>> install required libs${RESET}\n"
|
||||
yum install -y zlib zlib-devel gcc-c++ libtool openssl openssl-devel tcl
|
||||
|
||||
mkdir -p ${root}
|
||||
curl -o ${root}/redis-${version}.tar.gz http://download.redis.io/releases/redis-${version}.tar.gz
|
||||
# download and decompression
|
||||
printf "${CYAN}>>>> download redis${RESET}\n"
|
||||
temp="/tmp/redis"
|
||||
path="/usr/local/redis"
|
||||
mkdir -p ${temp}
|
||||
curl -o ${temp}/redis-${version}.tar.gz http://download.redis.io/releases/redis-${version}.tar.gz
|
||||
tar zxf ${temp}/redis-${version}.tar.gz -C ${temp}
|
||||
mv ${temp}/redis-${version} ${path}
|
||||
|
||||
path=${root}/redis-${version}
|
||||
tar zxf ${root}/redis-${version}.tar.gz -C ${root}
|
||||
# configure and makefile
|
||||
printf "${CYAN}>>>> compile redis${RESET}\n"
|
||||
cd ${path}
|
||||
make && make install
|
||||
rm -rf ${temp}
|
||||
cd -
|
||||
|
||||
printf "\n${CYAN}>>>>>>>>> config redis${RESET}\n"
|
||||
printf "${CYAN}>>>> modify redis config${RESET}\n"
|
||||
cp ${path}/redis.conf ${path}/redis.conf.default
|
||||
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/redis-remote-access.conf -O ${path}/redis.conf
|
||||
mkdir -p /etc/redis
|
||||
cp ${path}/redis.conf /etc/redis/${port}.conf
|
||||
sed -i "s/^port 6379/port ${port}/g" /etc/redis/${port}.conf
|
||||
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/redis/redis.conf -O ${path}/redis.conf
|
||||
sed -i "s/^port 6379/port ${port}/g" ${path}/redis.conf
|
||||
if [[ -n ${password} ]]; then
|
||||
sed -i "s/^# requirepass/requirepass ${password}/g" /etc/redis/${port}.conf
|
||||
sed -i "s/^protected-mode no/protected-mode yes/g" ${path}/redis.conf
|
||||
sed -i "s/^# requirepass/requirepass ${password}/g" ${path}/redis.conf
|
||||
fi
|
||||
|
||||
printf "\n${CYAN}>>>>>>>>> add firewall port${RESET}\n"
|
||||
printf "\n${CYAN}>>>> open redis port in firewall${RESET}\n"
|
||||
firewall-cmd --zone=public --add-port=${port}/tcp --permanent
|
||||
firewall-cmd --reload
|
||||
|
||||
printf "\n${CYAN}>>>>>>>>> add redis service${RESET}\n"
|
||||
# 注册 redis 服务,并设置开机自启动
|
||||
cp ${path}/utils/redis_init_script /etc/init.d/
|
||||
mv /etc/init.d/redis_init_script /etc/init.d/redis_${port}
|
||||
sed -i "s/^REDISPORT=.*/REDISPORT=${port}/g" /etc/init.d/redis_${port}
|
||||
chmod +x /etc/init.d/redis_${port}
|
||||
chkconfig --add redis_${port}
|
||||
service redis_${port} start
|
||||
# setting systemd service
|
||||
printf "${CYAN}>>>> set redis as a systemd service${RESET}\n"
|
||||
wget -N https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/config/redis/redis.service -O /usr/lib/systemd/system/redis.service
|
||||
chmod +x /usr/lib/systemd/system/redis.service
|
||||
|
||||
printf "\n${GREEN}<<<<<<<< install redis end.${RESET}\n"
|
||||
# boot redis
|
||||
printf "${CYAN}>>>> start redis${RESET}\n"
|
||||
systemctl enable redis.service
|
||||
systemctl start redis.service
|
||||
|
||||
printf "\n${GREEN}<<<<<<<< install redis end${RESET}\n"
|
||||
printf "\n${PURPLE}redis service status: ${RESET}\n"
|
||||
systemctl status redis
|
||||
|
|
|
@ -442,7 +442,35 @@ GET: 508388.41 requests per second
|
|||
|
||||
## 脚本
|
||||
|
||||
如果想傻瓜式安装一个 Redis 单节点服务,可以使用我的 [安装脚本](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft#redis-%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE)
|
||||
> CentOS7 环境安装脚本:[软件运维配置脚本集合](https://github.com/dunwu/linux-tutorial/tree/master/codes/linux/soft)
|
||||
|
||||
**安装说明**
|
||||
|
||||
- 采用编译方式安装 Redis, 并将其注册为 systemd 服务
|
||||
- 安装路径为:`/usr/local/redis`
|
||||
- 默认下载安装 `5.0.4` 版本,端口号为:`6379`,密码为空
|
||||
|
||||
**使用方法**
|
||||
|
||||
- 默认安装 - 执行以下任意命令即可:
|
||||
|
||||
```sh
|
||||
curl -o- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/redis-install.sh | bash
|
||||
wget -qO- https://gitee.com/turnon/linux-tutorial/raw/master/codes/linux/soft/redis-install.sh | bash
|
||||
```
|
||||
|
||||
- 自定义安装 - 下载脚本到本地,并按照以下格式执行:
|
||||
|
||||
|
||||
```sh
|
||||
sh redis-install.sh [version] [port] [password]
|
||||
```
|
||||
|
||||
参数说明:
|
||||
|
||||
- `version` - redis 版本号
|
||||
- `port` - redis 服务端口号
|
||||
- `password` - 访问密码
|
||||
|
||||
## 参考资料
|
||||
|
||||
|
|
Loading…
Reference in New Issue