【教程】Linux安装Redis步骤记录

【教程】Linux安装Redis步骤记录

下载地址

Index of /releases/

Downloads - Redis

安装redis-7.4.0.tar.gz

1.下载安装包

wget https://download.redis.io/releases/redis-7.4.0.tar.gz

2.解压

tar -zxvf redis-7.4.0.tar.gz

3.进入目录

cd redis-7.4.0/

4.编译

make

5.安装

make install PREFIX=/usr/local/redis

6.配置文件

将解压之后的redis目录下的 redis.conf 文件复制到这里

/usr/local/redis/bin

7.启动redis

进入到这个目录下

/usr/local/redis/bin

 执行启动命令 选择配置文件

./redis-server redis.conf

配置redis后台运行

打开 redis.conf 找到 daemonize no  改为  daemonize yes

设置密码

设置为123456

requirepass 123456

设置端口

#定位关键字port
:/port
#默认配置为6379,有需要可以变更,这里变更为6380,若变更了端口需要同步变更pidfile的配置
port 6380
#定位关键字pidfile
:/pidfile
#变更配置默认为/var/run/redis_6379.pid,这里变更为/var/run/redis_6380.pid
pidfile /var/run/redis_6380.pid

关闭保护模式

#定位关键字protected-mode
:/protected-mode
#默认配置为yes,只有本机才可以访问redis,这里改为no,关闭保护模式
protected-mode no

允许外网访问

#定位关键字bind
:/bind
#bind 绑定的是机器网卡的ip,代表允许客户端通过机器的哪些网卡ip去访问,内网一般可以不配置bind,注释掉即可;外网访问变更为0.0.0.0,并配置服务器安全组
bind 0.0.0.0

启动之后提示

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.

解决方案

vim /etc/sysctl.conf

最后加一行

vm.overcommit_memory = 1

 加完之后执行

sysctl vm.overcommit_memory=1

重启redis

vm.swappiness = 0
kernel.sysrq = 1

net.ipv4.neigh.default.gc_stale_time = 120

# see details in https://help.aliyun.com/knowledge_detail/39428.html
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2

# see details in https://help.aliyun.com/knowledge_detail/41334.html
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0

#TODO 加到这里
vm.overcommit_memory = 1

  • 7
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

我是Superman丶

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

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

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

打赏作者

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

抵扣说明:

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

余额充值