linux下yum安装redis以及使用

1、yum install redis      --查看是否有redis   yum 源

  1. [root@localhost ~]# yum install redis
  2. 已加载插件:fastestmirror
  3. base | 3.6 kB 00:00
  4. docker-ce-edge | 2.9 kB 00:00
  5. docker-ce-stable | 2.9 kB 00:00
  6. extras | 3.4 kB 00:00
  7. updates | 3.4 kB 00:00
  8. extras/7/x86_64/primary_db | 145 kB 00:00
  9. Loading mirror speeds from cached hostfile
  10. * base: mirrors.sohu.com
  11. * extras: mirrors.sohu.com
  12. * updates: mirrors.sohu.com
  13. 没有可用软件包 redis
  14. 错误:无须任何处理

2、yum install epel-release    --下载fedora的epel仓库

  1. [root@localhost ~]# yum install epel-release
  2. 已加载插件:fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.sohu.com
  5. * extras: mirrors.sohu.com
  6. * updates: mirrors.sohu.com
  7. 正在解决依赖关系
  8. --> 正在检查事务
  9. ---> 软件包 epel-release.noarch.0.7-9 将被 安装
  10. --> 解决依赖关系完成
  11.  
  12. 依赖关系解决
  13.  
  14. =====================================================================
  15. Package 架构 版本 大小
  16. =====================================================================
  17. 正在安装:
  18. epel-release noarch 7-9 extras 14 k
  19.  
  20. 事务概要
  21. =====================================================================
  22. 安装 1 软件包
  23.  
  24. 总下载量:14 k
  25. 安装大小:24 k
  26. Is this ok [y/d/N]: y
  27. Downloading packages:
  28. epel-release-7-9.noarch.rpm | 14 kB 00:00
  29. Running transaction check
  30. Running transaction test
  31. Transaction test succeeded
  32. Running transaction
  33. 正在安装 : epel-release-7-9.noarch 1/1
  34. 验证中 : epel-release-7-9.noarch 1/1
  35.  
  36. 已安装:
  37. epel-release.noarch 0:7-9
  38.  
  39. 完毕!

3、yum install redis    -- 安装redis数据库

  1. [root@localhost ~]# yum install redis
  2. 已加载插件:fastestmirror
  3. epel/x86_64/metalink | 7.9 kB 00:00
  4. epel | 4.7 kB 00:00
  5. (1/3): epel/x86_64/updateinfo | 857 kB 00:00
  6. (2/3): epel/x86_64/group_gz | 266 kB 00:01
  7. (3/3): epel/x86_64/primary_db | 6.1 MB 00:05
  8. Loading mirror speeds from cached hostfile
  9. * base: mirrors.sohu.com
  10. * epel: mirrors.ustc.edu.cn
  11. * extras: mirrors.sohu.com
  12. * updates: mirrors.sohu.com
  13. 正在解决依赖关系
  14. --> 正在检查事务
  15. ---> 软件包 redis.x86_64.0.3.2.10-2.el7 将被 安装
  16. --> 正在处理依赖关系 libjemalloc.so.1()(64bit),它被软件包 redis-3.2.10-2.el7.x86_64 需要
  17. --> 正在检查事务
  18. ---> 软件包 jemalloc.x86_64.0.3.6.0-1.el7 将被 安装
  19. --> 解决依赖关系完成
  20.  
  21. 依赖关系解决
  22.  
  23. =====================================================================
  24. Package 架构 版本 大小
  25. =====================================================================
  26. 正在安装:
  27. redis x86_64 3.2.10-2.el7 epel 545 k
  28. 为依赖而安装:
  29. jemalloc x86_64 3.6.0-1.el7 epel 105 k
  30.  
  31. 事务概要
  32. =====================================================================
  33. 安装 1 软件包 (+1 依赖软件包)
  34.  
  35. 总下载量:650 k
  36. 安装大小:1.7 M
  37. Is this ok [y/d/N]: y
  38. Downloading packages:
  39. 警告:/var/cache/yum/x86_64/7/epel/packages/jemalloc-3.6.0-1.el7.x86_64.rpm: V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
  40. jemalloc-3.6.0-1.el7.x86_64.rpm 的公钥尚未安装
  41. (1/2): jemalloc-3.6.0-1.el7.x86_64.rpm | 105 kB 00:00
  42. (2/2): redis-3.2.10-2.el7.x86_64.rpm | 545 kB 00:01
  43. ---------------------------------------------------------------------
  44. 总计 385 kB/s | 650 kB 00:01
  45. file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
  46. 导入 GPG key 0x352C64E5:
  47. 用户ID : "Fedora EPEL (7) <epel@fedoraproject.org>"
  48. 指纹 : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
  49. 软件包 : epel-release-7-9.noarch (@extras)
  50. 来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  51. 是否继续?[y/N]:y
  52. Running transaction check
  53. Running transaction test
  54. Transaction test succeeded
  55. Running transaction
  56. 正在安装 : jemalloc-3.6.0-1.el7.x86_64 1/2
  57. 正在安装 : redis-3.2.10-2.el7.x86_64 2/2
  58. 验证中 : redis-3.2.10-2.el7.x86_64 1/2
  59. 验证中 : jemalloc-3.6.0-1.el7.x86_64 2/2
  60.  
  61. 已安装:
  62. redis.x86_64 0:3.2.10-2.el7
  63.  
  64. 作为依赖被安装:
  65. jemalloc.x86_64 0:3.6.0-1.el7
  66.  
  67. 完毕!

