The steps for optimizing replication are as follows:
- Open a console and switch the current user to root. Then set some variables in the console for the basic information of a master and slave:
$ M_IP=127.0.0.1 $ M_PORT=6379 $ M_RDB_NAME=master.rdb $ M_OUT=master.out $ S1_IP=127.0.0.2 $ S1_PORT=6380 $ S1_OUT=slave_1.out $ S1_RDB_NAME=slave_1.rdb
- Start the two Redis instances:
$ nohup /redis/bin/redis-server --port $M_PORT --bind $M_IP --dbfilename $M_RDB_NAME > $M_OUT & $ nohup /redis/bin/redis-server --port $S1_PORT --bind $S1_IP --dbfilename $S1_RDB_NAME > $S1_OUT&
- Sleep for a while to wait for the Redis instances to finish their startup. After the sleep, we set some sample data to one of the Redis instances:
$ sleep ...