1. Redis Profile Common Options description
Daemonize No
Note: Whether to start the redis-server in the background, the default is "no". If you change to Yes, a PID file is generated.
Pidfile/var/run/redis.pid
Description: Redis-server pid file.
Port 6379
Description: The port number of the Redis-server
Dbfilename Dump.rdb
Description: The location of the database files, it is best to add an absolute path, if not added in the start user's home directory.
Slaveof
Description: Sets the address and port of the primary server for the master-slave server. Example: slaveof192.168.1.1 6379
LogLevel verbose
Description: Log level, there are four kinds, debug,verbose,notice,warning.
LogFile stdout
Note: The output file for the log is standard output by default. Example: Logfile/tmp/redis.log
2. master-Slave installation and configuration
2.1 Basic Environment
Suppose I have two machines:
master:192.168.1.116
slave:192.168.1.145
. download
The version used is: redis-3.2.1
>CD redis-3.2.1
>make
>sudo make Install
2.2 Installing the master server
Vim redis.conf
Modify some parameters according to your needs
. Modify the location on the disk where the database files are saved: (not modified)
Dbfilename/redisdb/dump.rdb
. modifying the log level
#如果只要输出少量日志的话, can use Waring (notice)
LogLevel Warning
. Modify the location of the log file
LogFile Redis-3.2.1/data/logs/redis.log
. Modify the binding address (otherwise it will appear: Error condition on socket for sync:connection refused, slave cannot connect to host)
bind0.0.0.0
2.3 Installing and configuring the Slave machine
Vim redis.conf configures the IP address of master and the port of Redis-server.
Find #slaveof <masterip><masterport> This line, add a line below it, as follows
Slaveof 192.168.1.116 6379 where 192.168.1.116 6379 represents the IP address and port number of master respectively.
3. Start and test
Host:./redis-server. /redis.conf
Slave machine:./redis-server. /redis_slave.conf
This test starts in the SRC directory
Note: If you use the./redis-server boot server, this warning will be reported, indicating that the server is not booting according to the redis.conf file you configured, Warning:no configfile specified, using the default Config. In order to specify a config file use./src/redis-server/path/to/redis.conf, so use the./src/redis-server/path/to/ redis.conf mode starts.
3.1 Testing
To start the Redis client on the host:
Start the REDIS-CLI client on the 192.168.1.116master host and execute the following command
>set name Masteradd
>get Name
"Masteradd"
. Log in from the machine and start the client on the slave:
Start the REDIS-CLI client on 192.168.1.145 slave and execute the following command
>get Name
"Masteradd"
You can see that Redis has synced the data.
3.2 Viewing Master host status
To enter REDIS-CLI, use the following command
>info
You can see that the master host's Slave is 192.168.1.145 and its related information.
Stop Redis Server command: redis-cli–hlocalhost–p 6379 shutdown
Redis Master-slave replication configuration and testing