redis-3.2.8安装部署

下载安装包

wget http://download.redis.io/releases/redis-3.2.8.tar.gz

解压缩包

tar xf redis-3.2.8.tar.gz
cd redis-3.2.8/
yum -y install gcc gcc-c++ libstdc++-devel tcl -y

编译安装

make PREFIX=/usr/local/redis-3.2.8 install
cd src
make install
make test

配置文件

cd /usr/local/redis-3.2.8
mkdir conf db logs
cp /tools/redis-3.2.8/redis.conf /usr/local/redis-3.2.8/conf/
cd /usr/local/redis-3.2.8/conf
vim redis.conf
61gg bind 172.22.33.83
84gg port 6379
128gg daemonize yes
150gg pidfile /usr/local/redis-3.2.8/redis_6379.pid
163gg logfile "/usr/local/redis-3.2.8/logs/redis_6379.log"
247gg dir /usr/local/redis-3.2.8/db
480gg requirepass xdf123

启动redis

/usr/local/redis-3.2.8/bin/redis-server /usr/local/redis-3.2.8/conf/redis.conf
开机自启动
vim /etc/init.d/redis

!/bin/bash

chkconfig: 22345 10 90

description: Start and Stop redis

REDISPORT=9379
EXEC=/usr/local/redis-3.2.8/src/redis-server
CLIEXEC=/usr/local/redis-3.2.8/src/redis-cli
HOST="10.167.2.16"
PASSWD="hf123qwe!"
PIDFILE=/var/run/redis_6379.pid
CONF="/usr/local/redis-3.2.8/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ];then
echo "$PIDFILE exists,process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ];then
echo "$PIDFILE does not exist,process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$CLIEXEC -h $HOST -p $REDISPORT -a $PASSWD shutdown
while [ -x ${PID} ]
do
echo "Waiting for Redis to shutdown..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Please use start or stop or restart as first argument"
;;
esac
chmod +x /etc/init.d/redis
chkconfig --add redis
chkconfig redis on
chkconfig --list redis

测试启动

service redis start

测试停止

service redis stop

加入开机启动

vi /etc/rc.d/rc.local  
加入下面内容
/usr/sbin/service redis start

注意:

如果重启linux服务没有自启动,则需检查/etc/rc.d/rc.local是否有可执行权限

posted @ 2021-01-28 16:51  霸都运维  阅读(121)  评论(0编辑  收藏  举报