当前位置: 首页 > news >正文

patroni+etcd开启SSL认证(三个节点证书一致 使用openssl命令)

瀚高数据库
目录
环境
文档用途
详细信息

环境
系统平台:Linux x86-64 Red Hat Enterprise Linux 7
版本:14
文档用途
本文主要介绍Patroni架构中如何开启etcd的ssl证书认证。

详细信息

一、前提说明

patroni版本:3.0.2

etcd版本:3.5.7

数据库版本:14.4

OS版本:redhat7.7

二、自签名CA证书及私钥

1、私钥生成

[root@patroni8 ssl]# openssl genrsa -out ca-key.pem 2048
Generating RSA private key, 2048 bit long modulus
.....................................+++
.............................+++
e is 65537 (0x10001)

2、自签名证书生成

填写以下内容,其余的回车跳过

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:SD

Locality Name (eg, city) [Default City]:JN

Common Name (eg, your name or your server’s hostname) []:etcd

[root@patroni8 ssl]# openssl req -new -x509 -key ca-key.pem -out ca.pem -days 365
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:SD
Locality Name (eg, city) [Default City]:JN
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:etcd
Email Address []:
[root@patroni8 ssl]# ls
ca-key.pem  ca.pem

3、etcd私钥生成

[root@patroni8 ssl]# openssl genrsa -out server-key.pem 2048
Generating RSA private key, 2048 bit long modulus
.....+++
...............+++
e is 65537 (0x10001)

4、编辑配置文件,生成etcd证书

[root@patroni8 ssl]# vi openssl.cnf
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = CN
ST = SD
L = JN
CN = etcd
[v3_req]
subjectAltName = @alt_names
[alt_names]
IP.1 = 192.168.11.16
IP.2 = 192.168.11.17
IP.3 = 192.168.11.18

5、生成etcd证书

[root@patroni8 ssl]# openssl req -new -key server-key.pem -out server.csr -subj "/CN=etcd-server" -config openssl.cnf
[root@patroni8 ssl]# ls
ca-key.pem  ca.pem  openssl.cnf  server.csr  server-key.pem
[root@patroni8 ssl]# openssl x509 -req -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server.pem -days 365 -extensi                       ons v3_req -extfile openssl.cnf
Signature ok
subject=/C=CN/ST=SD/L=JN/CN=etcd
Getting CA Private Key
[root@patroni8 ssl]# ls
ca-key.pem  ca.pem  ca.srl  openssl.cnf  server.csr  server-key.pem  server.pem
[root@patroni8 ssl]# ls -lrth
total 28K
-rw-r--r--. 1 root root 1.7K May 15 11:20 ca-key.pem
-rw-r--r--. 1 root root 1.3K May 15 11:28 ca.pem
-rw-r--r--. 1 root root 1.7K May 15 11:29 server-key.pem
-rw-r--r--. 1 root root  255 May 15 11:33 openssl.cnf
-rw-r--r--. 1 root root 1001 May 15 11:33 server.csr
-rw-r--r--. 1 root root   17 May 15 11:34 ca.srl
-rw-r--r--. 1 root root 1.2K May 15 11:34 server.pem

6、将私钥证书复制到其他节点

[root@patroni8 ssl]# scp ca-key.pem ca.pem server.pem server-key.pem root@192.168.11.17:/opt/etcd/ssl
[root@patroni8 ssl]# scp ca-key.pem ca.pem server.pem server-key.pem root@192.168.11.16:/opt/etcd/ssl

7、修改各节点etcd配置文件,将http换为https

编辑/opt/etcd/etcd.yaml文件

debug: false
name: etcd03
data-dir: /opt/etcd/data
initial-advertise-peer-urls: https://192.168.11.18:2380
listen-peer-urls: https://192.168.11.18:2380
advertise-client-urls: https://192.168.11.18:2379
listen-client-urls: https://192.168.11.18:2379,https://127.0.0.1:2379
initial-cluster-token: etcd-cluster
initial-cluster: etcd01=https://192.168.11.16:2380,etcd02=https://192.168.11.17:2380,etcd03=https://192.168.11.18:2380
initial-cluster-state: newclient-transport-security:cert-file: /opt/etcd/ssl/server.pemkey-file: /opt/etcd/ssl/server-key.pemclient-cert-auth: truetrusted-ca-file: /opt/etcd/ssl/ca.pemauto_tls: truepeer-transport-security:cert-file: /opt/etcd/ssl/server.pemkey-file: /opt/etcd/ssl/server-key.pemclient-cert-auth: truetrusted-ca-file: /opt/etcd/ssl/ca.pemauto_tls: trueenable-v2: true

