主頁 > 作業系統 > 分布式kv存盤系統之Etcd集群

分布式kv存盤系統之Etcd集群

2021-01-31 06:09:06 作業系統

  etcd是什么?

  etcd是一個高可用的分布式鍵值資料庫,可用于服務發現,etcd采用 raft 一致性演算法,基于 Go 語言實作,其特點有簡單易用,所謂簡單易用是指安裝配置簡單,提供http/https介面;安全,安全是指etcd支持ssl證書認證,支持集群各節點間使用對等證書認證;客戶端和服務端的雙向證書認證;可靠,可靠是指etcd使用raft協議實作分布式系統資料的可用性和一致性;etcd主要有兩個版本v2和v3;v2和v3的api是互不兼容的,所以我們在同一服務器上安裝多個版本的etcd時,我們需要用ETCDCTL_API這個環境變數指定;

  etcd集群部署

  環境準備

主機名稱 ip地址
master01.k8s.org 192.168.0.41
master02.k8s.org 192.168.0.42
master03.k8s.org 192.168.0.43

 

 

 

 

 

  各主機hosts檔案決議

[root@master01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.99 time.test.org time-node
192.168.0.41  master01 master01.k8s.org etcd01 etcd01.k8s.org 
192.168.0.42  master02 master02.k8s.org etcd02 etcd02.k8s.org
192.168.0.43  master03 master03.k8s.org etcd03 etcd03.k8s.org
192.168.0.44  node01 node01.k8s.org
192.168.0.45  node02 node02.k8s.org
192.168.0.46  node03 node03.k8s.org
[root@master01 ~]# 

  關閉各主機的firewalld服務

[root@master01 ~]# systemctl stop firewalld
[root@master01 ~]# systemctl disable firewalld
[root@master01 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@master01 ~]# 

  各主機間時間同步

[root@master01 ~]# grep server /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
server time.test.org iburst
# Serve time even if not synchronized to any NTP server.
[root@master01 ~]# systemctl restart chronyd.service 
[root@master01 ~]# systemctl status chronyd.service
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-01-30 15:41:25 CST; 11s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 1411 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 1407 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 1409 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─1409 /usr/sbin/chronyd

Jan 30 15:41:25 master01.k8s.org systemd[1]: Stopped NTP client/server.
Jan 30 15:41:25 master01.k8s.org systemd[1]: Starting NTP client/server...
Jan 30 15:41:25 master01.k8s.org chronyd[1409]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SI...+DEBUG)
Jan 30 15:41:25 master01.k8s.org chronyd[1409]: commandkey directive is no longer supported
Jan 30 15:41:25 master01.k8s.org chronyd[1409]: generatecommandkey directive is no longer supported
Jan 30 15:41:25 master01.k8s.org chronyd[1409]: Frequency -25.600 +/- 2.450 ppm read from /var/lib/chrony/drift
Jan 30 15:41:25 master01.k8s.org systemd[1]: Started NTP client/server.
Jan 30 15:41:29 master01.k8s.org chronyd[1409]: Selected source 192.168.0.99
Hint: Some lines were ellipsized, use -l to show in full.
[root@master01 ~]# 

  提示:集群內部可以使用自己搭建的時間服務,把chrony.conf中的server 指向對應時間服務器,然后重啟chronyd即可;當然也可以使用互聯網上公有的時間服務器;總之一個服務以集群方式作業,其時間同步是非常重要;

  各主機間ssh 互信

[root@master01 ~]# ssh master02
Last login: Sat Jan 30 15:34:33 2021 from master01
[root@master02 ~]# exit
logout
Connection to master02 closed.
[root@master01 ~]# ssh master03
Last login: Sat Jan 30 15:34:37 2021 from master01
[root@master03 ~]# exit
logout
Connection to master03 closed.
[root@master01 ~]# 

  提示:有關ssh互信的配置請參考本人博客:https://www.cnblogs.com/qiuhom-1874/p/11783371.html;各主機間實作ssh互信,其主要目的是方便各組件同步檔案;做好以上準備以后,我們就可以下載etcd二進制包進行etcd集群部署;這里需要說明一下,在centos7上的extras倉庫中有etcd的rpm包,我們可以使用yum來安裝;但是extras倉庫中的版本不是最新的,要想使用最新的就需要到官方github倉庫中下載最新版本的etcd二進制包進行部署;兩種部署方式沒有什么特別的不同;如果對版本要求不是特別新的環境中,建議使用yum安裝;

  下載etcd二進制包

[root@master01 ~]#wget https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz
--2021-01-30 15:46:18--  https://github.com/etcd-io/etcd/releases/download/v3.4.14/etcd-v3.4.14-linux-amd64.tar.gz
Resolving github.com (github.com)... 52.192.72.89
Connecting to github.com (github.com)|52.192.72.89|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-releases.githubusercontent.com/11225014/ad6a1d80-2f1a-11eb-8cb8-2f1ae35d5487?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210130%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210130T074619Z&X-Amz-Expires=300&X-Amz-Signature=47569782ddb8a1f70fbd28350433d3a045d22f040dd95b7de1055c96e7b4c359&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=11225014&response-content-disposition=attachment%3B%20filename%3Detcd-v3.4.14-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2021-01-30 15:46:19--  https://github-releases.githubusercontent.com/11225014/ad6a1d80-2f1a-11eb-8cb8-2f1ae35d5487?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210130%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210130T074619Z&X-Amz-Expires=300&X-Amz-Signature=47569782ddb8a1f70fbd28350433d3a045d22f040dd95b7de1055c96e7b4c359&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=11225014&response-content-disposition=attachment%3B%20filename%3Detcd-v3.4.14-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.111.154, 185.199.109.154, 185.199.108.154, ...
Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.111.154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17373058 (17M) [application/octet-stream]
Saving to: ‘etcd-v3.4.14-linux-amd64.tar.gz’