4、service redis start  

   systemctl start redis.service   --开启redis服务

   redis-server /etc/redis.conf   --开启方式二

  1. [root@localhost ~]# service redis start
  2. Redirecting to /bin/systemctl start redis.service

5、ps -ef | grep redis   -- 查看redis是否开启

  1. [root@localhost ~]# systemctl start redis.service
  2. [root@localhost ~]# ps -ef|grep redis
  3. redis 5024 1 0 07:58 ? 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
  4. root 5054 4497 0 08:00 pts/0 00:00:00 grep --color=auto redis

6、redis-cli       -- 进入redis服务

  1. [root@localhost ~]# redis-cli
  2. 127.0.0.1:6379> ?
  3. redis-cli 3.2.10
  4. To get help about Redis commands type:
  5. "help @<group>" to get a list of commands in <group>
  6. "help <command>" for help on <command>
  7. "help <tab>" to get a list of possible help topics
  8. "quit" to exit
  9.  
  10. To set redis-cli perferences:
  11. ":set hints" enable online hints
  12. ":set nohints" disable online hints
  13. Set your preferences in ~/.redisclirc
  14. 127.0.0.1:6379> get
  15. (error) ERR wrong number of arguments for 'get' command
  16. 127.0.0.1:6379> get key
  17. (nil)
  18. 127.0.0.1:6379> get key abc
  19. (error) ERR wrong number of arguments for 'get' command
  20. 127.0.0.1:6379> set key abc
  21. OK
  22. 127.0.0.1:6379> get key abc
  23. (error) ERR wrong number of arguments for 'get' command
  24. 127.0.0.1:6379> get key
  25. "abc"
  26. 127.0.0.1:6379>

7、redis-cli  shutdown      --关闭服务

  1. [root@localhost ~]# redis-cli
  2. 127.0.0.1:6379> shutdown
  3. not connected>
  4. not connected>
  5. [root@localhost ~]# ps -ef |grep redis
  6. root 5127 4497 0 08:34 pts/0 00:00:00 grep --color=auto redis
  7. [root@localhost ~]# systemctl start redis.service
  8. [root@localhost ~]# ps -ef |grep redis
  9. redis 5134 1 0 08:34 ? 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
  10. root 5138 4497 0 08:35 pts/0 00:00:00 grep --color=auto redis
  11. [root@localhost ~]#

8、开放端口6379、6380的防火墙