8、各节点开启etcd并验证tls通信,注意,无法使用环境变量,如果环境变量冲突,注释掉对应的环境变量。

[root@patroni8 ssl]# systemctl start etcd
验证etcd开启tls
[root@patroni6 etcd]#  etcdctl --endpoints=https://192.168.11.16:2379,https://192.168.11.17:2379,https://192.168.11.18:2379 --cacert=/opt/etcd/ssl/ca.pem --cert=/opt/etcd/ssl/server.pem --key=/opt/etcd/ssl/server-key.pem endpoint health
https://192.168.11.18:2379 is healthy: successfully committed proposal: took = 12.05254ms
https://192.168.11.16:2379 is healthy: successfully committed proposal: took = 12.007163ms
https://192.168.11.17:2379 is healthy: successfully committed proposal: took = 12.344144ms[root@patroni6 patroni]# ETCDCTL_API=2 etcdctl --endpoints=https://192.168.11.16:2379,https://192.168.11.17:2379,https://192.168.11.1                       8:2379 --ca-file=/opt/etcd/ssl/ca.pem --cert-file=/opt/etcd/ssl/server.pem --key-file=/opt/etcd/ssl/server-key.pem cluster-health
member 421aadb231b71fa1 is healthy: got healthy result from https://192.168.11.17:2379
member 61a0b36ccbf8f9bf is healthy: got healthy result from https://192.168.11.18:2379
member 910f6ce438f0d4dd is healthy: got healthy result from https://192.168.11.16:2379
cluster is healthy

三、patroni配置ssl

1、配置patroni文件中的etcd部分

etcd:#配置etcd所有节点的访问IP及端口hosts: 192.168.11.16:2379,192.168.11.17:2379,192.168.11.18:2379protocol: httpscert: /opt/etcd/ssl/server.pemkey: /opt/etcd/ssl/server-key.pemcacert: /opt/etcd/ssl/ca.pem
#  username: root
#  password: 123456

2、启动patroni

systemctl start patroni

四、注意事项

1、如果报错是CA是自签名的不可信,需要将证书添加到可信存储中,每个节点都执行

cp ca.pem /etc/pki/ca-trust/source/anchors/update-ca-trust

相关文章:

patroni+etcd开启SSL认证(三个节点证书一致 使用openssl命令)

瀚高数据库 目录 环境 文档用途 详细信息 环境 系统平台:Linux x86-64 Red Hat Enterprise Linux 7 版本:14 文档用途 本文主要介绍Patroni架构中如何开启etcd的ssl证书认证。 详细信息 一、前提说明 patroni版本:3.0.2 etcd版本&#x…...

Eureka入门指南:微服务注册与发现的基础概念

Eureka入门指南:微服务注册与发现的基础概念 引言 随着微服务架构的普及,微服务之间的高效通信和管理成为了开发和运维的核心挑战之一。为了解决服务发现和管理问题,Netflix推出了Eureka,一个功能强大的服务注册和发现工具。Eur…...

Linux:动态库和静态库

静态库与动态库 A:静态库(.a):程序在编译链接的时候把库的代码链接到可执行文件中。程序运行的时候将不再需要静态库。 B:动态库(.so):程序在运行的时候才去链接动态库的代码&#…...

8.13网络编程

笔记 多点通信 一、套接字属性 套接字属性的获取和设置 #include <sys/types.h> /* See NOTES */#include <sys/socket.h>int getsockopt(int sockfd, int level, int optname,void *optval, socklen_t *optlen);int setsockopt(int sockfd, int level…...

蚂蚁AL1 15.6T 创新科技的新典范

● 哈希率&#xff1a;算力达到15.6T&#xff08;相当于15600G&#xff09;&#xff0c;即每秒能够进行15.6万亿次哈希计算&#xff0c;在同类产品中算力较为出色&#xff0c;能提高WA掘效率。 ● 功耗&#xff1a;功耗为3510W&#xff0c;虽然数值看似不低&#xff0c;但结合其…...

2024年【汽车驾驶员(技师)】考试报名及汽车驾驶员(技师)试题及解析

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 汽车驾驶员&#xff08;技师&#xff09;考试报名参考答案及汽车驾驶员&#xff08;技师&#xff09;考试试题解析是安全生产模拟考试一点通题库老师及汽车驾驶员&#xff08;技师&#xff09;操作证已考过的学员汇总…...

2024年【甘肃省安全员C证】报名考试及甘肃省安全员C证考试总结

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 甘肃省安全员C证报名考试参考答案及甘肃省安全员C证考试试题解析是安全生产模拟考试一点通题库老师及甘肃省安全员C证操作证已考过的学员汇总&#xff0c;相对有效帮助甘肃省安全员C证考试总结学员顺利通过考试。 1、…...

