Redis7.2 单点安装到Alibaba Cloud Linux (Aliyun Linux) release 2.1903 LTS (Hunting Beagle)上步骤记录

Alibaba Cloud Linux (Aliyun Linux) release 2.1903 LTS (Hunting Beagle)按centos7系统操作命令操作
源码包编译安装方式

1、下载最新稳定版本:https://download.redis.io/redis-stable.tar.gz,当前版本是7.2

# mkdir /data
# cd /data
# curl -OL https://download.redis.io/redis-stable.tar.gz

2、解压后编译安装

# tar -zxvf redis-stable.tar.gz 
# cd redis-stable
# make
# make install

redis会被默认安装在 /usr/local/bin/目录下
在这里插入图片描述

3、修改配置文件

配置文件redis.conf在源码包下,通常需要修改或开启以下配置

  • daemonize yes # redis守护进程启动
  • requirepass foobared # 设置访问密码
  • port 6379 # 访问端口
  • bind 127.0.0.1 -::1 # 地址绑定

4、启动redis

以下是pwd在/data/redis-stable目录下的启动、以及验证启动运行正常的命令

#  /usr/local/bin/redis-server  redis.conf
# /usr/local/bin/redis-cli 
如果端口号修改为1234则:# /usr/local/bin/redis-cli -h 127.0.0.1 -p 1234
127.0.0.1:6379> auth foobared
127.0.0.1:6379> ping

在这里插入图片描述
当看到redis命令行客户端返回PONG。证明配置没问题,redis顺利运行。

后面的开机自启动按需设置即可。
执行启动命令可能会有以下警告。执行echo 1 > /proc/sys/vm/overcommit_memory 或者按警告提示操作消除警告

WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

5、开机自启动配置

先把redis进程kill掉,创建一个systemd管理文件

# vim /etc/systemd/system/redis.service

redis.service文件内容如下:

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking

ExecStart=/usr/local/bin/redis-server /data/redis-stable/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

接下来运行以下命令

systemd配置文件生效命令
# systemctl daemon-reload
设置redis开机自启:
# systemctl enable redis
启动redis服务
# systemctl start redis
查看redis服务状态
# systemctl status redis
停止服务
# systemctl stop redis
取消开机自动启动
# systemctl disabled redis

参考资料
https://redis.io/docs/install/install-redis/install-redis-from-source/
https://redis.io/docs/connect/cli/

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值