Redis installation and configuration
1. Environmental preparation
-
Operating system: CentOS 7
How to determine the number of linux?
getconf LONG_BIT # 需要为 64
-
install gcc
yum -y install gcc # 查看版本 gcc -v yum -y install gcc-c++
Two, install redis7
-
Download redis7 locally
https://redis.io/download/
-
Upload to the /opt directory through XShell
-
unzip
tar -zxvf redis-7.0.9.tar.gz
-
Execute make && make install
cd /opt/redis-7.0.9 make && make install
-
View the installation directory
cd /usr/local/bin
-
copy configuration file
cd /opt/redis-7.0.9 mkdir /myredis cp redis.conf /myredis/redis7.conf
After modifying the configuration file, you need to restart
-
Modify the configuration file redis7.conf we copied
# 1、daemonize 修改为 yes daemonize yes # 2、protected-mode 修改为 no protected-mode no # 3、注释掉 bind 127.0.0.1 -::1 # bind 127.0.0.1 -::1 # 4、添加redis密码,将requirepass修改为自己设置的密码 requirepass 1234
-
start service
redis-server /myredis/redis7.conf ps -ef|grep redis|grep -v grep
-
connect redis
redis-cli -a 1234 -p 6379
-
Ping returns PONG success
ping # 返回 PONG 则成功
-
close redis
# 单实例关闭 redis-cli -a 1234 shutdwon # 多实例关闭,指定端口关闭 redis-cli -p 6379 shutdown