RabbitMQ 双机系统偶尔丢失消息问题排查

实话说起来&#xff0c;这个问题&#xff0c;实际是一个非常低级的错误导致的&#xff0c;算不得什么高深的技术问题。但是在排查的过程中&#xff0c;却是费了好大的功夫&#xff0c;死了不少脑细胞。所以也值得记录一下&#xff0c;算作给大家提个醒&#xff0c;或许可以帮大…...

Python 环境搭建指南 超详细

Python是由荷兰⼈吉多范罗苏姆&#xff08;Guido von Rossum&#xff0c;后⾯都称呼他为Guido&#xff09;发明的⼀种编程语言 1. 1989年圣诞节&#xff1a;Guido开始写Python语⾔的编译器。2. 1991年2⽉&#xff1a;第⼀个Python解释器诞⽣&#xff0c;它是⽤C语⾔实现的&…...

使用三菱PLC源码进行PLC读取写入操作

安装 MX Component 。 我的安装地址在&#xff1a; 打开 utl 文件夹下的 Communication Settings Utility 执行。 配置PLC 添加当前需要配置的PLC 注意 logical station Namber 就是程序里需要对接的逻辑站点编号 5.配置选择对应的COM操作选择对应的cpu型型号&#xff0c;…...

使用Nvm切换nodeJs高版本之后,使用npm install一闪而过

先说现象,最近又有几个项目接手,其中有一个使用NVM切换至高版本node后,出现如下症状; 没有任何提示,然后翻看文件目录,node_modules目录没有创建,同时在全局 npm config set prefix 设置的目录下 多了一个 pgn的快捷,指向项目目录。 使用百度或者chart-gtp,搜索到的答案…...

【Kubernetes】k8s集群安全机制

目录 一.认证 1.k8s集群内的三种认证方式 2.k8s集群内的认证说明 2.1.需要被认证的访问类型 2.2.安全性说明 2.3.证书颁发的方式 2.4.kubeconfig 2.5.Service Account 2.6.Secret 与 SA 的关系 二.鉴权 1.鉴权的方式 2.RBAC的角色与角色绑定 2.1.RBAC的角色 2.2…...

嵌入式学习---DAY24:进程--二

一、exec函数族----启动一个新程序 用fork创建子进程后执行的是和父进程相同的程序&#xff08;但有可能执行不同的代码分支&#xff09;&#xff0c; 子进程往往要调用一种exec函数以执行另一个程序。当进程调用一种exec函数时&#xff0c;该进程的 用户空间代码和数据完全被…...

Diffusion Model相关论文解析之(二)DENOISING DIFFUSION IMPLICIT MODELS

目录 1、摘要2、创新点3、主要公式4、自己的理解&#xff0c;对错不确定 1、摘要 ‌Denoising Diffusion Implicit Models (DDIM)‌是一种扩散模型的改进版本&#xff0c;旨在加速采样过程并提高采样速度。DDIM通过引入非马尔可夫扩散过程&#xff0c;相对于传统的去噪扩散概率…...

【STM32嵌入式系统设计与开发拓展】——14_定时器之输入捕获

参考哔站&#xff1a;链接: 铁头山羊 一、微控制器的高级定时与控制功能集合 1、时基单元 2、输入捕获 3、输出比较 4、从模式控制器 5、高级定时器的输出控制 二、问题集合 1、什么是定时器 定时器是一种专门负责定时功能的片上外设GPI0AFI0EXTIUSART RCC I2C) 2、定时器…...

docker swarm如何让两个副本分别跑在两台不同的主机上

虽然 docker swarm 支持自动扩容部署&#xff0c;但是为了服务的稳定性、可靠性&#xff0c;有的时候甲方巴巴会要求一定要服务分散部署在不同的服务器上。 使用默认的部署方式&#xff0c;虽然副本为 N&#xff0c;但是部署的 N 个服务可能落在同一台服务器上。 在 Docker Swa…...

GPT助手的训练流程四个主要阶段( GPT Assistant training pipeline )

GPT助手的训练流程四个主要阶段&#xff08; GPT Assistant training pipeline &#xff09; flyfish 四个阶段 预训练&#xff08;pre-training&#xff09; 监督微调&#xff08;supervised fine tuning, SFT&#xff09; 奖励建模&#xff08;reward modeling&#xff09…...

网络如何发送一个数据包

网络如何发送一个数据包 网络消息发送就是点一点屏幕。 骚瑞&#xff0c;这一点都不好笑。&#xff08;小品就是我的本质惹&#xff09; 之前我就是会被这个问题搞的不安宁。是怎么知道对方的IP地址的呢&#xff1f;怎么知道对方的MAC呢&#xff1f;世界上计算机有那么多&…...

