安装位置:/usr/local下redis-6.0.3
安装命令:
wget http://download.redis.io/releases/redis-6.0.3.tar.gz
tar xzf redis-6.0.3.tar.gz
cd redis-6.0.3
make
make install
查看是否安装成功:
cd /usr/locsl/bin
若里面没有文件,查看文章最后,重新安装一些配置后再进行make编译,之后再到这里目录下接着往下操作。
./redis.server /usr/local/redis-6.0.3/redis.conf (启动redis)
修改redis.conf
systemctl管理Redis启动、停止、开机启动:
用service来管理服务的时候,是在/etc/init.d/目录中创建一个脚本文件,来管理服务的启动和停止,在systemctl中,也类似,文件目录有所不同,在/lib/systemd/system目录下创建一个脚本文件redis.service
vi redis.service
粘贴内容:
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server /usr/local/redis-6.0.3/redis.conf
ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown
[Install]
WantedBy=multi-user.target
创建软链接是为了下一步系统初始化时自动启动服务:
ln -s /lib/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service
刚刚配置的服务需要让systemctl能识别,就必须刷新配置:
systemctl daemon-reload
用systemctl启动、重启、停止:
systemctl start redis
systemctl restart redis
systemctl stop redis
查看启动状态:systemctl status redis
开机自启动:
redis服务加入开机启动
$ systemctl enable redis # 刚才创建链接并刷新配置时已经设置开机启动
禁止开机启动
$ systemctl disable redis
查看启动状态:
#检查后台进程是否正在运行
ps -ef |grep redis
ps aux | grep redis
#检测6379端口是否在监听
netstat -lntp | grep 6379
#使用配置文件启动redis服务
cd /usr/locsl/bin
./redis.server /usr/local/redis-6.0.3/redis.conf
#使用`redis-cli`客户端检测连接是否正常
cd /usr/locsl/bin
./redis-cli -h 127.0.0.1 -p 6379 (登陆客户端)
针对目录没有文件:
查看版本:gcc -v
1、yum -y install centos-release-scl # 升级到新版本
2、yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
3、scl enable devtoolset-9 bash
4、以上scl enable devtoolset-9 bash命令为临时启用,若需要长期使用:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
centos7安装redis-6.0.3
最新推荐文章于 2022-11-12 11:30:03 发布