|
@@ -41,6 +41,10 @@ JENKINS_FILE_NAME="jenkins.war"
|
|
|
JENKINS_JAVA_URL="https://d6.injdk.cn/oraclejdk/11/jdk-11.0.16.1_linux-x64_bin.tar.gz"
|
|
|
JENKINS_JAVA_FILE_NAME="jdk-11.0.16.1_linux-x64_bin.tar.gz"
|
|
|
JENKINS_JAVA_DIR_NAME="jdk-11.0.16.1"
|
|
|
+#--- redis Latest Stable
|
|
|
+REDIS_URL="https://download.redis.io/redis-stable.tar.gz"
|
|
|
+REDIS_FILE_NAME="redis-stable.tar.gz"
|
|
|
+REDIS_DIR_NAME="redis-stable"
|
|
|
|
|
|
# 安装标识
|
|
|
#--- SSH用户
|
|
@@ -68,6 +72,7 @@ JAVA_TAG="1"
|
|
|
GRADLE_TAG="1"
|
|
|
MAVEN_TAG="1"
|
|
|
JENKINS_TAG="1"
|
|
|
+REDIS_TAG="1"
|
|
|
|
|
|
# 脚本设置
|
|
|
TMP_DIR="$(rm -rf /tmp/env-install* && mktemp -d -t env-install.XXXXXXXXXX)"
|
|
@@ -550,6 +555,141 @@ EOF
|
|
|
log::info "[jenkins]" "停止jenkins: ${BASE_DIR}/jenkins/kill.sh"
|
|
|
}
|
|
|
|
|
|
+# 安装redis环境
|
|
|
+function init:redis() {
|
|
|
+ log::info "[redis]" "安装redis环境..."
|
|
|
+ local host="127.0.0.1"
|
|
|
+ local redis_path="${BASE_DIR}/redis/${REDIS_DIR_NAME}"
|
|
|
+ local redis_install_path="${BASE_DIR}/redis/${REDIS_DIR_NAME}-install"
|
|
|
+ command::exec "${host}" "
|
|
|
+ if [ ! -d "$redis_path" ]; then
|
|
|
+ mkdir -p ${BASE_DIR}/redis
|
|
|
+ wget --timeout=10 --waitretry=3 --tries=5 --retry-connrefused --no-check-certificate ${REDIS_URL} -O ${BASE_DIR}/redis/${REDIS_FILE_NAME}
|
|
|
+ cd ${BASE_DIR}/redis
|
|
|
+ tar -zxvf ${REDIS_FILE_NAME}
|
|
|
+ cd $redis_path
|
|
|
+ yum -y install gcc
|
|
|
+ yum -y install centos-release-scl
|
|
|
+ yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
|
|
|
+ scl enable devtoolset-9 bash
|
|
|
+ echo 'source /opt/rh/devtoolset-9/enable' >> /etc/profile
|
|
|
+ gcc -v
|
|
|
+ cd $redis_path
|
|
|
+ make install PREFIX=$redis_install_path
|
|
|
+ # 写文件start.sh文件
|
|
|
+ cat << EOF > $redis_install_path/redis.conf
|
|
|
+# bind 127.0.0.1
|
|
|
+protected-mode yes
|
|
|
+port 6379
|
|
|
+tcp-backlog 511
|
|
|
+timeout 300
|
|
|
+tcp-keepalive 300
|
|
|
+daemonize yes
|
|
|
+supervised auto
|
|
|
+pidfile $redis_install_path/redis.pid
|
|
|
+loglevel notice
|
|
|
+logfile $redis_install_path/redis.log
|
|
|
+databases 16
|
|
|
+always-show-logo yes
|
|
|
+save 900 1
|
|
|
+save 300 10
|
|
|
+save 60 10000
|
|
|
+stop-writes-on-bgsave-error yes
|
|
|
+rdbcompression yes
|
|
|
+rdbchecksum yes
|
|
|
+dbfilename dump.rdb
|
|
|
+rdb-del-sync-files no
|
|
|
+dir $redis_install_path/
|
|
|
+replica-serve-stale-data yes
|
|
|
+replica-read-only yes
|
|
|
+repl-diskless-sync no
|
|
|
+repl-diskless-sync-delay 5
|
|
|
+repl-diskless-load disabled
|
|
|
+repl-disable-tcp-nodelay no
|
|
|
+replica-priority 100
|
|
|
+acllog-max-len 128
|
|
|
+requirepass sk123456
|
|
|
+# 限制内存4GB = 4294967296 bytes
|
|
|
+maxmemory 4294967296
|
|
|
+maxmemory-policy allkeys-lfu
|
|
|
+lazyfree-lazy-eviction no
|
|
|
+lazyfree-lazy-expire no
|
|
|
+lazyfree-lazy-server-del no
|
|
|
+replica-lazy-flush no
|
|
|
+lazyfree-lazy-user-del no
|
|
|
+oom-score-adj no
|
|
|
+oom-score-adj-values 0 200 800
|
|
|
+appendonly no
|
|
|
+appendfilename "appendonly.aof"
|
|
|
+appendfsync everysec
|
|
|
+no-appendfsync-on-rewrite no
|
|
|
+auto-aof-rewrite-percentage 100
|
|
|
+auto-aof-rewrite-min-size 64mb
|
|
|
+aof-load-truncated yes
|
|
|
+aof-use-rdb-preamble yes
|
|
|
+lua-time-limit 5000
|
|
|
+slowlog-log-slower-than 10000
|
|
|
+slowlog-max-len 128
|
|
|
+latency-monitor-threshold 0
|
|
|
+notify-keyspace-events ""
|
|
|
+hash-max-ziplist-entries 512
|
|
|
+hash-max-ziplist-value 64
|
|
|
+list-max-ziplist-size -2
|
|
|
+list-compress-depth 0
|
|
|
+set-max-intset-entries 512
|
|
|
+zset-max-ziplist-entries 128
|
|
|
+zset-max-ziplist-value 64
|
|
|
+hll-sparse-max-bytes 3000
|
|
|
+stream-node-max-bytes 4096
|
|
|
+stream-node-max-entries 100
|
|
|
+activerehashing yes
|
|
|
+client-output-buffer-limit normal 0 0 0
|
|
|
+client-output-buffer-limit replica 256mb 64mb 60
|
|
|
+client-output-buffer-limit pubsub 32mb 8mb 60
|
|
|
+hz 10
|
|
|
+dynamic-hz yes
|
|
|
+aof-rewrite-incremental-fsync yes
|
|
|
+rdb-save-incremental-fsync yes
|
|
|
+jemalloc-bg-thread yes
|
|
|
+EOF
|
|
|
+ cat << EOF > $redis_install_path/start.sh
|
|
|
+#!/bin/bash
|
|
|
+#set -x
|
|
|
+set -e
|
|
|
+
|
|
|
+pid=\\\`ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}'\\\`
|
|
|
+cd $redis_install_path
|
|
|
+if [ -z \\\$pid ];then
|
|
|
+ $redis_install_path/bin/redis-server $redis_install_path/redis.conf
|
|
|
+ echo 'redis启动成功!'
|
|
|
+else
|
|
|
+ echo 'redis正在运行...'
|
|
|
+fi
|
|
|
+echo '查看日志: tail -F $redis_install_path/redis.log -n 100'
|
|
|
+EOF
|
|
|
+ # 写文件kill.sh文件
|
|
|
+ cat << EOF > $redis_install_path/kill.sh
|
|
|
+#!/bin/bash
|
|
|
+#set -x
|
|
|
+set -e
|
|
|
+pid=\\\`ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}'\\\`
|
|
|
+if [ -z \\\$pid ];then
|
|
|
+ echo 'redis未运行'
|
|
|
+else
|
|
|
+ ps -ef | grep '$redis_install_path/bin/redis-server' | grep -v 'grep' | awk '{print \\\$2}' | xargs kill
|
|
|
+ echo 'redis已停止!'
|
|
|
+fi
|
|
|
+EOF
|
|
|
+ chmod +x $redis_install_path/start.sh
|
|
|
+ chmod +x $redis_install_path/kill.sh
|
|
|
+ fi
|
|
|
+ "
|
|
|
+ check::exit_code "$?" "redis" "$host 安装redis环境" "exit"
|
|
|
+ log::info "[redis]" "redis环境安装成功!"
|
|
|
+ log::info "[redis]" "启动redis: $redis_install_path/start.sh"
|
|
|
+ log::info "[redis]" "停止redis: $redis_install_path/kill.sh"
|
|
|
+}
|
|
|
+
|
|
|
######################################################################################################
|
|
|
# 主调用逻辑
|
|
|
######################################################################################################
|
|
@@ -578,6 +718,7 @@ Flag:
|
|
|
-gradle 是否安装gradle环境, 默认: '1'
|
|
|
-maven 是否安装maven环境, 默认: '1'
|
|
|
-jenkins 是否安装jenkins环境, 默认: '1'
|
|
|
+ -redis 是否安装redis环境, 默认: '1'
|
|
|
|
|
|
Example:
|
|
|
env-install-centos.sh init \\
|
|
@@ -593,7 +734,8 @@ Example:
|
|
|
-java 1 \\
|
|
|
-gradle 0 \\
|
|
|
-maven 0 \\
|
|
|
- -jenkins 0
|
|
|
+ -jenkins 0 \\
|
|
|
+ -redis 0 \\
|
|
|
|
|
|
EOF
|
|
|
exit 1
|
|
@@ -649,6 +791,9 @@ while [ "${1:-}" != "" ]; do
|
|
|
-jenkins ) shift
|
|
|
JENKINS_TAG=${1:-JENKINS_TAG}
|
|
|
;;
|
|
|
+ -redis ) shift
|
|
|
+ REDIS_TAG=${1:-REDIS_TAG}
|
|
|
+ ;;
|
|
|
* ) help::usage
|
|
|
exit 1
|
|
|
esac
|
|
@@ -672,6 +817,7 @@ if [[ "${INIT_TAG:-}" == "1" ]]; then
|
|
|
[[ "${GRADLE_TAG:-}" == "1" ]] && { init:gradle; }
|
|
|
[[ "${MAVEN_TAG:-}" == "1" ]] && { init:maven; }
|
|
|
[[ "${JENKINS_TAG:-}" == "1" ]] && { init:jenkins; }
|
|
|
+ [[ "${REDIS_TAG:-}" == "1" ]] && { init:redis; }
|
|
|
else
|
|
|
help::usage
|
|
|
fi
|