100%[=================================================================================================>] 17,373,058  24.9MB/s   in 0.7s   

2021-01-30 15:46:20 (24.9 MB/s) - ‘etcd-v3.4.14-linux-amd64.tar.gz’ saved [17373058/17373058]
[root@master01 ~]#

  解壓etcd二進制包

[root@master01 ~]# ls
etcd-v3.4.14-linux-amd64.tar.gz
[root@master01 ~]# tar xf etcd-v3.4.14-linux-amd64.tar.gz  -C /usr/local/src/
[root@master01 ~]# cd /usr/local/src/
[root@master01 src]# ls
etcd-v3.4.14-linux-amd64
[root@master01 src]# cd etcd-v3.4.14-linux-amd64/
[root@master01 etcd-v3.4.14-linux-amd64]# ls
Documentation  etcd  etcdctl  README-etcdctl.md  README.md  READMEv2-etcdctl.md
[root@master01 etcd-v3.4.14-linux-amd64]# 

  把etcd和etcdctl軟連接至path環境變數下

[root@master01 etcd-v3.4.14-linux-amd64]# ls
Documentation  etcd  etcdctl  README-etcdctl.md  README.md  READMEv2-etcdctl.md
[root@master01 etcd-v3.4.14-linux-amd64]# ln -s /usr/local/src/etcd-v3.4.14-linux-amd64/etcd /usr/bin/
[root@master01 etcd-v3.4.14-linux-amd64]# ln -s /usr/local/src/etcd-v3.4.14-linux-amd64/etcdctl /usr/bin/
[root@master01 etcd-v3.4.14-linux-amd64]# ll /usr/bin/etcd
lrwxrwxrwx 1 root root 44 Jan 30 15:59 /usr/bin/etcd -> /usr/local/src/etcd-v3.4.14-linux-amd64/etcd
[root@master01 etcd-v3.4.14-linux-amd64]# ll /usr/bin/etcdctl 
lrwxrwxrwx 1 root root 47 Jan 30 15:59 /usr/bin/etcdctl -> /usr/local/src/etcd-v3.4.14-linux-amd64/etcdctl
[root@master01 etcd-v3.4.14-linux-amd64]# 

  撰寫etcd.service unit檔案

[root@master01 ~]# cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target

[Service]
Type=simple
WorkingDirectory=/var/lib/etcd
EnvironmentFile=-/etc/etcd/etcd.conf
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd"
Type=notify

[Install]
WantedBy=multi-user.target
[root@master01 ~]# 

  提供etcd環境變數加載檔案/etc/etcd/etcd.conf檔案

[root@master01 ~]# mkdir /etc/etcd/
[root@master01 ~]# cd /etc/etcd/
[root@master01 etcd]# vim etcd.conf
#[Member]
#ETCD_CORS=""
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#ETCD_WAL_DIR=""
#ETCD_LISTEN_PEER_URLS="http://localhost:2380"
ETCD_LISTEN_CLIENT_URLS="http://localhost:2379"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
ETCD_NAME="default"
#ETCD_SNAPSHOT_COUNT="100000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_QUOTA_BACKEND_BYTES="0"
#ETCD_MAX_REQUEST_BYTES="1572864"
#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"
#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"
#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"
#
#[Clustering]
#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#ETCD_DISCOVERY_SRV=""
#ETCD_INITIAL_CLUSTER="default=http://localhost:2380"
#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
#ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_STRICT_RECONFIG_CHECK="true"
#ETCD_ENABLE_V2="true"
#
#[Proxy]
#ETCD_PROXY="off"
#ETCD_PROXY_FAILURE_WAIT="5000"
#ETCD_PROXY_REFRESH_INTERVAL="30000"
#ETCD_PROXY_DIAL_TIMEOUT="1000"
#ETCD_PROXY_WRITE_TIMEOUT="5000"
#ETCD_PROXY_READ_TIMEOUT="0"
#
#[Security]
#ETCD_CERT_FILE=""
#ETCD_KEY_FILE=""
#ETCD_CLIENT_CERT_AUTH="false"
#ETCD_TRUSTED_CA_FILE=""
#ETCD_AUTO_TLS="false"
#ETCD_PEER_CERT_FILE=""
#ETCD_PEER_KEY_FILE=""
#ETCD_PEER_CLIENT_CERT_AUTH="false"
#ETCD_PEER_TRUSTED_CA_FILE=""
#ETCD_PEER_AUTO_TLS="false"
#
#[Logging]
#ETCD_DEBUG="false"
#ETCD_LOG_PACKAGE_LEVELS=""
#ETCD_LOG_OUTPUT="default"
#
#[Unsafe]
#ETCD_FORCE_NEW_CLUSTER="false"
#
#[Version]
#ETCD_VERSION="false"
#ETCD_AUTO_COMPACTION_RETENTION="0"
#
#[Profiling]
#ETCD_ENABLE_PPROF="false"
#ETCD_METRICS="basic"
#
#[Auth]
#ETCD_AUTH_TOKEN="simple"
"etcd.conf" [New] 69L, 1686C written                                                                                     
[root@master01 etcd]# 

  更改etcd.conf檔案

  提示:ETCD_DATA_DIR用于指定etcd資料目錄;ETCD_LISTEN_PEER_URLS用于指定集群節點通信監聽的url地址;ETCD_LISTEN_CLIENT_URLS用戶指定客戶端連接使用時的url地址;ETCD_NAME用戶指定當前節點etcd實體的名稱;ETCD_INITIAL_ADVERTISE_PEER_URLS用于指定集群事務通告的url地址;ETCD_ADVERTISE_CLIENT_URLS用戶指定客戶端事務通告url地址;ETCD_INITIAL_CLUSTER用戶指定集群成員,一個成員由成員名稱=對應集群間通信的url地址,多個成員用逗號隔開;

  創建/var/lib/etcd目錄

