linux 安装redis6教程


查看gcc版本

[root@centos8 liuhongdi]# gcc --version

gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4)
如果提示找不到gcc程序,说明没有安装,
可以用dnf命令安装

[root@centos8 liuhongdi]# dnf install gcc

说明:gcc版本不宜过低,应该在gcc 5.3以上
如版本过低则建议先升级gcc
参考下面文章
https://blog.csdn.net/qq_45069833/article/details/108762535

1、解压缩

[root@centos8 source]# tar -zxvf redis-6.0.1.tar.gz
[root@centos8 source]# cd redis-6.0.1/

2、安装redis

[root@centos8 redis-6.0.1]# make PREFIX=/usr/local/soft/redis6 install

3、生成配置文件

创建安装目录

[root@centos8 redis-6.0.1]# mkdir /usr/local/soft/redis6/conf

把源码目录下的redis.conf复制到安装目录

[root@centos8 redis-6.0.1]# cp redis.conf /usr/local/soft/redis6/conf/

分别用来存放redis的日志和数据
logs:存放日志
data:存放快照数据

[root@centos8 data]# mkdir -p /data/redis6
[root@centos8 data]# cd /data/redis6/
[root@centos8 redis6]# mkdir logs
[root@centos8 redis6]# mkdir data
[root@centos8 conf]# vi redis.conf

#使以daemon方式运行
daemonize yes
#日志保存目录
logfile “/data/redis6/logs/redis.log”
#数据保存目录
dir /data/redis6/data/
#使用的最大内存数量
maxmemory 128MB
生成供systemd使用的service文件

[root@centos8 ~]# vi /lib/systemd/system/redis6.service
[Unit]
Description=Redis
After=network.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/soft/redis6/bin/redis-server /usr/local/soft/redis6/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重新加载service文件

[root@centos8 ~]# systemctl daemon-reload

测试启动redis6

[root@centos8 ~]# systemctl start redis6

停止:

[root@centos8 ~]# systemctl stop redis6

测试从本地连接访问:

[root@centos8 conf]# /usr/local/soft/redis6/bin/redis-cli -h 192.168.1.7192.168.1.7:6379> set a aaaa
OK
192.168.1.7:6379> get a
"aaaa"

查看已安装redis的版本

[root@centos8 conf]# /usr/local/soft/redis6/bin/redis-server -v
Redis server v=6.0.1 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=0
  • 20
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gis分享者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值