Ubuntu + redis Master/Slave Configuration

Source: Internet
Author: User

Software environment:

OS: ubuntu-12.04-desktop-amd64

Redis: redis-2.8.13.tar.gz

TCL: tcl8.6.2-src.tar.gz

VMware: VMware Workstation 10

OS: Win 7-64

First install the operating system, and then use the clone function to clone four copies:

This means that S0 is a group supplemented by S1;

S20-dominated, S21-supplemented by a group

1. Install redis:

Then, place the two packages downloaded above to the desktop (the configuration of each of the following virtual machines is the same, unless otherwise specified, S0 and S1 are used as examples ):

Decompress the package to the downloads directory and rename it (double-click and drag it in ):

Then install TCL (required ):

Use [CTL] + [alt] + [T] to start the terminal:

Go to the Tcl directory:

The command is as follows:

CD downloads

CD Tcl/Unix

Set parameters:

The command is as follows:

./Configure -- prefix =/usr

Effect

Then compile:

Command:

Make

The results are as follows:

Then:

After compilation is complete, install:

To use administrator permissions, enter the password. The command is as follows:

Sudo make install

The result is as follows:

Then you can choose to close this terminal and re-open one:

Similarly, compile first:

If an error occurs, enter:

Make clean

The following interface is displayed:

Then simulate the installation:

Command:

Make Test

The effect is as follows:

A total of 36 steps are required, especially the last step, which is difficult.

The interface is OK:

After redis is installed, you can shut down and clone it.

2. Configure the master-slave relationship:

Go to the redis directory of the first group of hosts:

Copy redis. conf to generate a slave Configuration

Command:

CD downloads/redis

CP redis. conf redis_slave.conf

Find the generated configuration file redis_slave.conf in the file directory ].

Then bind the IP address. Note that you need to set the bridging mode in the virtual machine to connect to the Internet. (Of course, your cat must support multiple machines. If not, please use Baidu to crack your cat );

View the current host IP Address:

Open redis_slave.conf and search for "bind" to set it to the current IP Address:

Save and close. copy the file and copy it to the same directory on the slave machine:

Search for "pidfile" after opening"

Changed:

Then, bind the slave IP Address:

The slave IP address is:

Set slave log records:

Set the dbfilename of the slave:

The last step is the most critical: Set the host connection:

We didn't change the port number, so all machines are 6379.

Iii. Verify the Master/Slave Configuration:

Start the master server

Redis-server redis. conf

Start the slave server:

Redis-server redis_slave.conf

This is slow to start because it needs to communicate with the host and there is no successful interface. We can view logs

You will know that you have connected to the host.

Enter the host to start the client and save a key:

The host is readable and writable.

Go to the slave machine to find this key:

It is also found that data cannot be written and can only be read.

After the Master/Slave configuration is complete, the read/write splitting in the code can be set to two IP addresses respectively.

Ubuntu + redis Master/Slave 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.