Redis-6.2.7下载
下载地址:https://download.redis.io/releases/redis-6.2.7.tar.gz
解压缩文件
tar -zxvf redis-6.0.3.tar.gz
1
安装gcc
yum install gcc
1
进入压缩包src目录下进行源码编译,将redis安装到/usr/local/redis目录下
cd /opt/software/redis-6.2.7/src
make install PREFIX=/usr/local/redis
1
2
移动配置文件到安装目录下
mkdir /usr/local/redis/etc
mv /opt/software/redis-6.2.7/redis.conf /usr/local/redis/etc
1
2
参数配置
后台启动
daemonize yes
密码访问
requirepass Redis@dml
开启保护模式
protected-mode yes
允许远程访问
bind 172.24.215.134 或者注释掉
设置开机启动
vi /etc/systemd/system/redis.service
Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/etc/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
1
2
3
服务操作命令
systemctl start redis.service #启动redis服务
systemctl stop redis.service #停止redis服务
systemctl restart redis.service #重新启动服务
systemctl status redis.service #查看服务当前状态
systemctl enable redis.service #设置开机自启动
systemctl disable redis.service #停止开机自启动
1
2
3
4
5
6
7
8
9
10
11
创建 redis 命令链接
cp /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
cp /usr/local/redis/bin/redis-server /usr/bin/redis-server
# 软链接方式
# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
————————————————