Skip to Content
Kubernetes即学即用(第二版)
book

Kubernetes即学即用(第二版)

by Brendan Burns, Joe Beda, Kelsey Hightower
June 2021
Intermediate to advanced
300 pages
5h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Kubernetes即学即用(第二版)
部署实际应用程序
249
移成为主服务器。这种故障转移是由
redis-sentinel
执行的。我们使用同一个
部署文件来定义
redis-server
redis-sentinel
17.4.1
配置
Redis
和以前一样,我们将使用
Kubernetes
ConfigMaps
来配置
Redis
的安装。
Redis
需要针对主副本和从副本进行单独的配置。在配置主服务器时,请创建
一个名为
master.conf
的文件,内容如示例
17-5
的代码所示。
示例
17-5
master.conf
bind 0.0.0.0
port 6379
dir /redis-data
这段代码可以将
Redis
绑定到所有网络接口的端口
6379
(默认的
Redis
端口)
上,并将文件存储在
/redis-data
目录中。
从副本的配置也是相同的,但它添加了一个
slaveof
指令。首先创建一个名
slave.conf
的文件,如示例
17-6
所示。
示例
17-6
slave.conf
bind 0.0.0.0
port 6379
dir .
slaveof redis-0.redis 6379
注意,我们使用
redis-0.redis
作为主机名。我们将通过服务和状态集来设
置这个名称。
我们还需要设置
redis-sentinel
。首先创建一个
sentinel.conf
文件,内容如示例
17-7
所示。
250
17
示例
17-7
sentinel.conf
bind 0.0.0.0
port 26379
sentinel monitor redis redis-0.redis ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
Python数据分析

Python数据分析

Posts & Telecom Press, Ivan Idris
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé

Publisher Resources

ISBN: 9787519856762