在centos7.9上部署安装redis-7.2.3
官网
https://redis.io/download/
wget https://github.com/redis/redis/archive/7.2.3.tar.gz --no-check-certificate
?如果这个链接失效,自行去官网找个合适的版本
yum install gcc-c++ -y
?
tar -zxf 7.2.3.tar.gz
cd redis-7.2.3/
make
make install PREFIX=/usr/local/redis
cp redis.conf /usr/local/redis/bin/
sed -i 's/# requirepass foobared/requirepass mypwd123/g' /usr/local/redis/bin/redis.conf
sed -i '/^\s*#/!s/127\.0\.0\.1/0\.0\.0\.0/g' /usr/local/redis/bin/redis.conf
sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/bin/redis.conf
注:
● 给redis设置密码mypwd123
● 设置所有主机都能访问redis
● 开启redis即后台启动,默认是前台启动。
cd /usr/local/redis/bin/
./redis-server ./redis.conf
./redis-cli
keys * ? ?#会报错,因为给redis设置了密码
auth mypwd123
keys * ? ?#不报错,因为上面登录了
cat << EOF > /usr/lib/systemd/system/redis.service
[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
EOF
kill `ps -ef |grep redis |head -n 1 |awk '{print $2}'`
systemctl daemon-reload
systemctl enable redis --now
systemctl status redis
ss -ntl |grep 6379