linux源码安装并启动多个redis

6 篇文章 1 订阅

官方安装文档

https://redis.io/docs/getting-started/installation/install-redis-from-source/

1 下载对应版本的redis源码包

redis-6.2.3.tar.gz
链接:https://pan.baidu.com/s/1ep0L4LCsmL4bmRL28ax_zA?pwd=5vd2
提取码:5vd2

2 上传到服务器

上传到usr/local/下

tar -zxvf redis-6.2.3.tar.gz 

3 编译安装redis

cd redis-6.2.3
make
make install
[root@iZ8vbdcrmm49bxv7sirrv3Z redis-6.2.3] make install
cd src && make install
make[1]: Entering directory `/usr/local/redis-6.2.3/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/redis-6.2.3/src'
make[1]: Entering directory `/usr/local/redis-6.2.3/src'

Hint: It's a good idea to run 'make test' ;)

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: Leaving directory `/usr/local/redis-6.2.3/src'

4 编辑redis配置文件

先备份原有文件
mv redis.conf redis.conf.bak

再创建一个新的
vim redis.conf

# 启动端口
port 8391

# 密码
requirepass admin

# RDB持久化
save 900 1
save 300 10
save 60 10000

# 持久化压缩
rdbcompression yes

# RDB持久化文件
dbfilename dump.rdb

# 开启AOF
appendonly yes

# 文件名
appendfilename "appendonly.aof"

# 每秒持久化一次(推荐)
appendfsync everysec            

5 按照配置文件启动redis

在/usr/local/redis-6.2.3下执行

[root@shanghai redis-6.2.3]# ./src/redis-server ./redis.conf
19181:C 07 Dec 2022 14:51:47.660 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
19181:C 07 Dec 2022 14:51:47.660 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=19181, just started
19181:C 07 Dec 2022 14:51:47.660 # Configuration loaded
19181:M 07 Dec 2022 14:51:47.661 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 8391
 |    `-._   `._    /     _.-'    |     PID: 19181
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

19181:M 07 Dec 2022 14:51:47.662 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
19181:M 07 Dec 2022 14:51:47.662 # Server initialized
19181:M 07 Dec 2022 14:51:47.662 * DB loaded from append only file: 0.000 seconds
19181:M 07 Dec 2022 14:51:47.662 * Ready to accept connections

6 在不同端口启动多个redis

只需要复制redis-6.2.3文件,然后改变配置文件中的端口,分别启动即可

7 外界无法访问问题解决

redis默认安装只能本机连接,外网无法使用,修改配置文件

1、注释掉bind 允许所有ip连接redis
# bind 0.0.0.0 

2、注释redis保护模式
# protected-mode yes

3、设置reids密码
requirepass 123456 

重启即可

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

L-960

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

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

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

打赏作者

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

抵扣说明:

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

余额充值