redis搭建实战记录

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介:
Redis is an open source, advanced  key-value store . It is often referred to as a  data structure server  since keys can contain strings hashes lists sets  and  sorted sets .   

-- from http://redis.io/ 

 

redis  是一个基于内存的高性能key-value数据库,数据都保存在内存中定期刷新到磁盘,以极高的读写效率而备受关注。他的特点是支持各种数据结构,stirng,hashes, list,set,和sorted sets

client端对于不同数据结构是使用不同的命令

 

这里说一下redis的安装

虚拟机环境: centos 


1 wget  make 安装

wget http://download.redis.io/redis-stable.tar.gz

tar xvzf redis-stable.tar.gz

cd redis-stable

make

 

 这里记录一下我安装过程中出现的问题: 

make: Warning: File `Makefile' has modification time 5.4e+06 s in the future

cd src && make all

make[1]: Entering directory `/redis/redis-2.4.7/src'

make[1]: Warning: File `Makefile' has modification time 5.4e+06 s in the future

MAKE hiredis

make[2]: Entering directory `/redis/redis-2.4.7/deps/hiredis'

make[2]: Warning: File `Makefile' has modification time 5.4e+06 s in the future

cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings    -g -ggdb  net.c

make[2]: cc: Command not found

make[2]: *** [net.o] Error 127

make[2]: Leaving directory `/redis/redis-2.4.7/deps/hiredis'

make[1]: *** [dependencies] Error 2

make[1]: Leaving directory `/redis/redis-2.4.7/src'

make: *** [all] Error 2

 

 

第一个问题

make: Warning: File `Makefile' has modification time 5.4e+06 s in the future

系统时间调整错了,调过来就好了

 

第二个问题:

make[2]: Entering directory `/redis/redis-2.4.7/deps/hiredis'

cc -c -std=c99 -pedantic -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings    -g -ggdb  net.c

make[2]: cc: Command not found

没安装gcc

yum install gcc-c++

 

第三个问题:

make的时候显示

make[1]: Entering directory `/redis/redis-2.4.7/src'

which: no tclsh8.5 in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

You need 'tclsh8.5' in order to run the Redis test

没安装tcl

按照官网http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html 上的安装
 

安装完成之后,make成功!

 

安装成功之后会在src文件夹内有redis-server和redis-cli两个命令

建议将其放到bin

sudo cp redis-server /usr/local/bin/

sudo cp redis-cli /usr/local/bin/

 

 

好了,现在redis就安装成功了

 

2 测试redis安装情况 

我只在一台虚拟机上安装了redis,所以这台虚拟机既是服务器,又是客户端

测试:

 

使用secureRt打开一个会话,redis-server,让其作为服务器运行

[19282] 19 Feb 23:52:57 - 1 clients connected (0 slaves), 726248 bytes in use

[19282] 19 Feb 23:53:02 - DB 0: 1 keys (0 volatile) in 4 slots HT.

[19282] 19 Feb 23:53:02 - 1 clients connected (0 slaves), 726248 bytes in use

[19282] 19 Feb 23:53:07 - DB 0: 1 keys (0 volatile) in 4 slots HT.

[19282] 19 Feb 23:53:07 - 1 clients connected (0 slaves), 726248 bytes in use

 

打开另一个会话:

ast login: Tue Feb 19 22:49:49 2013 from 192.168.1.103


 

set keyget key都正确

redis搭建测试通过 

 

参考文章:

http://redis.io/ 

http://redis.io/topics/quickstart 

http://hi.baidu.com/thinkinginlamp/blog/item/3358c93d174e35ce9f3d62bf.html 

 

作者:yjf512(轩脉刃)

出处:http://www.cnblogs.com/yjf512/

本文版权归yjf512和cnBlog共有,欢迎转载,但未经作者同意必须保留此段声明

相关实践学习
基于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
目录
相关文章
|
缓存 NoSQL Java
Redis笔记1-redis的搭建和使用
1.   Redis的安装   1.1. Redis的安装 Redis是c语言开发的。 安装redis需要c语言的编译环境。如果没有gcc需要在线安装。yum install gcc-c++   安装步骤: 第一步:redis的源码包上传到linux系统。
1965 0
|
15天前
|
NoSQL Linux Redis
06- 你们使用Redis是单点还是集群 ? 哪种集群 ?
**Redis配置:** 使用哨兵集群,结构为1主2从,加上3个哨兵节点,总计分布在3台Linux服务器上,提供高可用性。
225 0
|
24天前
|
负载均衡 监控 NoSQL
Redis的集群方案有哪些?
Redis集群包括主从复制(基础,手动故障恢复)、哨兵模式(自动高可用)和Redis Cluster(官方分布式解决方案,自动分片和容错)。此外,还有如Codis、Redisson和Twemproxy等第三方工具用于代理和负载均衡。选择方案需考虑应用场景、数据规模和并发需求。
188 2
|
29天前
|
NoSQL Redis
Redis集群(六):集群常用命令及说明
Redis集群(六):集群常用命令及说明
186 0
|
2月前
|
运维 NoSQL 算法
Redis-Cluster 与 Redis 集群的技术大比拼
Redis-Cluster 与 Redis 集群的技术大比拼
82 0
|
23小时前
|
存储 NoSQL 算法
Redis 搭建分片集群
Redis 搭建分片集群
|
24天前
|
NoSQL Java 测试技术
面试官:如何搭建Redis集群?
**Redis Cluster** 是从 Redis 3.0 开始引入的集群解决方案,它分散数据以减少对单个主节点的依赖,提升读写性能。16384 个槽位分配给节点,客户端通过槽位信息直接路由请求。集群是无代理、去中心化的,多数命令直接由节点处理,保持高性能。通过 `create-cluster` 工具快速搭建集群,但适用于测试环境。在生产环境,需手动配置文件,启动节点,然后使用 `redis-cli --cluster create` 分配槽位和从节点。集群动态添加删除节点、数据重新分片及故障转移涉及复杂操作,包括主从切换和槽位迁移。
32 0
面试官:如何搭建Redis集群?
|
27天前
|
存储 缓存 NoSQL
【Redis深度专题】「核心技术提升」探究Redis服务启动的过程机制的技术原理和流程分析的指南(集群功能分析)(一)
【Redis深度专题】「核心技术提升」探究Redis服务启动的过程机制的技术原理和流程分析的指南(集群功能分析)
315 0
|
1月前
|
NoSQL Redis Docker
使用Docker搭建一个“一主两从”的 Redis 集群(超详细步骤)
使用Docker搭建一个“一主两从”的 Redis 集群(超详细步骤)
68 0
|
1月前
|
存储 监控 NoSQL
Redis 架构深入:主从复制、哨兵到集群
大家好,我是小康,今天我们来聊下 Redis 的几种架构模式,包括主从复制、哨兵和集群模式。
Redis 架构深入:主从复制、哨兵到集群

热门文章

最新文章