Redis Master-slave replication configuration

Source: Internet
Author: User
Tags strong password

Master configuration

Mainly the following configuration

# ~ ~ ~ WARNING ~ ~ ~ If the computer running Redis isdirectly exposed to the# Internet, binding to all the interfaces isdangerous and would expose the# instance to everybody on the internet. so bydefaultWe uncomment the# following bind directive, that would force Redis to listen only into# the IPv4 lookbackInterfaceAddress ( Thismeans Redis would be able to# accept connections only fromclients running into the same computer it# isrunning). # # IF You is sure you want YOUR INSTANCE to LISTEN to all the interfaces# JUST COMMENT the following line.# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Bind127.0.0.1 192.168.1.102
################################## SECURITY #################################### Require clients to issue AUTH <PASSWORD>before processing any other# commands. This might is usefulinchEnvironmentsinchwhich DoNot trust# Others with access to the host running Redis-server.## This should stay commented out  forbackward compatibility and because most# people DoNot need auth (e.g. they run their own servers). # # Warning:since Redis isPretty fast an outside user canTryUp to# 150k passwords per second against a good box. This means, should# use a very strong password otherwise it 'll be very easy to Break. #requirepass Master

Slave configuration

#1) Redis Replication isasynchronous, but can configure a master to# stop accepting writesifIt appears to is not connected with at least# a given number of slaves.#2) Redis slaves is able to perform aPartialresynchronization with the# masterifThe replication link isLost fora relatively small amount of# time. Want to configure the replication backlog size (see the next# sections of Thisfile) with a sensible value depending on your needs.#3) Replication isautomatic and does not need user intervention. After a# network partition slaves automaticallyTryTo reconnect to masters# and resynchronize with them. #slaveof192.168.1.102 6379# If The master isPasswordprotected(usingThe"Requirepass"configuration# directive below) it ispossible to tell the slave to authenticate before# starting the replication synchronization process, otherwise the MA Ster will# refuse the slave request. #masterauth Master
################################## SECURITY #################################### Require clients to issue AUTH <PASSWORD>before processing any other# commands. This might is usefulinchEnvironmentsinchwhich DoNot trust# Others with access to the host running Redis-server.## This should stay commented out  forbackward compatibility and because most# people DoNot need auth (e.g. they run their own servers). # # Warning:since Redis isPretty fast an outside user canTryUp to# 150k passwords per second against a good box. This means, should# use a very strong password otherwise it 'll be very easy to Break. #requirepass slave

Open Redis's default port 6379 in master or turn off firewall: Systemctl stop Firewalld.service

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

It's best to open the Redis port in slave.

In master requires the IP of the bind master, otherwise in slave may appear the connect refused, the specific reason is not clear, now just began to study redis, learning ....

Restarting the firewall

Firewall-cmd--reload

Redis Master-slave replication configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.