vi redis_single_install.sh
#!/bin/bash
# install redis
yum install gcc gcc-c++ -y
mkdir -p /data/usr/src
tar -zxf redis-4.0.11.tar.gz -C /data/usr/src
cd /data/usr/src/redis-4.0.11
make PREFIX=/data/usr/redis-4.0.11 install MALLOC=libc
mkdir /data/usr/redis-4.0.11/{run,conf,logs,data}
cp /data/usr/src/redis-4.0.11/redis.conf /data/usr/redis-4.0.11/conf/
# config ENV
cat >>/etc/profile <<EOF
REDIS_HOME=/data/usr/redis-4.0.11
export PATH=\$PATH:\$REDIS_HOME/bin
EOF
source /etc/profile
# config redis
IP=`hostname -i | awk '{print $2}'`
sed -i "s/^bind 127.0.0.1/& ${IP}/" /data/usr/redis-4.0.11/conf/redis.conf
sed -i "s/^daemonize no/daemonize yes/" /data/usr/redis-4.0.11/conf/redis.conf
sed -i "s|^pidfile /var/run/redis_6379.pid|pidfile /data/usr/redis-4.0.11/run/redis_6379.pid|" /data/usr/redis-4.0.11/conf/redis.conf
sed -i "s|^logfile.*$|logfile /data/usr/redis-4.0.11/logs/redis.log|" /data/usr/redis-4.0.11/conf/redis.conf
sed -i "s|dir ./|dir /data/usr/redis-4.0.11/data|" /data/usr/redis-4.0.11/conf/redis.conf
sed -i "s/# requirepass foobared/requirepass Redis2019\!/" /data/usr/redis-4.0.11/conf/redis.conf
# config start-shell
cp /data/usr/src/redis-4.0.11/utils/redis_init_script /etc/rc.d/init.d/redis
sed -i '/END INIT INFO/a# chkconfig: 2345 80 90' /etc/rc.d/init.d/redis
sed -i 's|EXEC=/usr/local/bin/redis-server|EXEC=/data/usr/redis-4.0.11/bin/redis-server|' /etc/rc.d/init.d/redis
sed -i 's|CLIEXEC=/usr/local/bin/redis-cli|CLIEXEC=/data/usr/redis-4.0.11/bin/redis-cli|' /etc/rc.d/init.d/redis
sed -i 's|PIDFILE=/var/run/redis_${REDISPORT}.pid|PIDFILE=/data/usr/redis-4.0.11/run/redis_6379.pid|' /etc/rc.d/init.d/redis
sed -i 's|CONF=\"/etc/redis/${REDISPORT}.conf\"|CONF=\"/data/usr/redis-4.0.11/conf/redis.conf\"|' /etc/rc.d/init.d/redis
sed -i 's/$REDISPORT/&-a Redis2019!/' /etc/rc.d/init.d/redis
# start server
systemctl enable redis
systemctl start redis
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。