附註:
- 此教學課程可在 Oracle 提供的免費實驗室環境中取得。
- 它使用 Oracle Cloud Infrastructure 證明資料、租用戶及區間的範例值。完成實驗室時,請將這些值取代為您雲端環境特定的值。
在 Oracle Linux 上安裝 Oracle Linux Automation Manager
簡介
Oracle Linux Automation Manager 是任務引擎和 Web 型圖形使用者介面 (GUI),用於排程和執行遠端主機產品目錄的 Oracle Linux Automation Engine 手冊。此工具套件可讓管理員輕鬆管理其 IT 基礎架構,並以已知且可預測的方式完成重複性工作,避免常見的手動管理問題。
Oracle Linux Automation Engine 是使用程式碼型基礎架構作為程式碼 (IaC) YAML 定義檔 (稱為手冊) 來管理及執行管理工作的工具。這些手冊包括教學工作,例如部署軟體、設定系統,以及協調升級和更新。
目標
在本教學課程中,您將瞭解如何:
- 啟用 Oracle Linux DNF 儲存區域
- 設定防火牆規則
- 下載、安裝並設定單一主機 Oracle Linux Automation Manager
必要條件
- 已安裝 Oracle Linux 的系統。
部署 Oracle Linux
注意:如果在您自己的租用戶中執行,請先閱讀 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" olam_type: none EOF
-
建立產品目錄檔案。
cat << EOF | tee hosts > /dev/null localhost ansible_connection=local ansible_connection=local ansible_python_interpreter=/usr/bin/python3.6 EOF
-
部署實驗室環境。
ansible-playbook create_instance.yml -i hosts -e "@instances.yml"
免費實驗室環境需要額外的 localhost
ansible_python_interpreter
變數,因為它會為 Python 適用的 Oracle Cloud Infrastructure SDK 安裝 RPM 套件。安裝此套裝軟體的位置位於以您 Oracle Linux 版本為基礎的系統預設 Python 模組底下。使用產品目錄變數可避免影響 localhost 以外的主機上執行的播放。預設部署資源配置使用 AMD CPU。您可以在命令行中傳送新的資源配置變數定義,以變更執行處理的資源配置。
例如:
-e instance_shape="VM.Standard3.Flex"
同樣地,Oracle Linux 映像檔的預設版本會使用 `default_vars.yml 檔案中定義的變數
os_version
。您可以在命令行中傳送 Oracle Linux 主要版本,即可修改這個值。例如:
-e os_version="9"
重要事項: 請等待播放手冊順利執行,然後到達暫停工作。在手冊的這個階段,Oracle Linux 的安裝已完成,實例已就緒。請注意,上一個播放會列印其部署節點的公用和專用 IP 位址。
啟用 Oracle Linux DNF 儲存區域並設定防火牆規則
請先啟用必要的 yum 儲存區域和防火牆規則,再安裝 Oracle Linux Automation Manager。
-
開啟終端機,然後透過 ssh 連線至 olam 節點。
ssh oracle@<ip_address_of_instance>
-
安裝 Oracle Linux Automation Manager 儲存區域。
Oracle Linux 8:
sudo dnf -y install oraclelinux-automation-manager-release-el8
Oracle Linux 9:
sudo dnf -y install oraclelinux-automation-manager-release-el9
此命令會啟用最新的 Oracle Linux Automation Manager 儲存區域,作為安裝產品套裝程式的預設值。
-
將 HTTP/HTTPS 服務新增至防火牆規則。
sudo firewall-cmd --add-service=https --permanent sudo firewall-cmd --reload
安裝本機 PostgreSQL 資料庫
-
啟用模組串流。
sudo dnf module reset postgresql sudo dnf -y module enable postgresql:16
-
安裝資料庫。
sudo dnf -y install postgresql-server
-
起始資料庫。
sudo postgresql-setup --initdb
-
將密碼儲存機制切換至 scram-sha-256 。
sudo sed -i "s/#password_encryption.*/password_encryption = scram-sha-256/" /var/lib/pgsql/data/postgresql.conf
-
啟用並啟動資料庫。
sudo systemctl enable --now postgresql
-
建立資料庫使用者帳戶。
重要事項:對於這個免費的實驗室環境,請在提示時使用
password
密碼。此密碼不安全,我們只會在此環境中使用該密碼作為示範用途。sudo su - postgres -c "createuser -S -P awx"
-
建立資料庫。
sudo su - postgres -c "createdb -O awx awx"
-
更新主機式認證檔案。
echo "host all all 0.0.0.0/0 scram-sha-256" | sudo tee -a /var/lib/pgsql/data/pg_hba.conf > /dev/null
-
更新資料庫監聽器的 IP 位址。
sudo sed -i "/^#port = 5432/i listen_addresses = '"$(hostname -i)"'" /var/lib/pgsql/data/postgresql.conf
-
更新資料庫記憶體需求。
這些計算會利用系統的總記憶體 (MB),並取代 PostgreSQL 組態檔中的預設值。
export TOTAL_MEMORY="$(free --mega | awk 'FNR == 2 {print $2}')" sudo sed -i 's/max_connections = 100/max_connections = 1024/g' /var/lib/pgsql/data/postgresql.conf sudo sed -i "/^shared_buffers =/c\shared_buffers = $( echo "($TOTAL_MEMORY*0.3)/1" | bc )" /var/lib/pgsql/data/postgresql.conf sudo sed -i "/^#work_mem =/c\work_mem = $( echo "($TOTAL_MEMORY*0.03)/1" | bc )" /var/lib/pgsql/data/postgresql.conf sudo sed -i "/^#maintenance_work_mem =/c\maintenance_work_mem = $( echo "($TOTAL_MEMORY*0.04)/1" | bc )MB" /var/lib/pgsql/data/postgresql.conf
-
重新啟動資料庫。
sudo systemctl restart postgresql
安裝並設定 Oracle Linux Automation Manager
-
安裝 Oracle Linux Automation Manager 套裝程式與任何相依性。
sudo dnf -y install ol-automation-manager
-
更新 Redis 組態檔。
Oracle Linux 8:
sudo sed -i '/^# unixsocketperm/a unixsocket /var/run/redis/redis.sock\nunixsocketperm 775' /etc/redis.conf
Oracle Linux 9:
sudo sed -i '/^# unixsocketperm/a unixsocket /var/run/redis/redis.sock\nunixsocketperm 775' /etc/redis/redis.conf
-
新增 CLUSTER_HOST_ID 至自訂的設定檔案。
cat << EOF | sudo tee -a /etc/tower/conf.d/olam.py > /dev/null CLUSTER_HOST_ID = '$(hostname -i)' EOF
注意:對於啟用 IPv6 的系統而言,使用
$(hostname -i)
無法運作,因為輸出中有空格。請改用系統的主機名稱,使用$(hostname -f)
或部分其他不含空格的字串。 -
更新自訂設定值檔案的權限。
sudo chown awx.awx /etc/tower/conf.d/olam.py sudo chmod 0640 /etc/tower/conf.d/olam.py
-
新增資料庫設定到自訂設定檔 。
cat << EOF | sudo tee -a /etc/tower/conf.d/olam.py > /dev/null DATABASES = { 'default': { 'ATOMIC_REQUESTS': True, 'ENGINE': 'awx.main.db.profiled_pg', 'NAME': 'awx', 'USER': 'awx', 'PASSWORD': 'password', 'HOST': '$(hostname -i)', 'PORT': '5432', } } EOF
-
啟用語言控制。
Oracle Linux 9:
sudo loginctl enable-linger awx
這會在無週邊系統上執行時解決此訊息:
WARN[0000] cgroupv2 管理程式設為 systemd,但是沒有可用的 systemd 使用者階段作業 WARN[0000] 若要使用 systemd,您可能需要使用使用者階段作業 WARN[0000] 登入。或者,您可以啟用 lingering with:
loginctl enable-linger 986
(可能為 root) WARN[0000] Falling Back to – cgroup-manager=cgroupfs
警告 [0000] cgroupv2 管理程式已設為 systemd,但沒有可用的 systemd 使用者階段作業 WARN[0000] 若要使用 systemd,您可能需要使用使用者階段作業 WARN[0000] 登入。或者,您也可以使用下列方法啟用 lingering:loginctl enable-linger 986
(可能為 root) WARN[0000] 轉至 – cgroup-manager=cgroupfs -
拉引 Oracle Linux Automation Manager 容器映像檔。
Oracle Linux 8:
sudo su -l awx -s /bin/bash
podman system migrate
podman pull container-registry.oracle.com/oracle_linux_automation_manager/olam-ee:2.3-ol8
Oracle Linux 9:
sudo su -l awx -s /bin/bash
podman system migrate
podman pull container-registry.oracle.com/oracle_linux_automation_manager/olam-ee:2.3-ol9
-
建立 Oracle Linux Automation Manager 綱要和管理員使用者帳戶。
awx-manage migrate awx-manage createsuperuser --username admin --email admin@example.com
注意:在前一個範例中,
admin@example.com
是管理員使用者的電子郵件地址範例。 -
輸入並確認管理員使用者的密碼。
-
結束 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 - 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
-
佈建執行處理並註冊執行環境。
sudo su -l awx -s /bin/bash
awx-manage provision_instance --hostname=$(hostname -i) --node_type=hybrid
awx-manage register_default_execution_environments
awx-manage register_queue --queuename=default --hostnames=$(hostname -i)
awx-manage register_queue --queuename=controlplane --hostnames=$(hostname -i)
awx-manage create_preload_data
exit
-
啟動服務。
sudo systemctl enable --now ol-automation-manager.service
-
從伺服器中斷連線。
exit
驗證安裝
-
使用相同的終端機視窗設定 SSH 通道。
ssh -L 8444:localhost:443 oracle@<ip_address_of_instance>
注意:在先前的範例中,
<ip_address_of_instance>
是執行 Oracle Linux Automation Manager 之系統的主機名稱或 IP 位址。如果使用主機名稱,則主機必須可解析。 -
開啟 Web 瀏覽器並輸入 URL。
https://localhost:8444
注意:根據使用的瀏覽器來核准安全警告。若為 Chrome,請按一下
Advanced
按鈕,然後按一下Proceed to localhost (unsafe)
連結。 -
使用 USERNAME
admin
與設定期間建立的密碼登入 Oracle Linux Automation Manager。
接下來的步驟
安裝 Oracle Linux Automation Manager 後,您可以開始探索 Web 使用者介面和各種產品功能,協助自動化基礎架構。查看我們在 Oracle Linux 訓練站的其他訓練,以擴展您的知識並獲得想法。
相關連結
其他學習資源
探索 docs.oracle.com/learn 上的其他實驗室,或存取 Oracle Learning YouTube 頻道上的更多免費學習內容。此外,請造訪 education.oracle.com/learning-explorer 以成為 Oracle Learning Explorer。
如需產品文件,請造訪 Oracle Help Center 。
Install Oracle Linux Automation Manager on Oracle Linux
F52956-05
Copyright ©2021, Oracle and/or its affiliates.