CentOS7-离线编译安装Redis4.0.9
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CentOS7-离线编译安装Redis4.0.9,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3019字,纯文字阅读大概需要5分钟。
内容图文
![CentOS7-离线编译安装Redis4.0.9](/upload/InfoBanner/zyjiaocheng/865/9b2da5cc6b514c308256bdd1ce0061af.jpg)
CentOS7-离线编译安装Redis4.0.9
redis下载官方地址: redis-4.0.9.tar.gz
1. 下载并解压
curl -o redis-4.0.9.tar.gz http://download.redis.io/releases/redis-4.0.9.tar.gz
tar -zxvf redis-4.0.9.tar.gz
2.编译源码
cd redis-4.0.9
mkdir -p /opt/tbp/redis
make && make PREFIX=/opt/tbp/redis install
3.创建启动项脚本
cat >> /etc/init.d/redisd <<EOF
#!/bin/bash
# chkconfig: 2345 85 80
# description: Starts and Stops the redisd server.
### BEGIN INIT INFO
# Provides: redis-server
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start up the redisd server:n
# Description: This service starts up the redis server daemon.
### END INIT INFO
# source function library.
#. /etc/init.d/functions
source /etc/profile
DIR=${TBP_HOME}/redis/
PROG=bin/redis-server
CONF=bin/redis.conf
CMD="${DIR}${PROG} ${DIR}${CONF}"
# check for $PROG script
if [ ! -f $DIR$PROG ]
then
echo "${PROG} not exists..."
exit
fi
start()
{
echo "starting $PROG : "
nohup $CMD >/dev/null 2>&1 &
sleep 0.5
status
}
stop()
{
echo "stopping $PROG: "
ps -ef | grep "$PROG" | kill -9 `awk '{print $2}'` >/dev/null 2>&1
sleep 0.5
status
}
restart()
{
stop
start
echo -n ""
}
status()
{
count=`ps -ef | grep -c $PROG`
if [ $count -gt 1 ]
then
echo "${PROG} is running."
else
echo "${PROG} is stoped."
fi
echo -n ""
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
status)
status ;;
*)
echo "Usage: ${PROG} {start|stop|restart|status}"
exit 1
esac
exit 0
EOF
4.添加启动项脚本权限
chmod +x /etc/init.d/redisd
5.添加服务
chkconfig --add redisd
5.配置启动级别
chkconfig --level 2345 redisd on
5.总结一句话脚本
curl -o redis-4.0.9.tar.gz http://download.redis.io/releases/redis-4.0.9.tar.gz && \
tar -zxvf redis-4.0.9.tar.gz && \
cd redis-4.0.9 && \
mkdir -p /opt/tbp/redis && \
make && make PREFIX=/opt/tbp/redis install && \
cat >> /etc/init.d/redisd <<EOF
#!/bin/bash
# chkconfig: 2345 85 80
# description: Starts and Stops the redisd server.
### BEGIN INIT INFO
# Provides: redis-server
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start up the redisd server:n
# Description: This service starts up the redis server daemon.
### END INIT INFO
# source function library.
#. /etc/init.d/functions
source /etc/profile
DIR=${TBP_HOME}/redis/
PROG=bin/redis-server
CONF=bin/redis.conf
CMD="${DIR}${PROG} ${DIR}${CONF}"
# check for $PROG script
if [ ! -f $DIR$PROG ]
then
echo "${PROG} not exists..."
exit
fi
start()
{
echo "starting $PROG : "
nohup $CMD >/dev/null 2>&1 &
sleep 0.5
status
}
stop()
{
echo "stopping $PROG: "
ps -ef | grep "$PROG" | kill -9 `awk '{print $2}'` >/dev/null 2>&1
sleep 0.5
status
}
restart()
{
stop
start
echo -n ""
}
status()
{
count=`ps -ef | grep -c $PROG`
if [ $count -gt 1 ]
then
echo "${PROG} is running."
else
echo "${PROG} is stoped."
fi
echo -n ""
}
case "$1" in
start)
start ;;
stop)
stop ;;
restart)
restart ;;
status)
status ;;
*)
echo "Usage: ${PROG} {start|stop|restart|status}"
exit 1
esac
exit 0
EOF
chmod +x /etc/init.d/redisd && \
chkconfig --add redisd && \
chkconfig --level 2345 redisd on
内容总结
以上是互联网集市为您收集整理的CentOS7-离线编译安装Redis4.0.9全部内容,希望文章能够帮你解决CentOS7-离线编译安装Redis4.0.9所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。