redis安装之yum安装

一.通过yum安装redis

yum -y install redis

安装记录,可以看到安装的版本是3.2.12

[root@10-31-1-119 ~]# yum -y install redis
已加载插件:fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
base                                                                                                                                                                                 | 3.6 kB  00:00:00     
epel                                                                                                                                                                                 | 4.7 kB  00:00:00     
extras                                                                                                                                                                               | 2.9 kB  00:00:00     
mysql-connectors-community                                                                                                                                                           | 2.5 kB  00:00:00     
mysql-tools-community                                                                                                                                                                | 2.5 kB  00:00:00     
mysql57-community                                                                                                                                                                    | 2.5 kB  00:00:00     
percona-release-noarch                                                                                                                                                               | 2.9 kB  00:00:01     
percona-release-x86_64                                                                                                                                                               | 2.9 kB  00:00:00     
prel-release-x86_64                                                                                                                                                                  | 2.9 kB  00:00:00     
updates                                                                                                                                                                              | 2.9 kB  00:00:00     
(1/6): epel/x86_64/updateinfo                                                                                                                                                        | 1.0 MB  00:00:00     
(2/6): epel/x86_64/primary_db                                                                                                                                                        | 6.9 MB  00:00:00     
(3/6): percona-release-noarch/7/primary_db                                                                                                                                           |  24 kB  00:00:00     
(4/6): updates/7/x86_64/primary_db                                                                                                                                                   | 4.5 MB  00:00:00     
(5/6): prel-release-x86_64/7/primary_db                                                                                                                                              | 1.9 kB  00:00:02     
(6/6): percona-release-x86_64/7/primary_db                                                                                                                                           | 1.1 MB  00:01:02     
正在解决依赖关系
--> 正在检查事务
---> 软件包 redis.x86_64.0.3.2.12-2.el7 将被 安装
--> 正在处理依赖关系 libjemalloc.so.1()(64bit),它被软件包 redis-3.2.12-2.el7.x86_64 需要
--> 正在检查事务
---> 软件包 jemalloc.x86_64.0.3.6.0-1.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

============================================================================================================================================================================================================
 Package                                          架构                                           版本                                                    源                                            大小
============================================================================================================================================================================================================
正在安装:
 redis                                            x86_64                                         3.2.12-2.el7                                            epel                                         544 k
为依赖而安装:
 jemalloc                                         x86_64                                         3.6.0-1.el7                                             epel                                         105 k

事务概要
============================================================================================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:648 k
安装大小:1.7 M
Downloading packages:
(1/2): jemalloc-3.6.0-1.el7.x86_64.rpm                                                                                                                                               | 105 kB  00:00:00     
(2/2): redis-3.2.12-2.el7.x86_64.rpm                                                                                                                                                 | 544 kB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                                        3.4 MB/s | 648 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : jemalloc-3.6.0-1.el7.x86_64                                                                                                                                                             1/2 
  正在安装    : redis-3.2.12-2.el7.x86_64                                                                                                                                                               2/2 
  验证中      : redis-3.2.12-2.el7.x86_64                                                                                                                                                               1/2 
  验证中      : jemalloc-3.6.0-1.el7.x86_64                                                                                                                                                             2/2 

已安装:
  redis.x86_64 0:3.2.12-2.el7   

二.确认安装目录

find / -name 'redis*'

image.png

三.常用参数介绍

daemonize no      -- 是否后台运行
port 6379             -- 运行端口号
bind 127.0.0.1     -- 绑定IP
timeout 0             -- 连接关闭时间,0代表不开启此功能
loglevel notice     -- 日志级别

四.redis服务启动和停止

-- 启动redis
 redis-server /etc/redis.conf &
-- 关闭redis
redis-cli shutdown

[root@test~]# redis-cli shutdown
(error) NOAUTH Authentication required.
[root@test ~]# redis-cli
127.0.0.1:6379> shutdown
(error) NOAUTH Authentication required.
127.0.0.1:6379> 
127.0.0.1:6379> auth redis
OK
127.0.0.1:6379> shutdown
not connected> 
not connected> 
not connected> 


测试记录

[root@10-31-1-119 ~]# ps -ef | grep redis
root     14050 10708  0 14:13 pts/0    00:00:00 grep --color=auto redis
[root@10-31-1-119 ~]# 
[root@10-31-1-119 ~]# redis-server /etc/redis.conf &
[1] 14064
[root@10-31-1-119 ~]# 
[root@10-31-1-119 ~]# 
[root@10-31-1-119 ~]# ps -ef | grep redis           
root     14064 10708  0 14:13 pts/0    00:00:00 redis-server 127.0.0.1:6379
root     14071 10708  0 14:13 pts/0    00:00:00 grep --color=auto redis
[root@10-31-1-119 ~]# 
[root@10-31-1-119 ~]# 
[root@10-31-1-119 ~]# redis-cli shutdown
[1]+  完成                  redis-server /etc/redis.conf

五.简单的测试

5.1 telnet简单测试

[root@10-31-1-119 ~]# telnet localhost 6379
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

set test 1
+OK
get test
$1
1
set test 1001
+OK
get test
$4
1001

5.2 redis-cli简单测试

[root@10-31-1-119 ~]# redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> get test
"1001"
127.0.0.1:6379> set test 11011
OK
127.0.0.1:6379> get test
"11011"
127.0.0.1:6379> 

参考

1.http://www.cnblogs.com/myrunning/p/4222385.html

  • 4
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值