A, redis installation
redis installed yum and compiled in two ways, the paper installed to compile reference documentation for the official website of the installation documentation
1.gcc installation
2. Download the installation package
3. Extract compilation
4. Modify the configuration file
Main configuration amended as follows:
5. Production start the service
6. Start and join start-up service
7.RedisDesktopManager management tools
The tool is a graphical management tool redis
Download: https://pan.baidu.com/s/1no0IWcIEBapfehNi8dfCfw Password: 7dvc
Connection settings:
After connecting effect
Two, redis master-slave replication and persistence
1. From the Server Settings
redis master copy from very simple, only need to add a configuration from the server configuration file to
2. From the main test
The value written on 2.1 host
View from the machine redis key:
Value slave write 2.2
Found error, can not be written in a slave state redis.
3. endurance of
redis persistence has RDB and AOF in two ways, by default persisted as RDB mode, turn off the default persistence just need to comment on the default configuration line:
Three, keepalived installation configuration
1.keepalived installation
2.keepalived Configuration
Compared master, slave arranged in different three points:
In order to avoid switching back and forth between the master may be provided nopreemt parameters, open non-preemptive mode; however, when an abnormality occurs keepalived redis or various alarm is triggered, operation and maintenance personnel will timely intervention process.
3. Start and set the boot
Four, expect to install
expect is an interactive tool to provide automatic paper notify_master the script to use.
Fifth, high availability script
1.redis-check.sh script
The script for the examination of state redis
2.redis-master.sh script
The key to the script for this article highly available switching.
monitor 31 for the root password; ip slave script should be replaced 172.27.9.30; the script to the script execution server when switching master, first checks before the switching from the main master synchronization is complete, and then use the tool to jump to expect another server will change its status to redis slave.
3.exp.sh script
slave script as ip 172.27.9.31; the role of the script jumps to another service execution slaveof command.
Six test
1. Analog redis service exception
Operation: master of redis service stopped
Expected: vip drift, redis state of the slave master switch for the master
Testing process:
1.1 Stop master of redis service
View 1.2 virtual ip
Vip found by the drift 30-31
1.3 View redis state
redis 31 is switched to the state of the master
1.4 switchback
redis service starts 30
View vip status and redis
30:
31:
Conclusion: redis service switching occurs when abnormal, switch to master state to provide services from outside opportunities.
2. Analog keepalived service exception
Operation: master of keepalived service stopped
Expected: vip drift, redis state switched to the slave master, redis status of slave to master switch
Testing process:
2.1 Stop master of keepalived service
2.2 View vip status and redis
30:
31:
vip drift from the 30-31 and the master-slave reversed; open keepalived service will trigger the switching.
Conclusion: keepalived service switching occurs when abnormal, master-slave will reverse.
3. Analog master downtime
Operation: master shutdown
Expected: vip drift, redis status of slave to master switch
Testing process:
3.1master server shutdown
3.2 View vip status and redis
vip drift to 31 and the state switched to the master; 30 cut open the opportunity to return trigger.
Conclusion: The switch occurs when the master is down, switch to master state to provide services outside the machine.
This completes the redis availability test.