redis主从复制配置

master配置

主要是下面配置

# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1 192.168.1.102
################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass master

slave配置

# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of slaves.
# 2) Redis slaves are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition slaves automatically try to reconnect to masters
#    and resynchronize with them.
#
slaveof 192.168.1.102 6379

# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#
masterauth master
################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
requirepass slave

在master中开放redis的默认端口6379或者关闭防火墙: systemctl stop firewalld.service

firewall-cmd --zone=public --add-port=6379/tcp --permanent

最好是在slave中也开放redis的端口

在master中需要bind master的ip,否则在slave中可能会出现connect refused,具体原因还不清楚,现在刚开始研究redis,学习中。。。。

重启防火墙

firewall-cmd --reload
时间: 2024-10-31 12:40:14

redis主从复制配置的相关文章

Redis主从复制配置及测试

1. redis配置文件常用选项说明 daemonize no 说明:是否把redis-server启动在后台,默认是"否".若改成yes,会生成一个pid文件. pidfile /var/run/redis.pid 说明:redis-server的pid文件. port 6379 说明:redis-server的端口号 dbfilename dump.rdb 说明:数据库文件的位置,最好添加绝对路径,若不添加时在启动用户的home目录下. slaveof 说明:设置主从服务器的主服务

centos下面redis主从复制配置

从机配置 vim /etc/redis.conf slaveof 192.168.1.169 6379 slave-read-only no requirepass mima 启动redis-server /etc/redis.conf 主机不用配置 mima是主机的访问密码,没有可不填写 192.168.1.169 6379 是主服务器的IP 端口

主从复制配置

应用示例: 这里我们假设Master-Slave已经建立.    #启动master服务器.    [[email protected] redis]# redis-cli -p 6379    redis 127.0.0.1:6379>    #情况Master当前数据库中的所有Keys.    redis 127.0.0.1:6379> flushdb    OK    #在Master中创建新的Keys作为测试数据.    redis 127.0.0.1:6379> set myk

配置Redis主从复制

[构建高性能数据库缓存之redis主从复制][http://database.51cto.com/art/201407/444555.htm] 一.什么是redis主从复制? 主从复制,当用户往Master端写入数据时,通过Redis Sync机制将数据文件发送至Slave,Slave也会执行相同的操作确保数据一致:且实现Redis的主从复制非常简单. 二.redis主从复制特点 1.同一个Master可以拥有多个Slaves. 2.Master下的Slave还可以接受同一架构中其它slave的

Redis主从复制基本配置

实现Redis的主从复制配置比较简单,而且容易明白. 下图是要配置的主从复制结构图: 1.说明 Redis主从复制中一个主服务可以有多个从服务,一个从服务可以有多个从服务. 配置比较简单,只需要更改redis.conf文件中的slaveof参数配置即可. slaveof参数的格式如:slaveof <masterip> <masterport> 如果master服务器设置有密码则需要配置masterauth参数. masterauth参数格式如:masterauth <mas

redis的主从复制配置

redis的主从复制配置 一.     原理 Redis的主从复制功能非常强大,一个master可以拥有多个slave,而一个slave又可以拥有多个slave,如此下去,形成了强大的多级服务器集群架构.下面是关于redis主从复制的一些特点:1.master可以有多个slave2.除了多个slave连到相同的master外,slave也可以连接其他slave形成图状结构3.主从复制不会阻塞master.也就是说当一个或多个slave与master进行初次同步数据时,master可以继续处理cl

实现Redis的主从复制配置

实现Redis的主从复制配置比较简单,而且容易明白. 下图是要配置的主从复制结构图: 1.说明 Redis主从复制中一个主服务可以有多个从服务,一个从服务可以有多个从服务. 配置比较简单,只需要更改redis.conf文件中的slaveof参数配置即可. slaveof参数的格式如:slaveof <masterip> <masterport> 如果master服务器设置有密码则需要配置masterauth参数. masterauth参数格式如:masterauth <mas

Redis主从复制和集群配置

redis主从复制 概述 1.redis的复制功能是支持多个数据库之间的数据同步.一类是主数据库(master)一类是从数据库(slave),主数据库可以进行读写操作,当发生写操作的时候自动将数据同步到从数据库,而从数据库一般是只读的,并接收主数据库同步过来的数据,一个主数据库可以有多个从数据库,而一个从数据库只能有一个主数据库. 2.通过redis的复制功能可以很好的实现数据库的读写分离,提高服务器的负载能力.主数据库主要进行写操作,而从数据库负责读操作. 主从复制过程 主从复制过程:见下图

redis主从复制原理和配置

1.应用场景2.redis的读写速度虽然非常快了,当大量数据访问的时候,还是有点吃力的,主从复制可以分担一些压力,从结构上,单个Redis服务器会发生单点故障,并且一台服务器需要处理所有的请求负载,压力较大:从容量上,单个Redis服务器内存容量有限,就算一台Redis服务器内存容量为256G,也不能将所有内存用作Redis存储内存,一般来说,单台Redis最大使用内存不应该超过20G.2.基本原理3.详细配置192.168.98.27作为master,192.168.98.111和192.16