附註:
- 此教學課程可在 Oracle 提供的免費實驗室環境中取得。
- 它使用 Oracle Cloud Infrastructure 證明資料、租用戶及區間的範例值。完成實驗室時,請將這些值取代為您雲端環境特定的值。
將 Oracle Linux Automation Manager 移轉至叢集部署
簡介
不論是從舊版升級或從單一主機安裝開始,這兩個環境都可以移轉至叢集部署。管理員必須在移轉前規劃其拓樸,因為叢集可能包含「控制層」、「執行」和「躍點」節點和遠端資料庫的組合。
完成此教學課程之後,您將知道如何將單一主機安裝移轉至遠端資料庫的叢集建置。
目標
在本教學課程中,您將瞭解如何:
- 設定遠端資料庫
- 移轉至叢集部署
必要條件
-
已安裝 Oracle Linux Automation Manager 的系統。
如需有關安裝 Oracle Linux Automation Manager 的詳細資訊,請參閱 Oracle Linux Automation Manager Installation Guide (僅英文版)。
部署 Oracle Linux Automation Manager
注意:如果在您自己的租用戶中執行,請先閱讀 linux-virt-labs
GitHub 專案 README.md 並完成先決條件,再部署實驗室環境。
-
在 Luna 桌面上開啟終端機。
-
複製
linux-virt-labs
GitHub 專案。git clone https://github.com/oracle-devrel/linux-virt-labs.git
-
變更至工作目錄。
cd linux-virt-labs/olam
-
安裝所需的集合。
ansible-galaxy collection install -r requirements.yml
-
更新 Oracle Linux 執行處理組態。
cat << EOF | tee instances.yml > /dev/null compute_instances: 1: instance_name: "olam-node" type: "control" 2: instance_name: "exe-node" type: "execution" 3: instance_name: "db-node" type: "db" passwordless_ssh: true add_cluster_ports: true EOF
-
部署實驗室環境。
ansible-playbook create_instance.yml -e ansible_python_interpreter="/usr/bin/python3.6" -e "@instances.yml" -e olam_single_host=true
免費實驗室環境需要額外的變數
ansible_python_interpreter
,因為它會安裝適用於 Oracle Cloud Infrastructure SDK for Python 的 RPM 套裝程式。此套裝軟體的安裝位置在 python3.6 模組下。預設部署資源配置使用 AMD CPU 和 Oracle Linux 8。若要使用 Intel CPU 或 Oracle Linux 9,請在部署命令中新增
-e instance_shape="VM.Standard3.Flex"
或-e os_version="9"
。重要事項:等待手冊順利執行並到達暫停工作。Oracle Linux Automation Manager 安裝已在手冊的這個階段完成,且執行處理已就緒。記下先前的播放,此播放會列印所部署節點的公用和專用 IP 位址。
登入 WebUI
-
開啟終端機並設定 Oracle Linux Automation Manager 的 SSH 通道。
ssh -L 8444:localhost:443 oracle@<hostname_or_ip_address>
在免費的實驗室環境中,使用 olam 節點執行處理的外部 IP 位址。
-
開啟 Web 瀏覽器並輸入 URL。
https://localhost:8444
注意:根據使用的瀏覽器來核准安全警告。若為 Chrome,請按一下 **Advanced 按鈕,然後按一下繼續 localhost (不安全) 連結。
-
使用
admin
的使用者名稱和自動部署期間建立的admin
密碼登入 Oracle Linux Automation Manager。 -
登入之後,就會顯示 WebUI。
移轉至叢集部署
雖然 Oracle Linux Automation Manager 是以單一主機部署方式執行,但也支援以具有遠端資料庫、個別控制層和執行節點的叢集方式執行。安裝會將單一主機執行處理設定為 hybrid
節點。移轉至叢集部署的第一個步驟是將此執行處理轉換成 control plane
節點。
如需有關不同安裝拓樸的詳細資訊,請參閱 Oracle Linux Automation Manager Installation Guide documentation 的 Planning the Installation 章節。
準備控制層節點
-
切換至連線至執行 Oracle Linux Automation Manager 之 olam-node 執行處理的終端機。
注意:從現在開始,我們將將此執行處理稱為控制層節點。
-
停止 Oracle Linux Automation Manager 服務。
sudo systemctl stop ol-automation-manager
-
建立資料庫備份。
sudo su - postgres -c 'pg_dumpall > /tmp/olamv2_db_dump'
安裝遠端資料庫
-
將資料庫備份從控制層節點複製到新的遠端資料庫主機。
scp /tmp/olamv2_db_dump oracle@db-node:/tmp/
scp
命令會使用節點之間的 SSH 連線進行通訊。此連線可能是由於免費實驗室環境在執行處理之間設定無密碼 SSH 登入。 -
透過 ssh 連線至 db-node 執行處理。
ssh oracle@db-node
-
啟用資料庫模組串流。
Oracle Linux Automation Manager 允許使用 Postgresql 資料庫版本 12 或 13。我們將在本教學課程中使用並啟用版本 13 模組串流。
sudo dnf -y module reset postgresql sudo dnf -y module enable postgresql:13
-
安裝資料庫伺服器。
sudo dnf -y install postgresql-server
-
新增資料庫防火牆規則。
sudo firewall-cmd --add-port=5432/tcp --permanent sudo firewall-cmd --reload
-
起始資料庫。
sudo postgresql-setup --initdb
-
設定資料庫預設儲存體演算法。
sudo sed -i "s/#password_encryption.*/password_encryption = scram-sha-256/" /var/lib/pgsql/data/postgresql.conf
如需有關此資料庫功能的詳細資訊,請參閱上游文件中的密碼認證。
-
更新資料庫主機式認證檔案。
echo "host all all 0.0.0.0/0 scram-sha-256" | sudo tee -a /var/lib/pgsql/data/pg_hba.conf > /dev/null
這一行額外的驗證方式是執行 SCRAM-SHA-256 驗證,驗證從任何 IP 位址連線時使用者的密碼。
-
更新資料庫監聽連線的 listen_address 值。
sudo sed -i "/^#port = 5432/i listen_addresses = '"$(hostname -s)"'" /var/lib/pgsql/data/postgresql.conf
您可以為此值選擇 IP 位址或主機名稱。此教學課程使用
hostname -s
來選取主機名稱。 -
啟動及啟用資料庫服務。
sudo systemctl enable --now postgresql
-
匯入資料庫傾印檔。
sudo su - postgres -c 'psql -d postgres -f /tmp/olamv2_db_dump'
-
設定 Oracle Linux Automation Manager 資料庫使用者帳戶密碼。
sudo su - postgres -c "psql -U postgres -d postgres -c \"alter user awx with password 'password';\""
此命令會將
awx
密碼設為password
。若在免費實驗室環境之外執行此命令,請選擇更安全的密碼。 -
請完成設定遠端資料庫的必要步驟,以關閉連線至 db-node 執行處理的 SSH 階段作業。
exit
新增遠端資料庫設定值
-
檢查終端機提示,確認您連線至 olam-node 執行處理。
-
確認主機可以與遠端資料庫通訊。
pg_isready -d awx -h db-node -p 5432 -U awx
postgresql 套裝程式包含
pg_isready
命令。該套裝軟體是原始的單一主機安裝的一部分。如果此命令無法運作,您可能會略過上方的步驟,或網路中遺漏連接埠 5432 的傳入存取。 -
將遠端資料庫設定值新增至新的自訂組態檔。
cat << EOF | sudo tee /etc/tower/conf.d/db.py > /dev/null DATABASES = { 'default': { 'ATOMIC_REQUESTS': True, 'ENGINE': 'awx.main.db.profiled_pg', 'NAME': 'awx', 'USER': 'awx', 'PASSWORD': 'password', 'HOST': 'db-node', 'PORT': '5432', } } EOF
使用先前為
awx
資料庫使用者帳戶設定的相同密碼。 -
停止並停用控制層節點上的本機資料庫。
sudo systemctl stop postgresql sudo systemctl disable postgresql
-
遮罩本機資料庫服務。
sudo systemctl mask postgresql
此步驟可防止在啟動 Oracle Linux Automation Manager 服務時啟動本機資料庫服務。
-
啟動 Oracle Linux Automation Manager。
sudo systemctl start ol-automation-manager
-
驗證 Oracle Linux Automation Manager 連線至遠端資料庫。
sudo su -l awx -s /bin/bash -c "awx-manage check_db"
如果連線成功,輸出會傳回遠端資料庫版本詳細資訊。
移除本機資料庫執行處理
確認遠端資料庫連線運作後,移除原始本機資料庫是安全的。
-
移除資料庫套裝程式。
sudo dnf -y remove postgresql
-
移除包含舊資料庫資料檔的
pgsql
目錄。sudo rm -rf /var/lib/pgsql
變更控制層節點的節點類型
轉換為叢集部署時,請將單一主機執行處理 node_type 從 hybrid
切換為 control
。
-
確認控制平面節點的目前節點類型。
sudo su -l awx -s /bin/bash -c "awx-manage list_instances"
輸出會顯示設為
hybrid
值的node_type
。 -
移除預設的執行處理群組。
sudo su -l awx -s /bin/bash -c "awx-manage remove_from_queue --queuename default --hostname $(hostname -i)"
-
定義新的執行處理與佇列。
sudo su -l awx -s /bin/bash -c "awx-manage provision_instance --hostname=$(hostname -i) --node_type=control" sudo su -l awx -s /bin/bash -c "awx-manage register_queue --queuename=controlplane --hostnames=$(hostname -i)"
-
在自訂設定值檔案中新增預設佇列名稱值。
cat << EOF | sudo tee -a /etc/tower/conf.d/olam.py > /dev/null DEFAULT_EXECUTION_QUEUE_NAME = 'execution' DEFAULT_CONTROL_PLANE_QUEUE_NAME = 'controlplane' EOF
-
更新接收器設定值。
cat << EOF | sudo tee /etc/receptor/receptor.conf > /dev/null --- - node: id: $(hostname -i) - log-level: info - tcp-listener: port: 27199 - control-service: service: control filename: /var/run/receptor/receptor.sock - work-command: worktype: local command: /var/lib/ol-automation-manager/venv/awx/bin/ansible-runner params: worker allowruntimeparams: true verifysignature: false EOF
-
重新啟動 Oracle Linux Automation Manager
sudo systemctl restart ol-automation-manager
已完成將單一主機混合節點轉換成含有遠端資料庫的控制層節點。現在,我們將新增一個執行平面節點,讓此叢集功能完整。
新增執行層節點至叢集
在叢集完全正常運作之前,請新增一或多個執行節點。執行節點會使用可能的執行者執行標準工作,該執行者會在以 OLAM EE Podman 容器為基礎的執行環境中執行手冊。
準備執行層節點
-
透過 ssh 連線至 *exe-node 執行處理。
ssh exe-node
-
安裝 Oracle Linux Automation Manager 儲存區域套裝程式。
sudo dnf -y install oraclelinux-automation-manager-release-el8
-
停用舊版的儲存區域。
sudo dnf config-manager --disable ol8_automation ol8_automation2
-
啟用目前版本的儲存區域。
sudo dnf config-manager --enable ol8_automation2.2
-
安裝 Oracle Linux Automation Manager 套裝程式。
sudo dnf -y install ol-automation-manager
-
新增 Receptor 防火牆規則。
sudo firewall-cmd --add-port=27199/tcp --permanent sudo firewall-cmd --reload
-
編輯 Redis 通訊埠組態。
sudo sed -i '/^# unixsocketperm/a unixsocket /var/run/redis/redis.sock\nunixsocketperm 775' /etc/redis.conf
-
複製控制層節點的秘密金鑰。
ssh oracle@olam-node "sudo cat /etc/tower/SECRET_KEY" | sudo tee /etc/tower/SECRET_KEY > /dev/null
重要事項:每個叢集節點都需要相同的秘密金鑰。
-
建立包含所需設定的自訂設定檔案。
cat << EOF | sudo tee /etc/tower/conf.d/olamv2.py > /dev/null CLUSTER_HOST_ID = '$(hostname -i)' DEFAULT_EXECUTION_QUEUE_NAME = 'execution' DEFAULT_CONTROL_PLANE_QUEUE_NAME = 'controlplane' EOF
CLUSTER_HOST_ID
是叢集內主機的唯一 ID。 -
建立包含遠端資料庫組態的自訂設定值檔案。
cat << EOF | sudo tee /etc/tower/conf.d/db.py > /dev/null DATABASES = { 'default': { 'ATOMIC_REQUESTS': True, 'ENGINE': 'awx.main.db.profiled_pg', 'NAME': 'awx', 'USER': 'awx', 'PASSWORD': 'password', 'HOST': 'db-node', 'PORT': '5432', } } EOF
-
部署可能的執行程式執行環境。
-
以
awx
使用者身分開啟 Shell。sudo su -l awx -s /bin/bash
-
將任何現有容器移轉至最新的 podman 版本,同時維持無權限的命名空間。
podman system migrate
-
提取 Oracle Linux Automation Manager 的 Oracle Linux Automation Engine 執行環境。
podman pull container-registry.oracle.com/oracle_linux_automation_manager/olam-ee:2.2
-
結束
awx
使用者 Shell。exit
-
-
產生 NGINX 的 SSL 憑證。
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/tower/tower.key -out /etc/tower/tower.crt
輸入要求的資訊或直接按下
ENTER
鍵。 -
用以下的設定取代預設的 NGINX 設定 。
cat << 'EOF' | sudo tee /etc/nginx/nginx.conf > /dev/null user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; } EOF
-
更新「接收器」組態檔。
cat << EOF | sudo tee /etc/receptor/receptor.conf > /dev/null --- - node: id: $(hostname -i) - log-level: debug - tcp-listener: port: 27199 - tcp-peer: address: $(ssh olam-node hostname -i):27199 redial: true - control-service: service: control filename: /var/run/receptor/receptor.sock - work-command: worktype: ansible-runner command: /var/lib/ol-automation-manager/venv/awx/bin/ansible-runner params: worker allowruntimeparams: true verifysignature: false EOF
node:id
是目前節點的主機名稱或 IP 位址。tcp-peer:address
是 Receptor 網格的主機名稱或 IP 位址,以及控制層節點上的連接埠。
-
啟動並啟用 Oracle Linux Automation Manager 服務。
sudo systemctl enable --now ol-automation-manager.service
-
關閉連線至 exe-node 執行處理的 SSH 階段作業,因為完成設定執行節點的必要步驟。
exit
佈建執行層節點
-
檢查終端機提示,確認您連線至 olam-node 執行處理。
您必須在叢集的控制層節點上執行佈建步驟,並將其套用至 Oracle Linux Automation Manager 的所有叢集執行處理。
-
定義執行執行處理與佇列。
sudo su -l awx -s /bin/bash -c "awx-manage provision_instance --hostname=$(ssh exe-node hostname -i) --node_type=execution" sudo su -l awx -s /bin/bash -c "awx-manage register_default_execution_environments" sudo su -l awx -s /bin/bash -c "awx-manage register_queue --queuename=execution --hostnames=$(ssh exe-node hostname -i)"
register_queue
會採用queuename
來建立 / 更新工作,以及以逗號分隔的hostnames
清單。
-
註冊服務網狀組織對等關係。
sudo su -l awx -s /bin/bash -c "awx-manage register_peers $(ssh exe-node hostname -i) --peers $(hostname -i)"
驗證執行層節點註冊
-
透過 ssh 連線至 *exe-node 執行處理。
ssh exe-node
-
請檢查 Oracle Linux Automation Manager 網狀組織服務是否在執行中。
sudo systemctl status receptor-awx
-
檢查服務網狀組織的狀態。
sudo receptorctl --socket /var/run/receptor/receptor.sock status
範例輸出:
[oracle@execution-node ~]$ sudo receptorctl --socket /var/run/receptor/receptor.sock status Node ID: 10.0.0.62 Version: +g System CPU Count: 2 System Memory MiB: 15713 Connection Cost 10.0.0.55 1 Known Node Known Connections 10.0.0.55 10.0.0.62: 1 10.0.0.62 10.0.0.55: 1 Route Via 10.0.0.55 10.0.0.55 Node Service Type Last Seen Tags 10.0.0.62 control Stream 2022-11-06 19:46:53 {'type': 'Control Service'} 10.0.0.55 control Stream 2022-11-06 19:46:06 {'type': 'Control Service'} Node Work Types 10.0.0.62 ansible-runner 10.0.0.55 local
如需有關 Receptor 的詳細資訊,請參閱上游文件。
-
檢查執行中的叢集執行處理並顯示可用的容量。
sudo su -l awx -s /bin/bash -c "awx-manage list_instances"
叢集建立所有執行處理間的通訊之後,輸出就會顯示
green
。如果結果顯示為red
,請等待 20-30 秒,然後嘗試重新執行命令。範例輸出:
[oracle@control-node ~]$ sudo su -l awx -s /bin/bash -c "awx-manage list_instances" [controlplane capacity=136] 10.0.0.55 capacity=136 node_type=control version=19.5.1 heartbeat="2022-11-08 16:24:03" [default capacity=0] [execution capacity=136] 10.0.0.62 capacity=136 node_type=execution version=19.5.1 heartbeat="2022-11-08 17:16:45"
完成將 Oracle Linux Automation Manager 移轉至叢集部署。
(選擇性) 驗證叢集是否正常運作
-
重新整理用來顯示上一個 WebUI 的 Web 瀏覽器視窗,或開啟新的 Web 瀏覽器視窗並輸入 URL。
https://localhost:8444
URL 中使用的連接埠必須與 SSH 通道的本機連接埠相同。
注意:根據使用的瀏覽器來核准安全警告。若為 Chrome,請按一下進階按鈕,然後按一下繼續進行 localhost (不安全) 連結。
-
使用 USERNAME
admin
與密碼admin
再次登入 Oracle Linux Automation Manager。 -
登入之後,就會顯示 WebUI。
-
使用左邊的導覽功能表,按一下管理段落下的執行處理群組。
-
在主視窗中,按一下新增按鈕,然後選取新增執行處理群組。
-
請在建立新的執行處理群組頁面中輸入必要的資訊。
-
按一下儲存按鈕。
-
在詳細資訊摘要頁面中,按一下執行處理頁籤。
-
從執行處理頁面中,按一下關聯按鈕。
-
在選取執行處理頁面中,按一下執行節點旁邊的核取方塊。
-
按一下儲存按鈕。
-
使用左側的導覽功能表,按一下資源區段下的存貨。
-
在主視窗中,按一下新增按鈕,然後選取新增產品目錄。
-
請在建立新產品目錄頁面中輸入必要的資訊。
若為執行處理群組,請選取搜尋圖示以顯示選取執行處理群組即現式對話方塊。按一下執行群組旁邊的核取方塊,然後按一下選取按鈕。
-
按一下儲存按鈕。
-
在詳細資訊摘要頁面中,按一下主機頁籤。
-
從主機頁面中,按一下新增按鈕。
-
在建立新主機頁面中,輸入可用執行處理的 IP 位址或主機名稱。
在免費的實驗室環境中,我們將使用 db-node ,這是遠端資料庫執行處理的主機名稱。
-
按一下儲存按鈕。
-
導覽至左側的功能表,然後按一下 ** 證明資料 `。
-
在證明資料頁面上,按一下新增按鈕。
-
請在建立新證明資料頁面輸入必要的資訊。
針對證明資料類型,按一下下拉式功能表,然後選取機器。這會顯示證明資料類型詳細資訊。
輸入
oracle
的使用者名稱,然後瀏覽 SSH 私密金鑰。按一下瀏覽 ... 按鈕會顯示開啟檔案對話方塊視窗。在該對話方塊的主視窗上按一下滑鼠右鍵,然後選取顯示隱藏的檔案。
然後選取
.ssh
資料夾和id_rsa
檔案。按一下開啟按鈕,即可將私密金鑰檔案的內容複製到 SSH 私密金鑰對話方塊中。向下捲動並按一下儲存按鈕。 -
導覽至左側的功能表,然後按一下存貨。
-
在庫存頁面中,按一下測試庫存。
-
在詳細資訊摘要頁面中,按一下主機頁籤。
-
在主機頁面中,按一下
db-node
主機旁邊的核取方塊。然後按一下執行命令 (Run Command) 按鈕。
-
從執行命令對話方塊中,從模組值清單選取
ping
模組,然後按一下下一步按鈕。 -
選取 OLAM EE (2.2) 執行環境,然後按一下下一步按鈕。
-
選取 db-node 機器證明資料,然後按一下下一步 (Next) 按鈕。
-
面板會重新整理並顯示指令的預覽。
複查詳細資訊之後,請按一下啟動按鈕。
-
工作將會啟動並顯示工作輸出頁面。
如果順利執行所有項目,輸出會顯示
SUCCESS
訊息,讓執行節點使用 Ansibleping
模組聯絡db-node
執行處理。如果您沒有看到輸出,請按一下詳細資訊頁籤,然後返回輸出頁籤來重新整理頁面。
接下來的步驟
WebUI 中的輸出會確認您有適用於 Oracle Linux Automation Manager 的工作叢集環境。繼續培養您的技能,並瞭解我們在 Oracle Linux Training Station 上的其他 Oracle Linux Automation Manager 訓練。
相關連結
Oracle Linux Automation Manager 文件
Oracle Linux Automation Manager 訓練
Oracle Linux 訓練站
其他學習資源
探索 docs.oracle.com/learn 上的其他實驗室,或存取 Oracle Learning YouTube 頻道上的更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Migrate Oracle Linux Automation Manager to a Clustered Deployment
F74668-02
Copyright ©2022, Oracle and/or its affiliates.