[root@master01 etcd]# mkdir /var/lib/etcd/
[root@master01 etcd]# ll -d /var/lib/etcd/
drwxr-xr-x 2 root root 6 Jan 30 16:20 /var/lib/etcd/
[root@master01 etcd]# 

  復制master01上的/usr/bin/etcd和etcdctl二進制檔案到master02和master03的/usr/bin/目錄下

[root@master01 etcd]# scp /usr/bin/etcd /usr/bin/etcdctl master02:/usr/bin/
etcd                                                                                                     100%   23MB  43.6MB/s   00:00    
etcdctl                                                                                                  100%   17MB  49.1MB/s   00:00    
[root@master01 etcd]# scp /usr/bin/etcd /usr/bin/etcdctl master03:/usr/bin/
etcd                                                                                                     100%   23MB  42.2MB/s   00:00    
etcdctl                                                                                                  100%   17MB  56.8MB/s   00:00    
[root@master01 etcd]# 

  復制master01上的etcd.service到master02和master03的/usr/lib/systemd/system目錄下

[root@master01 etcd]# scp /usr/lib/systemd/system/etcd.service master02:/usr/lib/systemd/system/
etcd.service                                                                                             100%  417   165.1KB/s   00:00    
[root@master01 etcd]# scp /usr/lib/systemd/system/etcd.service master03:/usr/lib/systemd/system/
etcd.service                                                                                             100%  417   175.7KB/s   00:00    
[root@master01 etcd]# 

  在master02和master03上創建/etc/etcd/目錄和/var/lib/etcd/目錄

[root@master01 etcd]# ssh master02 'mkdir /etc/etcd/ && mkdir /var/lib/etcd'
[root@master01 etcd]# ssh master03 'mkdir /etc/etcd/ && mkdir /var/lib/etcd' 
[root@master01 etcd]# 

  復制master01上的etcd.conf檔案到master02和master03的/etc/etcd/目錄下

[root@master01 etcd]# scp /etc/etcd/etcd.conf master02:/etc/etcd/
etcd.conf                                                                                                100% 1749   743.3KB/s   00:00    
[root@master01 etcd]# scp /etc/etcd/etcd.conf master03:/etc/etcd/
etcd.conf                                                                                                100% 1749   824.2KB/s   00:00    
[root@master01 etcd]# 

  修改master02上的/etc/etcd/etcd.conf檔案

  修改master03上的/etc/etcd/etcd.conf檔案

  到此三個節點的組態檔和相關用戶以及目錄都準備就緒,接下來我們要多載systemd的組態檔,加載etcd.service檔案

[root@master01 ~]# systemctl daemon-reload
[root@master01 ~]# ssh master02 'systemctl daemon-reload'
[root@master01 ~]# ssh master03 'systemctl daemon-reload' 
[root@master01 ~]# 

  啟動etcd

[root@master01 ~]# systemctl start etcd
[root@master01 ~]# 

  提示:在每個節點上運行上述命令啟動etcd;第一個啟動的節點將阻塞,原因是etcd以集群方式作業,它必須要有足夠的得票才能正常作業,如果集群節點有3個,那么至少有兩個節點正常啟動etcd才能正常作業;

  驗證:查看各節點的2379和2380埠是否都處于監聽?

[root@master01 ~]# ss -tnl
State      Recv-Q Send-Q                                Local Address:Port                                               Peer Address:Port              
LISTEN     0      128                                    192.168.0.41:2379                                                          *:*                  
LISTEN     0      128                                    192.168.0.41:2380                                                          *:*                  
LISTEN     0      128                                               *:22                                                            *:*                  
LISTEN     0      100                                       127.0.0.1:25                                                            *:*                  
LISTEN     0      128                                              :::22                                                           :::*                  
LISTEN     0      100                                             ::1:25                                                           :::*                  
[root@master01 ~]# ssh master02 'ss -tnl'
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128    192.168.0.42:2379                     *:*                  
LISTEN     0      128    192.168.0.42:2380                     *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@master01 ~]# ssh master03 'ss -tnl' 
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128    192.168.0.43:2379                     *:*                  
LISTEN     0      128    192.168.0.43:2380                     *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@master01 ~]# 

  驗證:使用etcdctl查看集群狀態

