1.准备
因为要使用rediSearch、redisJson,需要安装RediSearch6
系统:CentOS 7.9
2.下载
进入 /opt (自行选择目录),执行命令
wget http://download.redis.io/releases/redis-6.0.8.tar.gz
3.安装
#解压
tar xf redis-6.0.8.tar.gz
#更名
mv redis-6.0.8 redis
#编译
cd redis/
make
#安装指定目录
make install PREFIX=/opt/redis6
4.配置
#创建数据目录
mkdir /opt/redis6/data
#copy配置文件
cp /opt/redis/redis/redis.conf /opt/redis6/bin/
vim /opt/redis6/bin/redis.conf
配置文件内容
#守护进程
daemonize yes
#取消连接限制
#bind 127.0.0.1
protected-mode yes
#密码
requirepass 123456
#日志目录
logfile /opt/redis6/log/redis.log
5.启动
./redis-server /opt/redis6/bin/redis.conf
6.验证
netstat -na|grep 6379
ps -ef | grep redis
7.编写启动脚本?
vim /lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/opt/redis6/bin/redis-server /opt/redis6/bin/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#重启即可
systemctl restart redis
#查看状态
systemctl status redis
8.redis命令
# 重载服务
systemctl daemon-reload
# 开机自启
systemctl enable redis
# 启动
systemctl start redis
# 停止
systemctl stop redis
# 关闭开机启动
systemctl disable redis
9.连接redis?
1、 Redis Desktop Manager
配置连接
?2、redis_client连接
执行命令
./redis-cli -h 127.0.0.1 -p 6379 -a 123456
|