Redis安装与卸载(一)

本文涉及的产品
云数据库 Tair(兼容Redis),内存型 2GB
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介: Redis安装与卸载(一)

Redis是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。它支持丰富的数据类型,和高速的内存读写。正在逐步取代memcached的地位。



1、安装



 ①我们可以通过在官网下载tar.gz的安装包,或者通过wget的方式下载  


[root@localhost data]# wget http://download.redis.io/releases/redis-4.0.1.tar.gz
--2017-09-03 09:51:27--  http://download.redis.io/releases/redis-4.0.1.tar.gz
正在解析主机 download.redis.io... 109.74.203.151
正在连接 download.redis.io|109.74.203.151|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1711660 (1.6M) [application/x-gzip]
正在保存至: “redis-4.0.1.tar.gz”
57% [=====================================>                             ] 981,091      298K/s eta(英国中部时
64% [==========================================>                        ] 1,105,869    309K/s eta(英国中部时
72% [===============================================>                   ] 1,237,657    321K/s eta(英国中部时
80% [====================================================>              ] 1,376,455    334K/s eta(英国中部时
86% [========================================================>          ] 1,478,801    341K/s eta(英国中部时
92% [============================================================>      ] 1,582,549    349K/s eta(英国中部时
100%[==================================================================>] 1,711,660    380K/s   in 4.6s
2017-09-03 09:51:32 (363 KB/s) - 已保存 “redis-4.0.1.tar.gz” [1711660/1711660])
[root@localhost data]#


 ②解压


tar  -zxvf  redis-4.0.1.tar.gz


 ③移动到/local/usr/redis目录下去,这个纯属个人爱好


[root@localhost data]# ll
总用量 1676
drwxrwxr-x. 6 root root    4096 7月  24 22:58 redis-4.0.1
-rw-r--r--. 1 root root 1711660 7月  24 22:59 redis-4.0.1.tar.gz
[root@localhost data]# mv redis-4.0.1 ../redis
[root@localhost data]# cd ..
[root@localhost local]# ll
总用量 44
drwxr-xr-x. 2 root root 4096 9月   3 09:43 bin
drwxr-xr-x. 2 root root 4096 9月   3 10:04 data
drwxr-xr-x. 2 root root 4096 9月  23 2011 etc
drwxr-xr-x. 2 root root 4096 9月  23 2011 games
drwxr-xr-x. 2 root root 4096 9月  23 2011 include
drwxr-xr-x. 2 root root 4096 9月  23 2011 lib
drwxr-xr-x. 2 root root 4096 9月  23 2011 libexec
drwxrwxr-x. 6 root root 4096 7月  24 22:58 redis
drwxr-xr-x. 2 root root 4096 9月  23 2011 sbin
drwxr-xr-x. 5 root root 4096 4月   1 04:48 share
drwxr-xr-x. 2 root root 4096 9月  23 2011 src
[root@localhost local]# cd redis
[root@localhost redis]# ll
总用量 276
-rw-rw-r--.  1 root root 127778 7月  24 22:58 00-RELEASENOTES
-rw-rw-r--.  1 root root     53 7月  24 22:58 BUGS
-rw-rw-r--.  1 root root   1815 7月  24 22:58 CONTRIBUTING
-rw-rw-r--.  1 root root   1487 7月  24 22:58 COPYING
drwxrwxr-x.  6 root root   4096 7月  24 22:58 deps
-rw-rw-r--.  1 root root     11 7月  24 22:58 INSTALL
-rw-rw-r--.  1 root root    151 7月  24 22:58 Makefile
-rw-rw-r--.  1 root root   4223 7月  24 22:58 MANIFESTO
-rw-rw-r--.  1 root root  20530 7月  24 22:58 README.md
-rw-rw-r--.  1 root root  57764 7月  24 22:58 redis.conf
-rwxrwxr-x.  1 root root    271 7月  24 22:58 runtest
-rwxrwxr-x.  1 root root    280 7月  24 22:58 runtest-cluster
-rwxrwxr-x.  1 root root    281 7月  24 22:58 runtest-sentinel
-rw-rw-r--.  1 root root   7606 7月  24 22:58 sentinel.conf
drwxrwxr-x.  3 root root   4096 7月  24 22:58 src
drwxrwxr-x. 10 root root   4096 7月  24 22:58 tests
drwxrwxr-x.  8 root root   4096 7月  24 22:58 utils
[root@localhost redis]# cd ..
[root@localhost local]#


 ④接下来就是编译了,通过make命令,如果编译的时候报gcc命令找不到的话,可以通过下面的命令安装gcc命令,gcc是c的编译命令


yum install gcc-c++


 下面就通过make来编译,make是自动编译,会根据Makefile中描述的内容来进行编译。


[root@localhost redis]# make
cd src && make all
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
.
.
.
.
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory `/usr/local/redis/src'
[root@localhost redis]#


 ⑤可以看到在src目录下生成了几个新的文件。


[root@localhost redis]# ll -tr src
总用量 44440
-rw-rw-r--. 1 root root    3779 7月  24 22:58 zmalloc.h
.
.
.
-rw-r--r--. 1 root root   56148 9月   3 10:11 rax.o
-rwxr-xr-x. 1 root root 7185836 9月   3 10:11 redis-server
-rwxr-xr-x. 1 root root 7185836 9月   3 10:11 redis-sentinel
-rw-r--r--. 1 root root  143800 9月   3 10:11 redis-cli.o
-rwxr-xr-x. 1 root root 5092431 9月   3 10:11 redis-cli
-rw-r--r--. 1 root root   44892 9月   3 10:11 redis-benchmark.o
-rwxr-xr-x. 1 root root 4985275 9月   3 10:11 redis-benchmark
-rwxr-xr-x. 1 root root 7185836 9月   3 10:11 redis-check-rdb
-rwxr-xr-x. 1 root root 7185836 9月   3 10:11 redis-check-aof
[root@localhost redis]#


 为了使用方便,我们需要将这个几个文件加到/usr/local/bin目录下去。这个目录在Path下面的话,就可以直接执行这几个命令了。


[root@localhost redis]# make install
cd src && make install
make[1]: Entering directory `/usr/local/redis/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis/src'
make[1]: Entering directory `/usr/local/redis/src'
Hint: It's a good idea to run 'make test' ;)
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis/src'
[root@localhost redis]# cd ..
[root@localhost local]# ll
总用量 44
drwxr-xr-x. 2 root root 4096 9月   3 10:16 bin
drwxr-xr-x. 2 root root 4096 9月   3 10:04 data
drwxr-xr-x. 2 root root 4096 9月  23 2011 etc
drwxr-xr-x. 2 root root 4096 9月  23 2011 games
drwxr-xr-x. 2 root root 4096 9月  23 2011 include
drwxr-xr-x. 2 root root 4096 9月  23 2011 lib
drwxr-xr-x. 2 root root 4096 9月  23 2011 libexec
drwxrwxr-x. 6 root root 4096 7月  24 22:58 redis
drwxr-xr-x. 2 root root 4096 9月  23 2011 sbin
drwxr-xr-x. 5 root root 4096 4月   1 04:48 share
drwxr-xr-x. 2 root root 4096 9月  23 2011 src
[root@localhost local]# ll bin
总用量 30908
-rwxr-xr-x. 1 root root 4985275 9月   3 10:16 redis-benchmark
-rwxr-xr-x. 1 root root 7185836 9月   3 10:16 redis-check-aof
-rwxr-xr-x. 1 root root 7185836 9月   3 10:16 redis-check-rdb
-rwxr-xr-x. 1 root root 5092431 9月   3 10:16 redis-cli
lrwxrwxrwx. 1 root root      12 9月   3 10:16 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 7185836 9月   3 10:16 redis-server
[root@localhost local]#


可以看到,这几个文件就已经被加载到bin目录下了


 ⑥下面启动服务器,来看看安装是否成功。使用redis-server命令。  


[root@localhost local]# redis-server
9190:C 03 Sep 10:19:09.291 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9190:C 03 Sep 10:19:09.292 # Redis version=4.0.1, bits=32, commit=00000000, modified=0, pid=9190, just started
9190:C 03 Sep 10:19:09.292 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
9190:M 03 Sep 10:19:09.295 * Increased maximum number of open files to 10032 (it was originally set to 1024).
9190:M 03 Sep 10:19:09.312 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.


               _._

          _.-``__ ''-._

     _.-``    `.  `_.  ''-._           Redis 4.0.1 (00000000/0) 32 bit

 .-`` .-```.  ```\/    _.,_ ''-._

(    '      ,       .-`  | `,    )     Running in standalone mode

|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

|    `-._   `._    /     _.-'    |     PID: 9190

 `-._    `-._  `-./  _.-'    _.-'

|`-._`-._    `-.__.-'    _.-'_.-'|

|    `-._`-._        _.-'_.-'    |           http://redis.io

 `-._    `-._`-.__.-'_.-'    _.-'

|`-._`-._    `-.__.-'    _.-'_.-'|

|    `-._`-._        _.-'_.-'    |

 `-._    `-._`-.__.-'_.-'    _.-'

     `-._    `-.__.-'    _.-'

         `-._        _.-'

             `-.__.-'


9190:M 03 Sep 10:19:09.316 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9190:M 03 Sep 10:19:09.316 # Server initialized
9190:M 03 Sep 10:19:09.318 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
9190:M 03 Sep 10:19:09.318 * Ready to accept connections



 看到这个界面的话,就表示安装成功了。


 下面通过在启动一个linux客户端,通过server-cli shutdown来关闭服务器。


[root@localhost ~]# redis-cli shutdown
[root@localhost ~]#
下面是刚刚服务器启动的客户端的log
9190:M 03 Sep 10:20:45.566 # User requested shutdown...
9190:M 03 Sep 10:20:45.566 * Saving the final RDB snapshot before exiting.
9190:M 03 Sep 10:20:45.631 * DB saved on disk
9190:M 03 Sep 10:20:45.631 # Redis is now ready to exit, bye bye...
[root@localhost local]#


相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
2月前
|
NoSQL 关系型数据库 Redis
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
《docker高级篇(大厂进阶):1.Docker复杂安装详说》包括:安装mysql主从复制、安装redis集群
123 14
|
1月前
|
关系型数据库 MySQL 应用服务中间件
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
《docker基础篇:8.Docker常规安装简介》包括:docker常规安装总体步骤、安装tomcat、安装mysql、安装redis
120 7
|
2月前
|
NoSQL 算法 Redis
docker高级篇(大厂进阶):安装redis集群
docker高级篇(大厂进阶):安装redis集群
167 24
|
2月前
|
NoSQL 关系型数据库 MySQL
Linux安装jdk、mysql、redis
Linux安装jdk、mysql、redis
216 7
|
3月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
137 4
|
4月前
|
NoSQL 数据可视化 Linux
redis学习四、可视化操作工具链接 centos redis,付费Redis Desktop Manager和免费Another Redis DeskTop Manager下载、安装
本文介绍了Redis的两个可视化管理工具:付费的Redis Desktop Manager和免费的Another Redis DeskTop Manager,包括它们的下载、安装和使用方法,以及在使用Another Redis DeskTop Manager连接Redis时可能遇到的问题和解决方案。
197 1
redis学习四、可视化操作工具链接 centos redis,付费Redis Desktop Manager和免费Another Redis DeskTop Manager下载、安装
|
3月前
|
存储 SQL 关系型数据库
2024Mysql And Redis基础与进阶操作系列(1)作者——LJS[含MySQL的下载、安装、配置详解步骤及报错对应解决方法]
Mysql And Redis基础与进阶操作系列(1)之[MySQL的下载、安装、配置详解步骤及报错对应解决方法]
|
4月前
|
NoSQL Ubuntu Linux
Redis 安装
10月更文挑战第14天
122 1
|
4月前
|
NoSQL Linux Redis
Docker学习二(Centos):Docker安装并运行redis(成功运行)
这篇文章介绍了在CentOS系统上使用Docker安装并运行Redis数据库的详细步骤,包括拉取Redis镜像、创建挂载目录、下载配置文件、修改配置以及使用Docker命令运行Redis容器,并检查运行状态和使用Navicat连接Redis。
523 3
|
3月前
|
NoSQL 编译器 Linux
【赵渝强老师】Redis的安装与访问
本文基于Redis 6.2版本,详细介绍了在CentOS 7 64位虚拟机环境中部署Redis的步骤。内容包括安装GCC编译器、创建安装目录、解压安装包、编译安装、配置文件修改、启动服务及验证等操作。视频讲解和相关图片帮助理解每一步骤。