redis 安装和使用

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介:

环境:centos6.5  

安装gcc、gcc-c++编译的环境

1、下载Redis

wget http://download.redis.io/releases/redis-2.8.3.tar.gz

2、解压

tar xf redis-2.8.3.tar.gz -C /usr/src/

cd /usr/src/redis-2.8.3/

3、安装Redis之前测试一下make test(执行make test必须先安装tcl语言包)

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz

tar xf tcl8.6.1-src.tar.gz

cd tcl8.6.1/unix/

./configure && make && make install

这个时候在命令行就可以输入tclsh进入tcl解释器 tcl就可以使用了。

4、安装

[root@moban src]# make PREFIX=/usr/local/redis install

[root@moban src]# cd /usr/local/redis/

[root@moban redis]# ls

bin

[root@moban redis]# cd bin/

[root@moban bin]# ls

redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis-server

[root@moban bin]# cp /usr/src/redis-2.8.3/redis.conf /usr/local/redis

[root@localhost redis]# ls

bin  redis.conf 到这里redis已经安装成功了

5、启动Redis

方法一:进入 安装路径下的bin下

[root@localhost redis]# cd bin

[root@localhost bin]# ./redis-server redis.conf

[23753] 13 Nov 00:43:50.340 * Max number of open files set to 10032

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 2.8.3 (00000000/0) 64 bit

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

 (    '      ,       .-`  | `,    )     Running in stand alone mode

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

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

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

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

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

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

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

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

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

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

          `-._        _.-'                                           

              `-.__.-'                                               


[23753] 13 Nov 00:43:50.342 # Server started, Redis version 2.8.3

[23753] 13 Nov 00:43:50.342 * DB loaded from disk: 0.000 seconds

[23753] 13 Nov 00:43:50.342 * The server is now ready to accept connections on port 6379

这样其实已经启动成功了,但是这属于前端启动,启动redis之后,我们的控制台就不能进行任何操作了。只能ctrl+c停止启动。

方法二:后台启动

编辑redis.conf文件  daemonize no 改为yes保存退出

再次启动

[root@localhost bin]# ./redis-server redis.conf

查看启动成功没有:

netstat -anptl |grep redis

[root@moban redis]# netstat -antp|grep redis

tcp        0      0 0.0.0.0:6379                0.0.0.0:*                   LISTEN      23767/./bin/redis-s 

tcp        0      0 :::6379                     :::*                        LISTEN      23767/./bin/redis-s

6、关闭redis

[root@localhost redis]# ./bin/redis-cli shutdown

7、简单的使用

//连接客户端

[root@moban redis]# ./bin/redis-cli 

127.0.0.1:6379>

//检查网络是否通

127.0.0.1:6379> ping

PONG

//设置一个键值对

127.0.0.1:6379> set name cheny

OK

//获取刚刚设置的键值对

127.0.0.1:6379> get name

"cheny"

//查看所有的键

127.0.0.1:6379> keys *

1) "name"

//删除name这个键

127.0.0.1:6379> del name

(integer)

1127.0.0.1:6379> keys * (empty list or set)

127.0.0.1:6379>

到这里简单的redis安装就好了












本文转自liujing0751CTO博客,原文链接:http://blog.51cto.com/13281352/1981017 ,如需转载请自行联系原作者




相关实践学习
基于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
相关文章
|
7天前
|
NoSQL Linux 测试技术
Redis的安装(Linux版)
Redis的安装(Linux版)
149 1
|
17天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
17 0
|
2月前
|
NoSQL Redis 数据安全/隐私保护
Docker中Redis的安装与配置
本文主要讲解如何在Docker环境中搭建Redis环境,并进行相关配置
247 5
Docker中Redis的安装与配置
|
1月前
|
NoSQL Linux Redis
Linux系统中安装redis+redis后台启动+常见相关配置
Linux系统中安装redis+redis后台启动+常见相关配置
|
2月前
|
NoSQL Redis Docker
在docker中安装redis,并且阿里云服务器配置
在docker中安装redis,并且阿里云服务器配置
187 1
|
25天前
|
NoSQL Linux Redis
Linux安装Redis
Linux安装Redis
29 0
|
29天前
|
NoSQL 关系型数据库 MySQL
安装Docker&镜像容器操作&使用Docker安装部署MySQL,Redis,RabbitMQ,Nacos,Seata,Minio
安装Docker&镜像容器操作&使用Docker安装部署MySQL,Redis,RabbitMQ,Nacos,Seata,Minio
373 1
|
1月前
|
NoSQL 关系型数据库 MySQL
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
221 0
|
1月前
|
NoSQL Redis 数据安全/隐私保护
Docker安装和使用Redis
Docker安装和使用Redis
78 0
|
2月前
|
存储 NoSQL Redis
【docker专题_06】docker安装redis
【docker专题_06】docker安装redis

热门文章

最新文章