Home  >  Article  >  Database  >  How to install and configure Redis in Centos7

How to install and configure Redis in Centos7

WBOY
WBOYforward
2023-05-29 20:58:041616browse

Centos7 install Redis

0, update the file

yum update -y

1, download redis


How to install and configure Redis in Centos7

##2, compress the package Put it in Linux,I put it in export/intstall and decompressed it

cd export/install
tar -zxvf redis-6.2.1.tar.gz

3. Installation environment c

//安装c++yum install gcc-c++ -y//查看版本gcc -v

How to install and configure Redis in Centos7

4. Configuration basic files

cd redis-6.2.1make

5. Installation service

This is the default installation

make install

This is a custom installation

make install PREFIX=/usr/local/redis//后面的是你想要安装的路径

I am the default installation.

How to install and configure Redis in Centos7

6. Start the service

cd /cd usr/local/bin./redis-server

The startup is successful as shown below.


How to install and configure Redis in Centos7

Press ctrl c to exit.

7. Set up background startup

First copy the configuration file to the startup item.

cd /cd export/install/redis-6.2.1cp redis.conf /usr/local/bin/

7.1. Modify the configuration file

cd /cd usr/local/bin
vim redis.conf

Here is the modification to run in the background.

After opening the file,If you want to search, directly enter / in the field you want to search for such as /daemonized and press Enter to search,Press n to indicate the next match The characters :


How to install and configure Redis in Centos7

are queried to find this,Change the displayed no to yes,Then press esc and enter:wq to save the file.

7.2. Start the service

 ./redis-server redis.conf

7.3. Check whether the process is started

 ps aux|grep redis

How to install and configure Redis in Centos7##8. Close the service

./redis-cli shutdown

9. Simply use redis

to open the redis service.:

Open the redis client.


#Test:It is correct that pong appears.


How to install and configure Redis in Centos7Exit

 ./redis-server redis.conf ./redis-cli

10. Start remote connection
How to install and configure Redis in Centos7 Firewall allows.

quit

Modify the redis.conf configuration file

Turn off the protected-mode mode,At this time, the external network can directly access

firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload

This is the format display for setting the password.

Remember to restart the service after modifying it.

修改redis.conf 文件,protected-mode 要设置成no。//如果需要设置密码requirepass 空格后面跟设置的密码修改redis.conf 文件,将 bind 127.0.0.1 修改成bind * -::* 或者直接将bind这一行注释掉

Link redis with other ip addresses
How to install and configure Redis in Centos7The ip here is changed according to the ip address you want to link to

redis-cli -h 127.0.0.1 -p 6379 shutdown
# 干掉redis服务器(比较暴力,谨慎使用)
sudo kill -9 pid 进程号

Remote link with password

./redis-cli -h 192.168.10.20 -p 6379

The above is the detailed content of How to install and configure Redis in Centos7. 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