CentOS7 install redis (5.0+) detailed explanation

first step

  • Download the redis installation package
  • You can go to the following address to view the version, redis download address
  • Enter the directory where you want to download the installation package (this article is in the **/usr/local/redis** directory), execute the statement to start downloading
wget http://download.redis.io/releases/redis-5.0.8.tar.gz

Insert picture description here

Second step

  • Give operation authority, 777representing all authority ( some systems may not need it )
chmod 777 redis-5.0.8.tar.gz

Insert picture description here

  • Unzip
tar -zxvf redis-5.0.8.tar.gz

Insert picture description here

third step

  • yum installs gcc dependency ( if you have installed it before, you can ignore this operation )
yum install gcc

the fourth step

  • Enter the decompression directory, install and compile
make 
make install

Insert picture description here
Insert picture description here

the fifth step

  • Modify the configuration file and start redis
  • Copy redis.conf as a configuration file ( generally not modify the original file, so as to avoid the error being unrecoverable )
cp redis.conf redis01.conf 
vim redis.conf
  • Modify the following content

Insert picture description here

  • Will be daemonize nomodified to daemonize yesindicate that it can be started in the background. If you want to connect remotely, change the ip to your public network or 0.0.0.0, simple and rude!
  • Enter the src directory to specify the configuration file to start
cd src
./redis-server /usr/local/redis/redis-5.0.8/redis.conf
  • View process
ps -ef | grep redis

Insert picture description here

Sixth step

  • Set boot up automatically (see personal favorite)
  • In /etcNew redis directory directory
mkdir -p redis

Insert picture description here

  • Copy the /usr/local/redis/redis-5.0.8/redis.conf file to the /etc/redis directory and name it 6379.conf
cp /usr/local/redis/redis-5.0.8/redis.conf /etc/redis/6379.conf
  • Copy the redis startup script and place it in the /etc/init.d directory
cp /usr/local/redis/redis-5.0.8/utils/redis_init_script /etc/init.d/redisd
  • Enter the /etc/init.ddirectory, modify the file
vim redisd
  • Add the following content: The comment means that the redis service must be started or closed at run levels 2, 3, 4, and 5. The start priority is 90, and the shutdown priority is 10. Save and exit
# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database

Insert picture description here

  • Execute boot command
chkconfig redisd on

Seventh step

  • The test starts with the service name
service redisd start
  • If it appears: /var/run/redis_6379.pid exists, process is already running or crashed , execute the following command and then re-execute the above command.
rm -rf /var/run/redis_6379.pid
service redisd start

Insert picture description here

  • shut downservice redisd stop

Insert picture description here

  • Test connection
    Insert picture description here

Guess you like

Origin blog.csdn.net/JISOOLUO/article/details/105015970