First, install redis
1, to download the package / data / download
Links: https://pan.baidu.com/s/1QXmfntFH9zimGCNpvaJmNQ extraction code: 3exa
2、tar -xvf redis-5.0.3.tar.gz
3、mv redis-5.0.3 /usr/local/
4、cd /usr/local/redis-5.0.3/
5、make
6、cd src/
7、make install
At this point of the installation work is complete redis
Let's look at a few of the compiled program are doing:
redis-server: As the name suggests, redis service
redis-cli: redis client, a redis client, for connection to redis service, and other operations performed CRUD
redis-sentinel: monitoring and management redis instance, and instance failover notification service
redis-benchmark: redis performance testing tool
redis-check-aof: In terms of AOF way to produce logs for quick fixes when an accident
redis-check-rdb: In terms of RDB way to generate logs when the accident for quick fix
II. Configuration from the start
To make redis-server can run automatically at system startup, redis services need to be as a daemon (daemon) to run, we go back to / usr / redis / directory to find a redis.conf file, this file is run redis service when loaded configuration, we first look at its contents
8, we /usr/local/redis-5.0.3/redis.conf
This document content is very long, but most of the comments, we focus on a few of these settings daemonize and pidfile and requirepass
Daemonize where the default value is false, pidfile default is pidfile /var/run/redis_6379.pid
The first indicates whether the daemon of, obviously we want to change it to daemonize yes;
The second means that when the service is running in daemon mode when, redis default will write /var/run/redis_6379.pid pid file services running in the file exists, the service is stopped once the file is automatically deleted, so you can use to determine whether redis running .
The third represents redis password, the default is annotated for the "", you can customize its password: requirepass xxxxxx
------ Here you can configure a custom log files: The default logging configuration is: logfile "", can be changed to "/data/redis/log/redis.log", but must create data / redis / log this file
9, with the basic configuration, redis also need to have a management startup, shutdown, restart a script. redis source in fact, has provided an initial script, the location in / usr / redis / utils / redis_init_script .
Command: vi /usr/local/redis-5.0.3/utils/redis_init_script view script file
It is important to note several configuration
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
Script specifies a port, server path, cli path, pidfile path and conf path, the above-mentioned places need to properly configure, say one more thing, if you perform a make install during the installation, the script does not need to do much change here, because make install both the server and cli copying / usr / local / bin below the
10, we need to copy the files in redis.conf redis directory to /etc/redis/6379.conf
Command: cd / etc
mkdir redis
/usr/local/redis-5.0.3/redis.conf cp / etc / repeat /
11, then copied to the script redis_init_script /etc/init.d/redisd
Command: cp /usr/local/redis-5.0.3/utils/redis_init_script /etc/init.d/redisd
12, all scripts in /etc/init.d can be started automatically during system startup Services
Command: chkconfig --add redisd
Adding to the self-starting
chkconfig --list to see a list of all self-priming
13, after everything is ready, you can execute the following command to verify whether the service successfully set
Command: Service redisd Start equivalent to /etc/init.d/redisd start
service redisd stop equivalent to /etc/init.d/redisd stop