废话少说,直接来步骤:

1、设置redis.conf中daemonize为yes,确保守护进程开启。

2、编写开机自启动脚本

vi /etc/init.d/redis

脚本内容如下:

# chkconfig:
# description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=
EXEC=/usr/redisbin/redis-server
REDIS_CLI=/usr/redisbin/redis-cli PIDFILE=/var/run/redis.pid
CONF="/usr/redisbin/redis.conf"
AUTH="" 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
if [ "$?"="" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep
while [ -x $PIDFILE ]
do
echo "Waiting for Redis to shutdown..."
sleep
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${} stop
${} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&
exit
esac

3、写完后保存退出VI

4、设置权限

chmod  redis

5、启动测试

/etc/init.d/redis start

启动成功会提示如下信息:

Starting Redis server...
Redis is running...

使用redis-cli测试:

[root@rk ~]# /usr/redisbin/redis-cli
127.0.0.1:> set foo bar
OK
127.0.0.1:> get foo
"bar"
127.0.0.1:> exit

6、设置开机自启动

chkconfig redis on

7、关机重启测试

reboot

然后在用redis-cli测试即可。

Linux下Redis开机自启(Centos)的更多相关文章

  1. Linux下Redis开机自启(Centos6)

    1.设置redis.conf中daemonize为yes,确保守护进程开启. 查找redis配置文件redis.conf [root@localhost /]# find / -name redis. ...

  2. Linux下ejabberd开机自启(CentOS)

    废话少说,Linux下开机自启动Ejabberd步骤如下: 1.从ejabberd安装目录的bin目录拷贝ejabberd.init到/etc/init.d/ejabberd下 [root@imser ...

  3. linux下redis开机自启动

    将/usr/local/app/redis-4.0.8/redis.conf文件中daemonize no改为daemonize yes 在/etc目录下新建redis目录:mkdir /etc/re ...

  4. Linux配置redis开机启动(CentOS 7)

    https://blog.csdn.net/qq_31803503/article/details/79246205 本次配置linux版本是CentOS 7 首先将  redis-3.2.3/uti ...

  5. Job for redis-server.service failed because the control process exited with error code(Centos 7 设置Redis开机自启报错)

    报错信息如下: Job for redis-server.service failed because the control process exited with error code.  See ...

  6. Linux下Redis服务器安装配置

    说明:操作系统:CentOS1.安装编译工具yum install wget  make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel ...

  7. windows下和linux下 Redis 安装

    Redis 是一个高性能的key-value数据库, 使用内存作为主存储,数据访问速度非常快,当然它也提供了两种机制支持数据持久化存储.比较遗憾的是,Redis项目不直接支持Windows,Windo ...

  8. Centos7 设置redis开机自启

    Centos7 设置redis开机自启 标签(空格分隔):Linux 环境 Centos7.1 redis-3.0.6 chkconfig方式 **service和chkconfig命令的功能好像都被 ...

  9. linux Nginx服务开机自启

    linux Nginx服务开机自启 Nginx 是一个很强大的高性能Web和反向代理服务器.虽然使用命令行可以对nginx进行各种操作,比如启动等,但是还是根据不太方便.下面介绍在linux下安装后, ...

随机推荐

  1. C#异步下载文件--基于http请求

    1.废话不多说,直接上代码: using System; using System.IO; using System.Net; namespace AsyncProgram { class Progr ...

  2. [转载][翻译] IoC 容器和 Dependency Injection 模式

    原文地址:Inversion of Control Containers and the Dependency Injection pattern 中文翻译版本是网上的PDF文档,发布在这里仅为方便查 ...

  3. ssh默认端口更改后,如何正常使用git?

    由于安全或者其它原因,我们可能会修改默认的SSH服务端口号,默认情况下,已有的git项目在pull或者push的时候会报错. 现在假设原来的项目的remote设置为git@domain.com:Pro ...

  4. JQuery读取XML文件

    <?xml version="1.0" encoding="utf-8" ?> <taxrates> <taxrate id=&q ...

  5. Owl Carousel – 支持触摸的 jQuery 响应式传送带插件

    Owl Carousel 是一个 jQuery 插件,使我们能够迅速地创建响应式传送带滑块.这个插件是触摸友好的,能与几乎任何的 HTML 内容兼容使用.另外,强大的选项设置支持分页/滑动速度,启用/ ...

  6. go git 安装配置与使用 (windows 7 64bit)

    go语言安装使用第三方库方式一般采用 go get github.com/.../...  命令.例如: go get github.com/astaxie/beego 1.错误情况一: packag ...

  7. SharePoint 2013 在母版页中插入WebPart

    最近QQ群里有朋友问,如何在母版页里插入自己开发的WebPart.其实很简单,母版页中虽然不允许插入WebPartZone,但是Designer就可以插入WebPart:或者手动注册,然后插入WebP ...

  8. ArcGIS Server 标准版和高级版在Web3D的区别

  9. 自定义有监听器的ScrollView

    public class ObservableScrollView extends ScrollView { public ObservableScrollView(Context context) ...

  10. [Android]竖直滑动选择器WheelView的实现

    以下内容为原创,转载请注明: 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3819304.html 公司项目中有这么一个需求,所以需要自己实现下.效 ...