redis安装,主从集群

1:服务端
  下载 $ wget http://download.redis.io/releases/redis-2.8.13.tar.gz
  解压 $ tar xzf redis-2.8.13.tar.gz
  $ cd redis-2.8.13
  编译 $ make
[[email protected] ~]$ tar xzf redis-2.8.13.tar.gz
[[email protected] ~]$ cd redis-2.8.13
[[email protected] redis-2.8.13]$ make
cd src && make all
......出现一大堆信息
Hint: To run 'make test' is a good idea ;)

make[1]: Leaving directory `/home/jifeng/redis-2.8.13/src'

[[email protected] redis-2.8.13]$ 

运行 $ src/redis-server

[[email protected] redis-2.8.13]$ src/redis-server
[6675] 10 Aug 17:19:48.837 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
[6675] 10 Aug 17:19:48.838 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[6675] 10 Aug 17:19:48.838 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[6675] 10 Aug 17:19:48.838 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6675
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'                                               

[6675] 10 Aug 17:19:48.839 # Server started, Redis version 2.8.13
[6675] 10 Aug 17:19:48.839 # 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.
[6675] 10 Aug 17:19:48.839 * The server is now ready to accept connections on port 6379

测试一下
  连接redis  $ src/redis-cli  

  设置键值  redis> set foo bar 
    OK 
  读取键值  redis> get foo  "bar"

2:集群配置
用一致性哈希,做多个主从,可以做主从集群。
主从配置
配置Master-Slave,只需要在Slave上配置Master节点IP Port:
[[email protected] redis-2.8.13]$ vi redis.conf
################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
#
# slaveof <masterip> <masterport>

修改上面最后一行

slaveof 10.3.7.212 6379

启动slave

[[email protected] redis-2.8.13]$ src/redis-server ./redis.conf
[6762] 10 Aug 17:46:46.907 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[6762] 10 Aug 17:46:46.907 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[6762] 10 Aug 17:46:46.907 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 2.8.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 6762
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'                                               

[6762] 10 Aug 17:46:46.915 # Server started, Redis version 2.8.13
[6762] 10 Aug 17:46:46.916 # 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.
[6762] 10 Aug 17:46:46.916 * DB loaded from disk: 0.000 seconds
[6762] 10 Aug 17:46:46.916 * The server is now ready to accept connections on port 6379
[6762] 10 Aug 17:46:47.916 * Connecting to MASTER 10.3.7.212:6379
[6762] 10 Aug 17:46:47.916 * MASTER <-> SLAVE sync started
[6762] 10 Aug 17:46:47.916 * Non blocking connect for SYNC fired the event.
[6762] 10 Aug 17:46:47.917 * Master replied to PING, replication can continue...
[6762] 10 Aug 17:46:47.917 * Partial resynchronization not possible (no cached master)
[6762] 10 Aug 17:46:47.917 * Full resync from master: 925b249e41d001e66c4e683983439c346b96571f:1
[6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: receiving 29 bytes from master
[6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Flushing old data
[6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Loading DB in memory
[6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Finished with success

测试

Master写,Slave读:

OK!!

redis安装,主从集群

时间: 2024-10-01 06:55:50

redis安装,主从集群的相关文章

redis安装与集群配置

Redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sorted set --有序集合)和hash(哈希类型).这些数据类型都支持push/pop.add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的.在此基础上,redis支持各种不同方式的排序.与memcached一样,为了保证效率,数据都是缓存在内存中.区别的是redis会周期性的把更新的数

Redis安装与集群搭建

1 1.1   安装redis n  版本说明 本教程使用redis3.0版本.3.0版本主要增加了redis集群功能. 安装的前提条件: 需要安装gcc:yum install gcc-c++ 1.下载redis的源码包. 2.把源码包上传到linux服务器 3.解压源码包 tar -zxvf redis-3.0.0.tar.gz 4.Make 5.Make install [[email protected] redis-3.0.0]# make install PREFIX=/usr/lo

redis部署主从集群问题

解压:      执行cd /home/redis/redis, 执行tar xvzf redis-stable.tar.gz.          2.安装GCC依赖: 执行 cd /home/redis/redis/redis-stable [[email protected]]# yum install gcc gcc-c++ #遇到选择,直接输入y即可 检查:gcc -v //用于查看gcc版本 3.然后安装 开始编译:PREFIX=/home/redis/redis make 检查编译结

读懂Redis并配置主从集群及高可用部署

一.背景 运维工作尤其是linux运维,其实最考验你的能力,因为需要学习的东西实在太多, 你既要懂网络:思科华为设备的配置: 要懂性能调优:包括lamp或者lnmp的性能调优,也包括linux操作系统调优: 要懂数据库mysql或者nosql(例如mongodb): 要懂编程语言:Shell是最基本的,还要学习perl,python,甚至ruby和C++等(因为一些软件是这些语言编写的),还得熟练掌握awk,sed,grep以及正则表达式: 要懂一些调试排错的命令工具的使用,比如htop,dst

主从集群搭建及容灾部署redis

redis主从集群搭建及容灾部署(哨兵sentinel) Redis也用了一段时间了,记录一下相关集群搭建及配置详解,方便后续使用查阅. 提纲 l  Redis安装 l  整体架构 l  Redis主从结构搭建 l  Redis容灾部署(哨兵sentinel) l  Redis常见问题 Redis安装 发行版:CentOS-6.6 64bit 内核:2.6.32-504.el6.x86_64 CPU:intel-i7 3.6G 内存:2G 下载redis,选择合适的版本 [[email prot

部署redis主从集群并开启哨兵模式

一.部署环境系统:centos7通过在Linux系统上启动两个不同的redis实例来完成主从集群的部署yum源已部署 二.redis的下载与安装1.下载:官网下载2.安装创建/app/目录,redis安装在/app/目录下 [[email protected] ~]# mkdir /app [[email protected] ~]# cd /usr/local/src/ [[email protected] src]# ls redis-4.0.11.tar.gz [[email protec

02.Redis主从集群的Sentinel配置

阅读目录 开始 1.集群环境 2.配置并启动Redis主从集群 3.配置sentinel集群并启动 4.测试sentinel集群 回到顶部 1.集群环境 1.Linux服务器列表 使用4台CentOS Linux服务器搭建环境,其IP地址如下: 192.168.110.100192.168.110.101192.168.110.102192.168.110.103 2.Redis服务部署环境 192.168.110.100    启动多个Redis sentinel服务,构成Redis sent

Redis中sentinel集群的搭建和Jedis测试 图文教程[三]

在前两篇Redis中sentinel集群的搭建和Jedis测试 图文教程[一] 和Redis中sentinel集群的搭建和Jedis测试 图文教程[二] 中分别简述了Redis中sentinel集群的搭建和Java代码的Jedis测试. 这篇主要来简单分析一下Redis-sentinel集群的原理,根据追踪sentinel信息来完成Redis-sentinel集群测试中的详细的原理分析.包括master-slave各个中的sentinel信息的分析,failover过程,master宕机后的le

Redis进阶实践之十一 Redis的Cluster集群搭建

原文:Redis进阶实践之十一 Redis的Cluster集群搭建 一.引言 本文档只对Redis的Cluster集群做简单的介绍,并没有对分布式系统的所涉及到的概念做深入的探讨.本文只是针对如何设置集群.测试和操作集群做了简述,并且从用户的角度描述了系统的行为,并不涉及Redis集群规范中所包含的细节.但是,本教程试图从最终用户的角度来解释有关Redis的Cluster集群的可用性和一致性的特点,并以简单易懂的方式讲解. 请注意,本教程需要使用Redis 3.0版本或更高版本. 如果您打算部署