【Harmony OS 4.0】向上滑动加载案例

// 自定义class类对象类型 class Article {public id: numberpublic title: stringpublic content: stringconstructor(id: number, title: string, content: string) {this.id idthis.title titlethis.content content} }// 子组件 Component struct ArticleComponent {Pro…...

SQL基础教程(八)SQL高级处理

※食用指南&#xff1a;文章内容为《SQL基础教程》系列学习笔记&#xff0c;该书对新手入门非常友好&#xff0c;循序渐进&#xff0c;浅显易懂&#xff0c;本人主要用来补全学习MySQL中未涉及的部分&#xff0c;便于刷题和做项目。 官方电子书&#xff1a;《SQL基础教程》第2…...

安宝特方案丨XRSOP人员作业标准化管理平台:AR智慧点检验收套件

在选煤厂、化工厂、钢铁厂等过程生产型企业&#xff0c;其生产设备的运行效率和非计划停机对工业制造效益有较大影响。 随着企业自动化和智能化建设的推进&#xff0c;需提前预防假检、错检、漏检&#xff0c;推动智慧生产运维系统数据的流动和现场赋能应用。同时&#xff0c;…...

el-switch文字内置

el-switch文字内置 效果 vue <div style"color:#ffffff;font-size:14px;float:left;margin-bottom:5px;margin-right:5px;">自动加载</div> <el-switch v-model"value" active-color"#3E99FB" inactive-color"#DCDFE6"…...

[10-3]软件I2C读写MPU6050 江协科技学习笔记(16个知识点)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16...

全面解析各类VPN技术:GRE、IPsec、L2TP、SSL与MPLS VPN对比

目录 引言 VPN技术概述 GRE VPN 3.1 GRE封装结构 3.2 GRE的应用场景 GRE over IPsec 4.1 GRE over IPsec封装结构 4.2 为什么使用GRE over IPsec&#xff1f; IPsec VPN 5.1 IPsec传输模式&#xff08;Transport Mode&#xff09; 5.2 IPsec隧道模式&#xff08;Tunne…...

selenium学习实战【Python爬虫】

selenium学习实战【Python爬虫】 文章目录 selenium学习实战【Python爬虫】一、声明二、学习目标三、安装依赖3.1 安装selenium库3.2 安装浏览器驱动3.2.1 查看Edge版本3.2.2 驱动安装 四、代码讲解4.1 配置浏览器4.2 加载更多4.3 寻找内容4.4 完整代码 五、报告文件爬取5.1 提…...

如何更改默认 Crontab 编辑器 ?

在 Linux 领域中&#xff0c;crontab 是您可能经常遇到的一个术语。这个实用程序在类 unix 操作系统上可用&#xff0c;用于调度在预定义时间和间隔自动执行的任务。这对管理员和高级用户非常有益&#xff0c;允许他们自动执行各种系统任务。 编辑 Crontab 文件通常使用文本编…...

MySQL JOIN 表过多的优化思路

当 MySQL 查询涉及大量表 JOIN 时&#xff0c;性能会显著下降。以下是优化思路和简易实现方法&#xff1a; 一、核心优化思路 减少 JOIN 数量 数据冗余&#xff1a;添加必要的冗余字段&#xff08;如订单表直接存储用户名&#xff09;合并表&#xff1a;将频繁关联的小表合并成…...

NPOI Excel用OLE对象的形式插入文件附件以及插入图片

static void Main(string[] args) {XlsWithObjData();Console.WriteLine("输出完成"); }static void XlsWithObjData() {// 创建工作簿和单元格,只有HSSFWorkbook,XSSFWorkbook不可以HSSFWorkbook workbook new HSSFWorkbook();HSSFSheet sheet (HSSFSheet)workboo…...

ThreadLocal 源码

ThreadLocal 源码 此类提供线程局部变量。这些变量不同于它们的普通对应物&#xff0c;因为每个访问一个线程局部变量的线程&#xff08;通过其 get 或 set 方法&#xff09;都有自己独立初始化的变量副本。ThreadLocal 实例通常是类中的私有静态字段&#xff0c;这些类希望将…...

用 FFmpeg 实现 RTMP 推流直播

RTMP&#xff08;Real-Time Messaging Protocol&#xff09; 是直播行业中常用的传输协议。 一般来说&#xff0c;直播服务商会给你&#xff1a; ✅ 一个 RTMP 推流地址&#xff08;你推视频上去&#xff09; ✅ 一个 HLS 或 FLV 拉流地址&#xff08;观众观看用&#xff09;…...