Centos7 Installing Redis

Source: Internet
Author: User
Tags mkdir redis
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.