redis非集群操作模式的部署详解

写在前面的话:

对于redis来说,它有四种部署模式,分别是单机模式、主从模式、哨兵模式和集群模式,他们的使用场景有些区别,当然也是越来越复杂,可靠性越来越高。

本文从实际操作的角度,来介绍和讲解下,这几种模式的特点,鉴于篇幅的问题,文章分成两篇,一篇用来介绍:单机模式、主从模式和哨兵模式;另外一篇用来介绍:集群模式。

一、单机部署:

下面是单机部署的操作步骤。

// redis-server 没有启动的情况下,直接连接 redis-cli的结果
$ redis-cli -h 127.0.0.1 -p 6379
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>

1.通过redis-server /usr/local/etc/redis.conf 启动默认的6379redis服务

// redis-server 服务启动
$ redis-server /usr/local/etc/redis.conf
5286:C 03 Nov 2020 18:35:17.905 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
5286:C 03 Nov 2020 18:35:17.905 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=5286, just started
5286:C 03 Nov 2020 18:35:17.905 # Configuration loaded
5286:M 03 Nov 2020 18:35:17.907 * Increased maximum number of open files to 10032 (it was originally set to 256).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 5.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 5286
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'


5286:M 03 Nov 2020 18:35:17.909 # Server initialized
5286:M 03 Nov 2020 18:35:17.909 * DB loaded from disk: 0.001 seconds
5286:M 03 Nov 2020 18:35:17.909 * Ready to accept connections

2.通过redis-cli去验证redis-server是否连接成功,下面对一些命令做了简要绍明

// redis-cli 启动成功
$ redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>
127.0.0.1:6379> ping // 检测连接是不是好的
PONG
127.0.0.1:6379> ping "hello the world" // 也可以发送指定消息
"hello the world"
127.0.0.1:6379>
127.0.0.1:6379> ping // 断开redis-server之后,ping的话就提示下面的错误
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
not connected> ping // 此刻redis-server又被启动了起来
PONG
127
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值