1. Download the installation package, unzip, build the soft chain
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
tar zxvf redis-4.0.8.tar.gz-c/opt
cd/opt
Ln -SV Redis-4.0.8/redis
Redis and redis-4.0.8 Two folders will be available in the/OPT directory at this time. 2. Compiling
CD Redis make
After compiling, you can see that the extracted files in Redis will have corresponding SRC, conf and other files (clips).
CD src make
Install
At this point, no error is installed, it is ready to use. The configuration file is below/opt/redis, and the command is under/OPT/REDIS/SRC. 3. To facilitate management, move the Conf profile and common commands in the Redis file to a unified file
Mkdir-p/opt/redis/bin
mkdir-p/opt/redis/ect
cd/opt/redis
mv redis.conf etc/
cd src
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server redis-sentinel redis-trib.rb Redis-check-rdb. /bin
4. Setting Up background startup
Cd/opt/redis/etc
Vim redis.conf
Edit the redis.conf file, change the Daemonize property to Yes (indicates that you need to run in the background) 5. Run
Start the service side
Cd/opt/redis/bin
./redis-server. /etc/redis.conf
Client connections
Redis-cli
The following screen appears, indicating that the installation was successful.
6. Set up environment variables and make them effective
vim/etc/profile.d/redis.sh
export Redis_home=/opt/redis
export path= $PATH: $REDIS _home/bin
#source/ etc/profile.d/redis.sh
7. Configuring Redis for System Services
sudo vim/usr/lib/systemd/system/redis.service
Write the following and save (path according to your actual situation):
[Unit]
Description=redis
after=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
pidfile=/var/run/redis_6379.pid
execstart=/opt/redis/bin/redis-server/opt/redis/etc/ redis.conf
execreload=/bin/kill-s HUP $MAINPID
execstop=/bin/kill-s QUIT $MAINPID
privatetmp=true
[Install]
Wantedby=multi-user.target
Heavy-duty system services
sudo systemctl daemon-reload
Start/Stop Redis
Systemctl start Redis
systemctl stop Redis
8. Configuring Kernel Parameters
Configure the following kernel parameters, or the Redis script will error when restarting or stopping Redis, and cannot automatically synchronize data to disk before stopping the service
sudo vim/etc/sysctl.conf
vm.overcommit_memory = 1 # Add this line