centos8安装redis
centos8安装redis
一,下载:
1,下载页面:
2,下载
[root@localhost source]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
说明:架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,解压:
[root@localhost source]# tar -xzvf redis-5.0.7.tar.gz
三,准备编译
1, 请在操作前确认gcc是否已安装,
如未安装,可以执行这个命令安装:
[root@localhost redis-5.0.7]# yum install gcc
2,请在操作前确认tcl是否已安装
如未安装,可以执行这个命令安装:
[root@localhost redis-5.0.7]# yum install tcl
四,编译:
[root@localhost source]# cd redis-5.0.7/ [root@localhost redis-5.0.7]# make MALLOC=libc
说明:make 后加 MALLOC的参数的原因:
避免提示找不到 jemalloc/jemalloc.h
五,测试编译:
[root@localhost redis-5.0.7]# make test
如果看到以下字样:表示无错误:
\o/ All tests passed without errors!
六,安装:
[root@localhost redis-5.0.7]# mkdir /usr/local/soft/redis5 [root@localhost redis-5.0.7]# cd /usr/local/soft/redis5/ [root@localhost redis5]# mkdir bin [root@localhost redis5]# mkdir conf [root@localhost redis5]# cd bin/ [root@localhost bin]# cp /usr/local/source/redis-5.0.7/src/redis-cli ./ [root@localhost bin]# cp /usr/local/source/redis-5.0.7/src/redis-server ./ [root@localhost bin]# cd ../conf/ [root@localhost conf]# cp /usr/local/source/redis-5.0.7/redis.conf ./
七,配置:
[root@localhost conf]# vi redis.conf
设置以下两个地方:
# daemonize no daemonize yes # maxmemory <bytes> maxmemory 128MB
说明:分别是以daemon方式独立运行 / 内存的最大使用限制
八,运行:
[root@localhost conf]# /usr/local/soft/redis5/bin/redis-server /usr/local/soft/redis5/conf/redis.conf
九,检查端口是否在使用中
[root@localhost conf]# netstat -anp | grep 6379 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 16073/redis-server
十,查看redis的当前版本:
[root@localhost conf]# /usr/local/soft/redis5/bin/redis-server -v Redis server v=5.0.7 sha=00000000:0 malloc=libc bits=64 build=8e31d2ed9a4c9593
十一,使redis可以用systemd方式启动和管理
1,编辑service文件
[root@localhost liuhongdi]# vim /lib/systemd/system/redis.service
2,service文件内容:
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/soft/redis5/bin/redis-server /usr/local/soft/redis5/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
3.重载系统服务
[root@localhost liuhongdi]# systemctl daemon-reload
4,用来管理redis
启动
systemctl start redis
查看状态
systemctl status redis
使开机启动
systemctl enable redis
十二,查看本地centos的版本:
[root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core)
Powered by .NET 7.0 on Kubernetes