Centos7 install Redis
0, update the file
yum update -y
Copy after login
1, download redis
##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
Copy after login
3. Installation environment c
//安装c++yum install gcc-c++ -y//查看版本gcc -v
Copy after login
4. Configuration basic files
cd redis-6.2.1make
Copy after login
5. Installation service
This is the default installation
make install
Copy after login
This is a custom installation
make install PREFIX=/usr/local/redis//后面的是你想要安装的路径
Copy after login
I am the default installation.
6. Start the service
cd /cd usr/local/bin./redis-server
Copy after login
The startup is successful as shown below.
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/
Copy after login
7.1. Modify the configuration file
cd /cd usr/local/bin
vim redis.conf
Copy after login
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 :
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
Copy after login
7.3. Check whether the process is started
ps aux|grep redis
Copy after login
##8. Close the service
./redis-cli shutdown
Copy after login
9. Simply use redis
to open the redis service.:
Open the redis client.
#Test:It is correct that pong appears.
Exit
./redis-server redis.conf ./redis-cli
Copy after login
10. Start remote connection
Firewall allows.
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
Copy after login
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这一行注释掉
Copy after login
Link redis with other ip addresses
The 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 进程号
Copy after login
Remote link with password
./redis-cli -h 192.168.10.20 -p 6379
Copy after login
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!