How to install configuration Redis and master-slave configuration under Linux

Source: Internet
Author: User
Tags mkdir redis linux

Advantages of Redis: Support master-slave backup, rich operation instructions, support asynchronous data persistence

Install the Redis to the/usr/local/webserver/redis

1. Download installation package

wget http://redis.googlecode.com/files/redis-2.2.15.tar.gz

Tar zxvf redis-2.2.15.tar.gz

CD redis-2.2.15

Make

Mkdir-p/usr/local/webserver/redis/conf

Mkdir-p/usr/local/webserver/redis/run

Mkdir-p/usr/local/webserver/redis/db

CP redis.conf/usr/local/webserver/redis/conf/

CD src

2. Copy all executable files in the SRC directory to the installation directory

CP Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server mkreleasehdr.sh

/usr/local/webserver/redis/

3. Modify the configuration file

-------vi/usr/local/webserver/redis/conf/redis.conf--------

Daemonize Yes--yes enable daemon

Pidfile/usr/local/webserver/redis/run/redis.pid--redis writes PID to file when running as daemon

DIR/USR/LOCAL/WEBSERVER/REDIS/DB--Directory of data storage

--------------------------------------------------------------

4. Create start and stop service scripts

-------vi/usr/local/webserver/redis/start.sh---------

#!/bin/bash

/usr/local/webserver/redis/redis-server/usr/local/webserver/redis/conf/redis.conf

-------vi/usr/local/webserver/redis/stop.sh---------

#!/bin/bash

Kill ' Cat/usr/local/webserver/redis/run/redis.pid '

chmod a+x/usr/local/webserver/redis/start.sh/usr/local/webserver/redis/stop.sh

5. Start Redis Service

/usr/local/webserver/redis/start.sh

Verify that the certificate service is successful:

Netstat-nlpt | grep 6379

6. Start Client Authentication

/usr/local/webserver/redis/redis-cli

>set Key1 Val1

>get Key1

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

Two. m/S Master cluster configuration

1 Master and one Slave

Master ip:127.0.0.1 port:6379

Slave1 ip:127.0.0.1 port:63791

2. Copy slave directory for easy Management

Cp-r/usr/local/webserver/redis/usr/local/webserver/redis-slave1

3. Modify slave configuration files and service scripts

--vi/usr/local/webserver/redis-slave1/conf/redis.conf--

Port 63791

Pidfile/usr/local/webserver/redis-slave1/run/redis.pid

dir/usr/local/webserver/redis-slave1/db

slaveof 127.0.0.1 6379

----------------------------------------------------------

--vi/usr/local/webserver/redis-slave1/start.sh--

#!/bin/bash

/usr/local/webserver/redis-slave1/redis-server/usr/local/webserver/redis-slave1/conf/redis.conf

---------------------------------------------------

-------vi/usr/local/webserver/redis-slave1/stop.sh---------

#!/bin/bash

Kill ' Cat/usr/local/webserver/redis-slave1/run/redis.pid '

--------------------------------------------------------

4. Start m/s service

/usr/local/webserver/redis/start.sh

/usr/local/webserver/redis-slave1/start.sh

Verify that the service is normal

Netstat-nlpt | grep redis-server

5. Verify that the Redis is valid

/USR/LOCAL/WEBSERVER/REDIS/REDIS-CLI [Default connection port: 6379 Master Service]

>set Key1 Val1

>quit

/usr/local/webserver/redis/redis-cli-p 63791 [connect Slave1 service]

>get Key1

"Val1″ (data has been successfully synchronized)

Multiple slave empathy configuration

Author: cnblogs Blueel

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.