一.通过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*'

三.常用参数介绍
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>
网友评论