Home > Database > Redis > body text

How to deploy Redis5.0.3 on CentOS7.6

王林
Release: 2023-06-02 08:34:05
forward
1398 people have browsed it

1. Deployment steps

1. Installing 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.

# yum install -y gcc
Copy after login

2. Download and install

# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
# tar -zxvf redis-5.0.3.tar.gz
Copy after login

3. Switch to the decompression directory and compile

# cd redis-5.0.3
# make
Copy after login

4. Install to the specified directory

# make install PREFIX=/usr/local/redis
Copy after login

5. Firewall settings

# firewall-cmd --zone=public --add-port=6379/tcp --permanent
# firewall-cmd --reload
# firewall-cmd --zone=public --query-port=6379/tcp
Copy after login

2. Start service

1. Front desk startup

# cd /usr/local/redis/bin/
# ./redis-server
Copy after login

2. Background startup

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

# cp /home/ptcvi/redis-5.0.3/redis.conf /usr/local/redis/bin/
# vi redis.conf
Copy after login

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

How to deploy Redis5.0.3 on CentOS7.6

Add IP

How to deploy Redis5.0.3 on CentOS7.6

Background startup

# ./redis-server redis.conf
Copy after login

3. Boot startup configuration

Add startup service

# vi /etc/systemd/system/redis.service
Copy after login

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
Copy after login

Note: ExecStart is configured to the installation path

How to deploy Redis5.0.3 on CentOS7.6

Create redis command Soft link

# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
Copy after login

Set up startup

# systemctl daemon-reload
# systemctl enable redis.service
# systemctl start redis.service
Copy after login

4. Set password

Find the redis.windows.conf configuration in the redis root directory file, search for requirepass, find the comment password line, and add the password as follows:

# requirepass foobared
requirepass redis#123     //注意,行前不能有空格
Copy after login

Restart the service

#systemctl restart redis.service
Copy after login

5. Common commands for services

启动redis服务
# systemctl start redis.service
停止redis服务
# systemctl stop redis.service 
重新启动服务
#systemctl restart redis.service
查看服务当前状态
# systemctl status redis.service
设置开机自启动
# systemctl enable redis.service
停止开机自启动
# systemctl disable redis.service
Copy after login

The above is the detailed content of How to deploy Redis5.0.3 on CentOS7.6. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!