[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  endpoint status
192.168.0.41:2379, b8b747c74aaea686, 3.4.14, 4.5 MB, true, false, 13, 2163, 2163, 
192.168.0.42:2379, b3504381e8ba3cb, 3.4.14, 4.5 MB, false, false, 13, 2163, 2163, 
192.168.0.43:2379, f572fdfc5cb68406, 3.4.14, 4.5 MB, false, false, 13, 2163, 2163, 
[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  member list
b3504381e8ba3cb, started, etcd02, http://etcd02:2380, http://etcd02:2379, false
b8b747c74aaea686, started, etcd01, http://etcd01:2380, http://etcd01:2379, false
f572fdfc5cb68406, started, etcd03, http://etcd03:2380, http://etcd03:2379, false
[root@master01 ~]# 

  提示:能夠列出集群成員和查看集群成員狀態,就表示etcd集群作業已經正常;

  驗證:向etcd任意節點寫資料,看看是否能夠正常寫?

[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  put name "test"
OK
[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  get name 
name
test
[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  del name    
1
[root@master01 ~]# etcdctl --endpoints=192.168.0.41:2379,192.168.0.42:2379,192.168.0.43:2379  get name 
[root@master01 ~]# 

  提示:使用etcdctl工具可以正常向etcd集群寫入資料;

  為etcd集群生成證書

  在某一節點上安裝git工具

[root@master01 ~]# yum install git -y 

  克隆生成證書的腳本工具

[root@master01 ~]# git clone https://github.com/iKubernetes/k8s-certs-generator.git
Cloning into 'k8s-certs-generator'...
remote: Enumerating objects: 58, done.
remote: Total 58 (delta 0), reused 0 (delta 0), pack-reused 58
Unpacking objects: 100% (58/58), done.
[root@master01 ~]# ls
etcd-v3.4.14-linux-amd64.tar.gz  k8s-certs-generator
[root@master01 ~]# cd k8s-certs-generator/
[root@master01 k8s-certs-generator]# ls
etcd-certs-gen.sh  gencerts.sh  k8s-certs-gen.sh  openssl.conf  README.md
[root@master01 k8s-certs-generator]# 

  使用gencerts.sh腳本生成etcd所需證書

[root@master01 k8s-certs-generator]# sh gencerts.sh -h
Usage: ./gencerts.sh etcd|k8s
[root@master01 k8s-certs-generator]# sh gencerts.sh etcd
Enter Domain Name [ilinux.io]: k8s.org
Generating RSA private key, 4096 bit long modulus
.......++
.................................................................................................................................................................................................................................................................++
e is 65537 (0x10001)
Generating RSA private key, 2048 bit long modulus
.................................................+++
.........................+++
e is 65537 (0x10001)
Generating etcd/pki/peer.csr
Generating RSA private key, 2048 bit long modulus
...........................................................................................................................................+++
...............+++
e is 65537 (0x10001)
Generating etcd/pki/server.csr
Generating RSA private key, 2048 bit long modulus
..............................................................+++
............................+++
e is 65537 (0x10001)
Generating etcd/pki/apiserver-etcd-client.csr
Generating RSA private key, 2048 bit long modulus
............+++
.................................+++
e is 65537 (0x10001)
Generating etcd/pki/client.csr
Generating etcd/pki/peer.crt
Using configuration from openssl.conf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 4096 (0x1000)
        Validity
            Not Before: Jan 30 10:46:52 2021 GMT
            Not After : Jan 28 10:46:52 2031 GMT
        Subject:
            commonName                = etcd
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Cert Type: 
                SSL Server
            Netscape Comment: 
                OpenSSL Generated Server Certificate
            X509v3 Subject Key Identifier: 
                FC:BA:D7:73:4E:C7:1D:9D:73:12:E3:60:96:5B:69:58:CE:4F:14:FD
            X509v3 Authority Key Identifier: 
                keyid:9C:C0:85:32:DE:F7:78:C0:90:D5:E1:20:F9:14:A7:1A:F4:5B:C5:BE
                DirName:/CN=etcd-ca
                serial:BE:88:C0:B5:81:5D:6D:D6

            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication, TLS Web Client Authentication
            X509v3 Subject Alternative Name: 
                DNS:*.k8s.org
Certificate is to be certified until Jan 28 10:46:52 2031 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
Generating etcd/pki/server.crt
Using configuration from openssl.conf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 4097 (0x1001)
        Validity
            Not Before: Jan 30 10:46:53 2021 GMT
            Not After : Jan 28 10:46:53 2031 GMT
        Subject:
            commonName                = etcd
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Cert Type: 
                SSL Server
            Netscape Comment: 
                OpenSSL Generated Server Certificate
            X509v3 Subject Key Identifier: 
                1C:BE:22:C0:B7:5F:03:39:5C:E0:FC:47:88:8D:3A:FC:27:FA:0E:BC
            X509v3 Authority Key Identifier: 
                keyid:9C:C0:85:32:DE:F7:78:C0:90:D5:E1:20:F9:14:A7:1A:F4:5B:C5:BE
                DirName:/CN=etcd-ca
                serial:BE:88:C0:B5:81:5D:6D:D6

            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication
            X509v3 Subject Alternative Name: 
                DNS:*.k8s.org
Certificate is to be certified until Jan 28 10:46:53 2031 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
Generating etcd/pki/apiserver-etcd-client.crt
Using configuration from openssl.conf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 4098 (0x1002)
        Validity
            Not Before: Jan 30 10:46:53 2021 GMT
            Not After : Jan 28 10:46:53 2031 GMT
        Subject:
            commonName                = etcd
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Cert Type: 
                SSL Client
            Netscape Comment: 
                OpenSSL Generated Client Certificate
            X509v3 Subject Key Identifier: 
                FD:52:EA:9F:84:72:35:46:9A:33:71:DE:D0:41:E6:8D:89:C0:62:AE
            X509v3 Authority Key Identifier: 
                keyid:9C:C0:85:32:DE:F7:78:C0:90:D5:E1:20:F9:14:A7:1A:F4:5B:C5:BE

            X509v3 Key Usage: critical
                Digital Signature, Non Repudiation, Key Encipherment
            X509v3 Extended Key Usage: 
                TLS Web Client Authentication
Certificate is to be certified until Jan 28 10:46:53 2031 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
Generating etcd/pki/client.crt
Using configuration from openssl.conf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 4099 (0x1003)
        Validity
            Not Before: Jan 30 10:46:53 2021 GMT
            Not After : Jan 28 10:46:53 2031 GMT
        Subject:
            commonName                = etcd
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Cert Type: 
                SSL Client
            Netscape Comment: 
                OpenSSL Generated Client Certificate
            X509v3 Subject Key Identifier: 
                6B:31:50:84:00:9E:0F:6E:B8:56:7A:C1:57:82:F4:BB:12:57:52:B2
            X509v3 Authority Key Identifier: 
                keyid:9C:C0:85:32:DE:F7:78:C0:90:D5:E1:20:F9:14:A7:1A:F4:5B:C5:BE

            X509v3 Key Usage: critical
                Digital Signature, Non Repudiation, Key Encipherment
            X509v3 Extended Key Usage: 
                TLS Web Client Authentication
Certificate is to be certified until Jan 28 10:46:53 2031 GMT (3650 days)

Write out database with 1 new entries
Data Base Updated
[root@master01 k8s-certs-generator]# ls
etcd  etcd-certs-gen.sh  gencerts.sh  k8s-certs-gen.sh  openssl.conf  README.md
[root@master01 k8s-certs-generator]# ls etcd
patches  pki
[root@master01 k8s-certs-generator]# ls etcd/pki/
apiserver-etcd-client.crt  apiserver-etcd-client.key  ca.crt  ca.key  client.crt  client.key  peer.crt  peer.key  server.crt  server.key
[root@master01 k8s-certs-generator]# 

  提示:server.crt和server.key用于etcd服務端的證書和密鑰;peer.crt和peer.key用于集群內部各節間認證所需證書和密鑰;client.crt和client.key用于客戶端連接服務端所需的證書和密鑰;ca.crt和ca.key是用于集群內部做認證和客戶端連接服務端所信任的ca的證書和密鑰;

  復制證書檔案到其他節點

[root@master01 k8s-certs-generator]# cp -a etcd/pki/ /etc/etcd/
[root@master01 k8s-certs-generator]# cd /etc/etcd/
[root@master01 etcd]# ls
etcd.conf  pki
[root@master01 etcd]# scp -r pki/ master02:/etc/etcd/
ca.key                                                                                                                  100% 3247     1.8MB/s   00:00    
ca.crt                                                                                                                  100% 1814     1.2MB/s   00:00    
peer.key                                                                                                                100% 1679     1.1MB/s   00:00    
server.key                                                                                                              100% 1679     1.2MB/s   00:00    
apiserver-etcd-client.key                                                                                               100% 1675     1.3MB/s   00:00    
client.key                                                                                                              100% 1675     1.1MB/s   00:00    
peer.crt                                                                                                                100% 1659    75.0KB/s   00:00    
server.crt                                                                                                              100% 1647   917.8KB/s   00:00    
apiserver-etcd-client.crt                                                                                               100% 1570     1.2MB/s   00:00    
client.crt                                                                                                              100% 1570   902.2KB/s   00:00    
[root@master01 etcd]# scp -r pki/ master03:/etc/etcd/
ca.key                                                                                                                  100% 3247     1.1MB/s   00:00    
ca.crt                                                                                                                  100% 1814   695.0KB/s   00:00    
peer.key                                                                                                                100% 1679   621.6KB/s   00:00    
server.key                                                                                                              100% 1679   657.1KB/s   00:00    
apiserver-etcd-client.key                                                                                               100% 1675   950.4KB/s   00:00    
client.key                                                                                                              100% 1675     1.0MB/s   00:00    
peer.crt                                                                                                                100% 1659   916.3KB/s   00:00    
server.crt                                                                                                              100% 1647     1.0MB/s   00:00    
apiserver-etcd-client.crt                                                                                               100% 1570   850.8KB/s   00:00    
client.crt                                                                                                              100% 1570   872.7KB/s   00:00    
[root@master01 etcd]# 

  配置etcd基于https協議提供服務

  配置master01上的etcd啟用證書認證

[root@master01 etcd]# cat etcd.conf 
#[Member]
#ETCD_CORS=""
ETCD_DATA_DIR="/var/lib/etcd/cluster.etcd"
#ETCD_WAL_DIR=""
ETCD_LISTEN_PEER_URLS="http://192.168.0.41:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.41:2379"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
ETCD_NAME="etcd01"
#ETCD_SNAPSHOT_COUNT="100000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_QUOTA_BACKEND_BYTES="0"
#ETCD_MAX_REQUEST_BYTES="1572864"
#ETCD_GRPC_KEEPALIVE_MIN_TIME="5s"
#ETCD_GRPC_KEEPALIVE_INTERVAL="2h0m0s"
#ETCD_GRPC_KEEPALIVE_TIMEOUT="20s"
#
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://etcd01:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://etcd01:2379"
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#ETCD_DISCOVERY_SRV=""
ETCD_INITIAL_CLUSTER="etcd01=http://etcd01:2380,etcd02=http://etcd02:2380,etcd03=http://etcd03:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_STRICT_RECONFIG_CHECK="true"
#ETCD_ENABLE_V2="true"
#
#[Proxy]
#ETCD_PROXY="off"
#ETCD_PROXY_FAILURE_WAIT="5000"
#ETCD_PROXY_REFRESH_INTERVAL="30000"
#ETCD_PROXY_DIAL_TIMEOUT="1000"
#ETCD_PROXY_WRITE_TIMEOUT="5000"
#ETCD_PROXY_READ_TIMEOUT="0"
#
#[Security]
ETCD_CERT_FILE="/etc/etcd/pki/server.crt"
ETCD_KEY_FILE="/etc/etcd/pki/server.key"
ETCD_CLIENT_CERT_AUTH="true"
ETCD_TRUSTED_CA_FILE="/etc/etcd/pki/ca.crt"
ETCD_AUTO_TLS="false"
ETCD_PEER_CERT_FILE="/etc/etcd/pki/peer.crt"
ETCD_PEER_KEY_FILE="/etc/etcd/pki/peer.key"
ETCD_PEER_CLIENT_CERT_AUTH="true"
ETCD_PEER_TRUSTED_CA_FILE="/etc/etcd/pki/ca.crt"
ETCD_PEER_AUTO_TLS="false"
#
#[Logging]
#ETCD_DEBUG="false"
#ETCD_LOG_PACKAGE_LEVELS=""
#ETCD_LOG_OUTPUT="default"
#
#[Unsafe]
#ETCD_FORCE_NEW_CLUSTER="false"
#
#[Version]
#ETCD_VERSION="false"
#ETCD_AUTO_COMPACTION_RETENTION="0"
#
#[Profiling]
#ETCD_ENABLE_PPROF="false"
#ETCD_METRICS="basic"
#
#[Auth]
#ETCD_AUTH_TOKEN="simple"
[root@master01 etcd]# 

  提示:ETCD_CERT_FILE用于指定etcd服務端證書檔案路徑;ETCD_KEY_FILE用戶指定服務端證書檔案所對應的密鑰檔案路徑;ETCD_CLIENT_CERT_AUTH用戶指定是否啟用客戶端證書認證;ETCD_TRUSTED_CA_FILE用戶指定客戶端認證信任的ca證書檔案;

ETCD_AUTO_TLS用于指定是否自動生成證書檔案;ETCD_PEER_CERT_FILE用于指定集群間對等證書檔案路徑;ETCD_PEER_KEY_FILE用于指定集群間對等證書對應的密鑰檔案;ETCD_PEER_CLIENT_CERT_AUTH用于指定是否啟用對等證書認證;ETCD_PEER_TRUSTED_CA_FILE用于指定對等證書認證所信賴的ca證書;ETCD_PEER_AUTO_TLS用于指定是否自動生成對等證書;

  修改/etc/etcd/etcd.conf檔案,將etcd01修改成etcd01.k8s.org,將etcd02修改成etcd02.k8s.org,將etcd03修改成etcd03.k8s.org,將http修改成https

  停止etcd服務,洗掉/var/lib/etcd/目錄下的所有檔案

[root@master01 etcd]# systemctl stop etcd
[root@master01 etcd]# rm -rf /var/lib/etcd/*
[root@master01 etcd]# ll /var/lib/etcd/
total 0
[root@master01 etcd]# 

  配置master02啟用證書認證,并將對應http修改成很https,把對應短格式名稱修改為類似etcd01.k8s.org名稱

  停止etcd服務,洗掉/var/lib/etcd/目錄下的所有檔案

[root@master02 ~]# systemctl stop etcd
[root@master02 ~]# rm -rf /var/lib/etcd/*
[root@master02 ~]# ll /var/lib/etcd/
total 0
[root@master02 ~]# 

  配置master03啟用證書認證,并將對應http修改成很https,把對應短格式名稱修改為長格式名稱

  停止etcd服務,洗掉/var/lib/etcd下的所有檔案

[root@master03 ~]# systemctl stop etcd
[root@master03 ~]# rm -rf /var/lib/etcd/*
[root@master03 ~]# ll /var/lib/etcd/
total 0
[root@master03 ~]# 

  啟動各節點上的etcd

[root@master01 etcd]# systemctl start etcd
[root@master01 etcd]# 

  提示:如果三個節點上的etcd都能正常啟動,說明我們組態檔沒有問題;

  驗證:查看所有節點的etcd服務是否都正常啟動,并監聽對應的的埠?

[root@master01 etcd]# ss -tnl
State      Recv-Q Send-Q                                Local Address:Port                                               Peer Address:Port              
LISTEN     0      128                                    192.168.0.41:2379                                                          *:*                  
LISTEN     0      128                                    192.168.0.41:2380                                                          *:*                  
LISTEN     0      128                                               *:22                                                            *:*                  
LISTEN     0      100                                       127.0.0.1:25                                                            *:*                  
LISTEN     0      128                                              :::22                                                           :::*                  
LISTEN     0      100                                             ::1:25                                                           :::*                  
[root@master01 etcd]# ssh master02 'ss -tnl'
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128    192.168.0.42:2379                     *:*                  
LISTEN     0      128    192.168.0.42:2380                     *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@master01 etcd]# ssh master03 'ss -tnl' 
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128    192.168.0.43:2379                     *:*                  
LISTEN     0      128    192.168.0.43:2380                     *:*                  
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
[root@master01 etcd]# 

  驗證:查看集群成員

[root@master01 etcd]# etcdctl --endpoints="https://etcd01.k8s.org:2379,https://etcd02.k8s.org:2379,https://etcd03.k8s.org:2379" --cacert="/etc/etcd/pki/ca.crt" --cert="/etc/etcd/pki/client.crt" --key="/etc/etcd/pki/client.key" endpoint status
https://etcd01.k8s.org:2379, 61d91b7ed8f88f32, 3.4.14, 20 kB, true, false, 6, 9, 9, 
https://etcd02.k8s.org:2379, ef13441fdfe8af38, 3.4.14, 20 kB, false, false, 6, 9, 9, 
https://etcd03.k8s.org:2379, f11ed09b6567910f, 3.4.14, 20 kB, false, false, 6, 9, 9, 
[root@master01 etcd]# etcdctl --endpoints="https://etcd01.k8s.org:2379" --cacert="/etc/etcd/pki/ca.crt" --cert="/etc/etcd/pki/client.crt" --key="/etc/etcd/pki/client.key" member list
61d91b7ed8f88f32, started, etcd01.k8s.org, https://etcd01.k8s.org:2380, https://etcd01.k8s.org:2379, false
ef13441fdfe8af38, started, etcd02.k8s.org, https://etcd02.k8s.org:2380, https://etcd02.k8s.org:2379, false
f11ed09b6567910f, started, etcd03.k8s.org, https://etcd03.k8s.org:2380, https://etcd03.k8s.org:2379, false
[root@master01 etcd]# 

  提示:現在etcd啟用了ssl認證功能,客戶端訪問必須攜帶對應的客戶端證書和私鑰檔案以及對應認證所信任的ca證書,才可以正常訪問到etcd集群;這里需要注意指定的endpoints需要使用域名格式給出,給定ip地址是無法正常通過認證的;

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/254658.html

標籤:其他

上一篇:linux服務器命令

下一篇:關于steam游戲的問題 求大佬幫幫忙?

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • CA和證書

    1、在 CentOS7 中使用 gpg 創建 RSA 非對稱密鑰對 gpg --gen-key #Centos上生成公鑰/密鑰對(存放在家目錄.gnupg/) 2、將 CentOS7 匯出的公鑰,拷貝到 CentOS8 中,在 CentOS8 中使用 CentOS7 的公鑰加密一個檔案 gpg -a ......

    uj5u.com 2020-09-10 00:09:53 more
  • Kubernetes K8S之資源控制器Job和CronJob詳解

    Kubernetes的資源控制器Job和CronJob詳解與示例 ......

    uj5u.com 2020-09-10 00:10:45 more
  • VMware下安裝CentOS

    VMware下安裝CentOS 一、軟硬體準備 1 Centos鏡像準備 1.1 CentOS鏡像下載地址 下載地址 1.2 CentOS鏡像下載程序 點擊下載地址進入如下圖的網站,選擇需要下載的版本,這里選擇的是Centos8,點擊如圖所示。 決定選擇Centos8后,選擇想要的鏡像源進行下載,此 ......

    uj5u.com 2020-09-10 00:12:10 more
  • 如何使用Grep命令查找多個字串

    如何使用Grep 命令查找多個字串 大家好,我是良許! 今天向大家介紹一個非常有用的技巧,那就是使用 grep 命令查找多個字串。 簡單介紹一下,grep 命令可以理解為是一個功能強大的命令列工具,可以用它在一個或多個輸入檔案中搜索與正則運算式相匹配的文本,然后再將每個匹配的文本用標準輸出的格式 ......

    uj5u.com 2020-09-10 00:12:28 more
  • git配置http代理

    git配置http代理 經常遇到克隆 github 慢的問題,這里記錄一下幾種配置 git 代理的方法,解決 clone github 過慢。 目錄 git配置代理 git單獨配置github代理 git配置全域代理 配置終端環境變數 git配置代理 主要使用 git config 命令 git單獨 ......

    uj5u.com 2020-09-10 00:12:33 more
  • Linux npm install 裝包時提示Error EACCES permission denied解

    npm install 裝包時提示Error EACCES permission denied解決辦法 ......

    uj5u.com 2020-09-10 00:12:53 more
  • Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包

    Centos 7下安裝nginx,使用yum install nginx,提示沒有可用的軟體包。 18 (flaskApi) [root@67 flaskDemo]# yum -y install nginx 19 已加載插件:fastestmirror, langpacks 20 Loading ......

    uj5u.com 2020-09-10 00:13:13 more
  • Linux查看服務器暴力破解ssh IP

    在公網的服務器上經常遇到別人爆破你服務器的22埠,用來挖礦或者干其他嘿嘿嘿的事情~ 這種情況下正確的做法是: 修改默認ssh的22埠 使用設定密鑰登錄或者白名單ip登錄 建議服務器密碼為復雜密碼 創建普通用戶登錄服務器(root權限過大) 建立堡壘機,實作統一管理服務器 統計爆破IP [root ......

    uj5u.com 2020-09-10 00:13:17 more
  • CentOS 7系統常見快捷鍵操作方式

    Linux系統中一些常見的快捷方式,可有效提高操作效率,在某些時刻也能避免操作失誤帶來的問題。 ......

    uj5u.com 2020-09-10 00:13:31 more
  • CentOS 7作業系統目錄結構介紹

    作業系統存在著大量的資料檔案資訊,相應檔案資訊會存在于系統相應目錄中,為了更好的管理資料資訊,會將系統進行一些目錄規劃,不同目錄存放不同的資源。 ......

    uj5u.com 2020-09-10 00:13:35 more
最新发布
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:43:21 more
  • vim的常用命令

    Vim的6種基本模式 1. 普通模式在普通模式中,用的編輯器命令,比如移動游標,洗掉文本等等。這也是Vim啟動后的默認模式。這正好和許多新用戶期待的操作方式相反(大多數編輯器默認模式為插入模式)。 2. 插入模式在這個模式中,大多數按鍵都會向文本緩沖中插入文本。大多數新用戶希望文本編輯器編輯程序中一 ......

    uj5u.com 2023-04-20 08:42:36 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:26:53 more
  • 設定Windows主機的瀏覽器為wls2的默認瀏覽器

    這里以Chrome為例。 1. 準備作業 wsl是可以使用Windows主機上安裝的exe程式,出于安全考慮,默認情況下改功能是無法使用。要使用的話,終端需要以管理員權限啟動。 我這里以Windows Terminal為例,介紹如何默認使用管理員權限打開終端,具體操作如下圖所示: 2. 操作 wsl ......

    uj5u.com 2023-04-19 09:25:49 more
  • docker學習

    ###Docker概述 真實專案部署環境可能非常復雜,傳統發布專案一個只需要一個jar包,運行環境需要單獨部署。而通過Docker可將jar包和相關環境(如jdk,redis,Hadoop...)等打包到docker鏡像里,將鏡像發布到Docker倉庫,部署時下載發布的鏡像,直接運行發布的鏡像即可。 ......

    uj5u.com 2023-04-19 09:19:04 more
  • Linux學習筆記

    IP地址和主機名 IP地址 ifconfig可以用來查詢本機的IP地址,如果不能使用,可以通過install net-tools安裝。 Centos系統下ens33表示主網卡;inet后表示IP地址;lo表示本地回環網卡; 127.0.0.1表示代指本機;0.0.0.0可以用于代指本機,同時在放行設 ......

    uj5u.com 2023-04-18 06:52:01 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:50 more
  • 解決linux系統的kdump服務無法啟動的問題

    問題:專案麒麟系統服務器的kdump服務無法啟動,沒有相關日志無法定位問題。 1、查看服務狀態是關閉的,重啟系統也無法啟動 systemctl status kdump 2、修改grub引數,修改“crashkernel”為“512M(有的機器數值太大太小都會導致報錯,建議從128M開始試,或者加個 ......

    uj5u.com 2023-04-12 09:59:01 more
  • 你是不是暴露了?

    作者:袁首京 原創文章,轉載時請保留此宣告,并給出原文連接。 如果您是計算機相關從業人員,那么應該經歷不止一次網路安全專項檢查了,你肯定是收到過資訊系統技術檢測報告,要求你加強風險監測,確保你提供的系統服務堅實可靠了。 沒檢測到問題還好,檢測到問題的話,有些處理起來還是挺麻煩的,尤其是線上正在運行的 ......

    uj5u.com 2023-04-05 16:52:56 more
  • 細節拉滿,80 張圖帶你一步一步推演 slab 記憶體池的設計與實作

    1. 前文回顧 在之前的幾篇記憶體管理系列文章中,筆者帶大家從宏觀角度完整地梳理了一遍 Linux 記憶體分配的整個鏈路,本文的主題依然是記憶體分配,這一次我們會從微觀的角度來探秘一下 Linux 內核中用于零散小記憶體塊分配的記憶體池 —— slab 分配器。 在本小節中,筆者還是按照以往的風格先帶大家簡單 ......

    uj5u.com 2023-04-05 16:44:11 more