Before start
- Download and install redis from official site
- redis excutable commands are under
bin
folder, configs are underetc
folder, logs are undervar
folder
Redis master
Configuration
1 |
|
Start Master
1 | redis-server /redis/etc/{master.config} |
Verify Master
1 | redis-cli -h 127.0.0.1 -p 6379 -a password info replication |
You should see something like this, if you have slave you will see number of connected_slaves
:
1 | [root@lx-uk-ssm129 redis]# bin/redis-cli -p 6379 -a password info replication |
Redis slave
Configuration
Repeat master configuration, change your port, bind ip…etc, the only difference are two lines :
1 | # Specify master instance location |
Start Slave
1 | redis-server /redis/etc/{slave.config} |
Verify Slave
1 | redis-cli -h 127.0.0.1 -p 6379 -a password info replication |
You will see something like this :
1 | [root@example redis]# bin/redis-cli -h 127.0.0.1 -p 8879 -a password info replication |
Sentinel
Create sentinel.conf
1 | # port to run sentinel |
Start sentinel
1 | redis-server sentinel.conf --sentinel |
Verify sentinel
1 | redis-cli -h 127.0.0.1 -p 26379 info sentinel |
Useful commands
1 | # check redis instance |
A little note for yaml format
- Normally you don’t need quote for string,
- If string contains special character, use quote
""
or''
- Difference between
""
or''
is double quote parse escape character but single quote doesn’t