ITPub博客

首页 > 数据库 > NoSQL > Redis学习笔记-0、Linux快速安装Redis

Redis学习笔记-0、Linux快速安装Redis

原创 NoSQL 作者:kaodaxia 时间:2016-10-12 17:50:13 0 删除 编辑

转载自 https://www.dbalog.net,转载请注明出处
1、下载Redis

  1. [root@lb03 src]# wget http://download.redis.io/releases/redis-3.0.6.tar.gz

2、解压编译

  1. [root@lb03 src]# tar -zxvf redis-3.0.6.tar.gz
  2. [root@lb03 src]# cd redis-3.0.6
  3. [root@lb03 redis-3.0.6]# make

3、启停服务

  1. 启动:
  2. [root@lb03 redis-3.0.6]# src/redis-server
  3. [root@lb03 redis-3.0.6]# src/redis-server & #放入后台 或者修改daemonize 参数为yes
  4. 启动后提示redis的默认端口是6379
  5. 停止:
  6. 启动后前台会被占用,如需停止服务,ctrol+c即可,或者
  7. [root@lb03 redis-3.0.6]# src/redis-cli shutdown

blob.png


4、连接测试

  1. [root@lb03 redis-3.0.6]# src/redis-cli
  2. 127.0.0.1:6379> set name kaodaxia
  3. OK
  4. 127.0.0.1:6379> get name
  5. "kaodaxia"
  6. 127.0.0.1:6379>

5、修改redis随Linux系统自动启动

  1. 方法1:
  2. [root@lb03 redis-3.0.6]# vi /etc/rc.local
  3. #!/bin/sh
  4. #
  5. # This script will be executed *after* all the other init scripts.
  6. # You can put your own initialization stuff in here if you don't
  7. # want to do the full Sys V style init stuff.
  8. touch /var/lock/subsys/local
  9. /usr/local/src/redis-3.0.6/src/redis-server #增加此行,保证随机启动
  1. 方法2:
  2. [root@lb03 redis-3.0.6]# mkdir /etc/redis
  3. [root@lb03 redis-3.0.6]# cp redis.conf /etc/redis/6379.conf #为什么是6379.cof 
  4.                          #看下utils/redis_init_script启动脚本就明白
  5. [root@lb03 redis-3.0.6]# cp utils/redis_init_script /etc/init.d/redisd
  6. [root@lb03 redis-3.0.6]# chkconfig redisd on
  7. redisd 服务不支持 chkconfig
  8. 报错了 ,在启动脚本添加如下两行注释即可:
  9. [root@lb03 redis-3.0.6]# vi /etc/init.d/redisd
  10. #!/bin/sh
  11. #
  12. # Simple Redis init.d script conceived to work on Linux systems
  13. # as it does use of the /proc filesystem.
  14. # chkconfig:   2345 90 10
  15. # description:  Redis is a persistent key-value database
  16. [root@lb03 redis-3.0.6]# service redisd stop
  17. Stopping ...
  18. Redis stopped
  19. [root@lb03 redis-3.0.6]# service redisd start
  20. Starting Redis server...
  21. 注意:启动脚本开头需要修改下PIDFILE的变量值

  * 推荐使用方法2,不仅自动启动,还可以使用redis的启停脚本

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29335267/viewspace-2126189/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2014-10-08

  • 博文量
    2
  • 访问量
    28879