@@ -20,6 +20,16 @@ if [[ -n $2 ]]; then
2020 root=$2
2121fi
2222
23+ port=6379
24+ if [[ -n $3 ]]; then
25+ port=$3
26+ fi
27+
28+ password=123456
29+ if [[ -n $4 ]]; then
30+ path=$4
31+ fi
32+
2333echo -e " \n>>>>>>>>> install libs"
2434yum install -y zlib zlib-devel gcc-c++ libtool openssl openssl-devel tcl
2535
@@ -28,7 +38,28 @@ mkdir -p ${root}
2838wget -O ${root} /redis-${version} .tar.gz http://download.redis.io/releases/redis-${version} .tar.gz
2939
3040echo -e " \n>>>>>>>>> install redis"
41+ path=${root} /redis-${version}
3142tar zxf ${root} /redis-${version} .tar.gz -C ${root}
32- cd ${root} /redis- ${version }
43+ cd ${path }
3344make && make install
3445cd -
46+
47+ echo -e " \n>>>>>>>>> config redis"
48+ cp ${path} /redis.conf ${path} /redis.conf.default
49+ wget -N https://raw.githubusercontent.com/dunwu/linux-tutorial/master/codes/linux/ops/soft/config/redis-remote-access.conf -O ${path} /redis.conf
50+ cp ${path} /redis.conf /etc/redis/${port} .conf
51+ sed -i " s/^port 6379/port ${port} /g" /etc/redis/${port} .conf
52+ sed -i " s/^requirepass 123456/requirepass ${password} /g" /etc/redis/${port} .conf
53+
54+ echo -e " \n>>>>>>>>> add firewall port"
55+ firewall-cmd --zone=public --add-port=${port} /tcp --permanent
56+ firewall-cmd --reload
57+
58+ echo -e " \n>>>>>>>>> add redis service"
59+ # 注册 redis 服务,并设置开机自启动
60+ cp ${path} /utils/redis_init_script /etc/init.d/redis_${port}
61+ sed -i " s/^REDISPORT=.*/REDISPORT=${port} /g" /etc/init.d/redis_${port}
62+ chmod +x /etc/init.d/redis_${port}
63+ chkconfig --add redis_${port}
64+ service redis_${port} start
65+
0 commit comments