/sbin/iptables -I INPUT -p tcp --dport 6379  -j ACCEPT   开启6379

/sbin/iptables -I INPUT -p tcp --dport 6380 -j ACCEPT  开启6380

  1. [root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
  2. [root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 6380 -j ACCEPT

9、使用redis  desktop manager连接redis

centos yum install redis的更多相关文章

  1. centos7 yum install redis

    直接yum 安装的redis 不是最新版本 yum install redis 如果要安装最新的redis,需要安装Remi的软件源,官网地址:http://rpms.famillecollet.co ...

  2. CentOS yum安装redis(转)

    1.安装redis yum install redis 2.安装php-redis扩展 yum install php-redis 3.启动redis,并设定开机自动启动 service redis ...

  3. Centos yum install

    http://wiki.centos.org/TipsAndTricks/BrokenVserver centos mirror:  http://mirror.centos.org/centos/6 ...

  4. CentOS 7 Install Redis

    1. yum install epel-release 2. yum install –y redis 3. start : systemctl start redis.service 4. stat ...

  5. centos yum安装redis,nginx

    先安装源 yum install epel-release 之后 分别安装redis,nginx

  6. centos yum install 找不到软件包

    yum install epel-release 然后再试试yum install 其他安装包

  7. centos yum install oracle java

    How to install Java on CentOS 7 | Linuxizehttps://linuxize.com/post/install-java-on-centos-7/ CentOS ...

  8. centos yum install nginx

    nginx newshttp://nginx.org/ nginx news: 2017http://nginx.org/2017.html nginx: Linux packageshttps:// ...

  9. Install Redis on CentOS 6.4--转

    Install Redis on CentOS 6.4 source:http://thoughts.z-dev.org/2013/05/27/install-redis-on-centos-6-4/ ...

随机推荐

  1. Java8 函数式编程详解

    Java8 函数式编程详解 Author:Dorae Date:2017年11月1日23:03:26 转载请注明出处 说起Java8,可能很多人都已经知道其最大的改进,就是引入了Lambda表达式与S ...

  2. Python Web框架篇:Django cookie和session

    part 1 概念 在Django里面,cookie和session都记录了客户端的某种状态,用来跟踪用户访问网站的整个回话. 两者最大的区别是cookie的信息是存放在浏览器客户端的,而sessio ...

  3. 【XML】xStream浅录

    XStream可以用来转换对象-XML,或者XML-对象. 官网地址:http://x-stream.github.io 小案例: 实体类 FileVo.java package cn.pinnsvi ...

  4. mysql服务处理流程

    先把错误日志定位 就是找的错误日志 然后必要的时候 重新启动服务器 排除其他的干扰 把错误日志 挪到旧文件 清空错误日志 然后试着启动 看干净的错误日志 然后 问题就解决了

  5. spring框架应用系列三:切面编程(带参数)

    本文系作者原创,转载请注明出处:http://www.cnblogs.com/further-further-further/p/7786715.html 解决问题 1.分离业务监控与业务处理.简单点 ...

  6. Increasing Speed Limits

    Increasing Speed Limits Time Limit: 2000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...

  7. Good Luck in CET-4 Everybody!

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...

  8. URI 方法 encodeURI() encodeURIComponent() docodeURI() decodeURIComponent()

    URI 方法  encodeURI()  encodeURIComponent()  docodeURI()  decodeURIComponent()   var sUri = “http://ww ...

  9. Spring IOC容器分析(2) -- BeanDefinition

    上文对Spring IOC容器的核心BeanFactory接口分析发现:在默认Bean工厂DefaultListableBeanFactory中对象不是以Object形成存储,而是以BeanDefin ...

  10. 基础进阶(一)之HashMap实现原理分析

    HashMap实现原理分析 1. HashMap的数据结构 数据结构中有数组和链表来实现对数据的存储,但这两者基本上是两个极端. 数组 数组存储区间是连续的,占用内存严重,故空间复杂的很大.但数组的二 ...