Home  >  Article  >  Database  >  Centos7.6 installation Redis instance analysis

Centos7.6 installation Redis instance analysis

WBOY
WBOYforward
2023-06-03 08:28:061052browse

1. Install gcc dependencies

Since redis is developed in C language, you must first confirm whether the gcc environment (gcc -v) is installed before installation. If it is not installed, execute the following command to install it

[root@localhost local]# yum install -y gcc

2. Download and unzip the installation package

[root@localhost local]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz

[root@localhost local]# tar -zxvf redis-5.0.3.tar .gz

3. cd to the redis decompression directory and execute compilation

[root@localhost local]# cd redis-5.0.3

[root@localhost redis-5.0.3]# make

4. Install and specify the installation directory

[root@localhost redis- 5.0.3]# make install PREFIX=/usr/local/redis

5. Start the service

5.1 Start the front desk

[root@localhost redis-5.0.3]# cd /usr/local/redis/bin/

[root@localhost bin]# ./redis-server

5.2 Background startup

Copy redis.conf from the redis source code directory to the redis installation directory

[root@localhost bin]# cp /usr/local/redis-5.0. 3/redis.conf /usr/local/redis/bin/

Modify the redis.conf file and change daemonize no to daemonize yes

[root@localhost bin ]# vi redis.conf

Centos7.6 installation Redis instance analysis

Background startup

[root@localhost bin]# ./redis-server redis.conf

Centos7.6 installation Redis instance analysis

6. Set up startup

Add startup service

[root@localhost bin]# vi /etc/systemd/system/redis.service

Copy and paste the following content:

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Note: Configure ExecStart to your own path

Set startup

[root@localhost bin]# systemctl daemon-reload

[root@localhost bin]# systemctl start redis.service

[root@ localhost bin]# systemctl enable redis.service

Create redis command soft link

[root@localhost ~]# ln -s /usr/local/redis/bin /redis-cli /usr/bin/redis

Test redis

Centos7.6 installation Redis instance analysis

Service operation command

systemctl start redis.service #Start redis service

systemctl stop redis.service #Stop redis service

systemctl restart redis.service #Restart service

systemctl status redis.service #View the current status of the service

systemctl enable redis.service #Set auto-start at boot

systemctl disable redis.service #Stop auto-start at boot

The above is the detailed content of Centos7.6 installation Redis instance analysis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete