TR-4987:使用 NFS 在Azure NetApp Files上簡化、自動化 Oracle 部署
Allen Cao、Niyaz Mohamed, NetApp
該解決方案提供了在 Microsoft Azure NetApp Files中自動部署 Oracle 的概述和詳細信息,該部署作為具有 NFS 協議的主資料庫存儲,並且 Oracle 資料庫部署為啟用 dNFS 的容器資料庫。
目的
在雲端中運行效能密集且延遲敏感的 Oracle 工作負載可能具有挑戰性。 Azure NetApp Files (ANF) 讓企業業務線 (LOB) 和儲存專業人員可以輕鬆遷移和執行要求嚴苛的 Oracle 工作負載,而無需更改程式碼。 Azure NetApp Files被廣泛用作各種場景中的底層共用檔案儲存服務,例如 Oracle 資料庫的新部署或從本機到 Azure 的遷移(提升和轉移)。
本文檔示範了使用 Ansible 自動化透過 NFS 掛載在 Azure NetApp檔案中簡化 Oracle 資料庫的部署。 Oracle 資料庫部署在容器資料庫 (CDB) 和可插拔資料庫 (PDB) 配置中,並啟用 Oracle dNFS 協定以提高效能。此外,可以使用自動化 PDB 遷移方法將本機 Oracle 單一執行個體資料庫或 PDB 遷移到 Azure 中新部署的容器資料庫中,同時最大程度地減少服務中斷。它還提供有關使用 Azure Cloud 中的NetApp SnapCenter UI 工具快速備份、還原和克隆 Oracle 資料庫的資訊。
此解決方案適用於以下用例:
-
Azure NetApp檔案上的自動 Oracle 容器資料庫部署
-
本地端和 Azure 雲端之間的自動 Oracle 資料庫遷移
對象
此解決方案適用於以下人群:
-
想要在Azure NetApp Files上部署 Oracle 的 DBA。
-
想要在Azure NetApp Files上測試 Oracle 工作負載的資料庫解決方案架構師。
-
想要在Azure NetApp Files上部署和管理 Oracle 資料庫的儲存管理員。
-
希望在Azure NetApp Files上建立 Oracle 資料庫的應用程式擁有者。
解決方案測試和驗證環境
此解決方案的測試和驗證是在實驗室環境中進行的,可能與最終部署環境不符。請參閱部署考慮的關鍵因素了解更多。
架構
硬體和軟體組件
硬體 |
||
Azure NetApp Files |
Microsoft 目前在 Azure 中提供的產品 |
一個具有高級服務等級的容量池 |
用於資料庫伺服器的 Azure VM |
Standard_B4ms - 4 個 vCPU,16GiB |
兩個 Linux 虛擬機器實例用於並發部署 |
用於SnapCenter的 Azure VM |
Standard_B4ms - 4 個 vCPU,16GiB |
一個 Windows 虛擬機器實例 |
軟體 |
||
紅帽Linux |
RHEL Linux 8.6(LVM)-x64 Gen2 |
部署 RedHat 訂閱進行測試 |
Windows 伺服器 |
2022 資料中心;Azure 版本熱補丁 - x64 Gen2 |
託管SnapCenter伺服器 |
Oracle 資料庫 |
版本 19.18 |
已套用RU補丁p34765931_190000_Linux-x86-64.zip |
Oracle OPatch |
版本 12.2.0.1.36 |
最新補丁 p6880880_190000_Linux-x86-64.zip |
SnapCenter伺服器 |
版本 5.0 |
工作小組部署 |
開啟 JDK |
版本 java-11-openjdk |
資料庫虛擬機器上的SnapCenter插件要求 |
NFS |
版本 3.0 |
已啟用 Oracle dNFS |
Ansible |
核心 2.16.2 |
Python 3.6.8 |
實驗室環境中的 Oracle 資料庫配置
伺服器 |
資料庫 |
資料庫儲存 |
ora-01 |
NTAP1(NTAP1_PDB1、NTAP1_PDB2、NTAP1_PDB3) |
/u01、/u02、/u03 在 ANF 容量池上掛載 NFS |
ora-02 |
NTAP2(NTAP2_PDB1、NTAP2_PDB2、NTAP2_PDB3) |
/u01、/u02、/u03 在 ANF 容量池上掛載 NFS |
部署考慮的關鍵因素
-
Oracle 資料庫儲存佈局。在此自動化 Oracle 部署中,我們預設為每個資料庫配置三個資料庫磁碟區來託管 Oracle 二進位檔案、資料和日誌。這些磁碟區透過 NFS 安裝在 Oracle DB 伺服器上,作為 /u01 - 二進位、/u02 - 資料、/u03 - 日誌。在 /u02 和 /u03 掛載點上配置雙控製檔以實現冗餘。
-
*多個資料庫伺服器部署。 *自動化解決方案可以在單一 Ansible 劇本運行中將 Oracle 容器資料庫部署到多個 DB 伺服器。無論資料庫伺服器的數量有多少,劇本的執行都保持不變。您可以透過使用不同的資料庫執行個體 ID(Oracle SID)重複部署將多個容器資料庫部署到單一 VM 執行個體。但要確保主機上有足夠的記憶體來支援部署的資料庫。
-
*dNFS 配置。 *透過使用 dNFS(自 Oracle 11g 起可用),在 Azure 虛擬機器上執行的 Oracle 資料庫可以比本機 NFS 用戶端驅動更多的 I/O。自動化 Oracle 部署預設在 NFSv3 上配置 dNFS。
-
*分配大尺寸卷以加快部署速度。 * ANF 檔案系統 IO 吞吐量根據磁碟區的大小進行調整。對於初始部署,分配大尺寸磁碟區可以加快部署速度。隨後可以動態縮小磁碟區的大小,而不會對應用程式產生影響。
-
*資料庫備份。 * NetApp提供了SnapCenter software套件,用於資料庫備份、復原和克隆,並具有使用者友好的 UI 介面。 NetApp建議實施這樣的管理工具,以實現快速(一分鐘內)快照備份、快速(幾分鐘內)資料庫復原和資料庫複製。
解決方案部署
以下部分提供了在Azure NetApp Files上自動部署 Oracle 19c 和資料庫遷移的逐步過程,其中資料庫磁碟區透過 NFS 直接裝載到 Azure VM。
部署先決條件
Details
部署需要以下先決條件。
-
已設定 Azure 帳戶,並在您的 Azure 帳戶內建立了必要的 VNet 和網路區段。
-
從 Azure 雲端門戶,將 Azure Linux VM 部署為 Oracle DB 伺服器。為 Oracle 資料庫建立Azure NetApp Files容量池和資料庫磁碟區。為 azureuser 到 DB 伺服器啟用 VM SSH 私鑰/公鑰身份驗證。有關環境設定的詳細信息,請參閱上一節中的架構圖。也提到"Azure VM 和Azure NetApp Files上的逐步 Oracle 部署流程"了解詳細資訊。
對於使用本機磁碟冗餘部署的 Azure VM,請確保在 VM 根磁碟中指派至少 128G,以便有足夠的空間來暫存 Oracle 安裝檔案並新增 OS 交換檔。相應地擴展 /tmplv 和 /rootlv OS 分區。如果rootvg-homelv的可用空間小於1G,則新增1G的可用空間。確保資料庫磁碟區命名遵循 VMname-u01、VMname-u02 和 VMname-u03 約定。 sudo lvresize -r -L +20G /dev/mapper/rootvg-rootlv
sudo lvresize -r -L +10G /dev/mapper/rootvg-tmplv
sudo lvresize -r -L +1G /dev/mapper/rootvg-homelv
-
從 Azure 雲端入口網站設定 Windows 伺服器以執行最新版本的NetApp SnapCenter UI 工具。詳細資訊請參考以下連結:"安裝SnapCenter伺服器"
-
將 Linux VM 配置為 Ansible 控制器節點,並安裝最新版本的 Ansible 和 Git。詳細資訊請參考以下連結:"NetApp解決方案自動化入門"在第 -
Setup the Ansible Control Node for CLI deployments on RHEL / CentOS`或者
。
`Setup the Ansible Control Node for CLI deployments on Ubuntu / DebianAnsible 控制器節點可以位於本機或 Azure 雲端中,只要它可以透過 ssh 連接埠存取 Azure DB VM。 -
克隆適用於 NFS 的NetApp Oracle 部署自動化工具包的副本。
git clone https://bitbucket.ngage.netapp.com/scm/ns-bb/na_oracle_deploy_nfs.git
-
在 Azure DB VM /tmp/archive 目錄上以 777 權限執行下列 Oracle 19c 安裝檔案階段。
installer_archives: - "LINUX.X64_193000_db_home.zip" - "p34765931_190000_Linux-x86-64.zip" - "p6880880_190000_Linux-x86-64.zip"
-
觀看以下影片:
使用 NFS 在Azure NetApp Files上簡化和自動化 Oracle 部署
自動化參數文件
Details
Ansible playbook 使用預先定義參數執行資料庫安裝和設定任務。對於此 Oracle 自動化解決方案,有三個使用者定義的參數檔案需要在劇本執行之前使用者輸入。
-
主機 - 定義自動化劇本運作的目標。
-
vars/vars.yml - 定義適用於所有目標的變數的全域變數檔案。
-
host_vars/host_name.yml - 定義僅適用於命名目標的變數的本機變數檔案。在我們的用例中,這些是 Oracle DB 伺服器。
除了這些使用者定義的變數文件之外,還有幾個預設變數文件,其中包含預設參數,除非必要,否則不需要更改。以下部分介紹如何設定使用者定義的變數檔。
參數檔案配置
Details
-
Ansible 目標 `hosts`文件配置:
# Enter Oracle servers names to be deployed one by one, follow by each Oracle server public IP address, and ssh private key of admin user for the server. [oracle] ora_01 ansible_host=10.61.180.21 ansible_ssh_private_key_file=ora_01.pem ora_02 ansible_host=10.61.180.23 ansible_ssh_private_key_file=ora_02.pem
-
全球的 `vars/vars.yml`文件配置
###################################################################### ###### Oracle 19c deployment user configuration variables ###### ###### Consolidate all variables from ONTAP, linux and oracle ###### ###################################################################### ########################################### ### ONTAP env specific config variables ### ########################################### # Prerequisite to create three volumes in NetApp ONTAP storage from System Manager or cloud dashboard with following naming convention: # db_hostname_u01 - Oracle binary # db_hostname_u02 - Oracle data # db_hostname_u03 - Oracle redo # It is important to strictly follow the name convention or the automation will fail. ########################################### ### Linux env specific config variables ### ########################################### redhat_sub_username: XXXXXXXX redhat_sub_password: XXXXXXXX #################################################### ### DB env specific install and config variables ### #################################################### # Database domain name db_domain: solutions.netapp.com # Set initial password for all required Oracle passwords. Change them after installation. initial_pwd_all: XXXXXXXX
-
本地資料庫伺服器 `host_vars/host_name.yml`配置如ora_01.yml,ora_02.yml…
# User configurable Oracle host specific parameters # Enter container database SID. By default, a container DB is created with 3 PDBs within the CDB oracle_sid: NTAP1 # Enter database shared memory size or SGA. CDB is created with SGA at 75% of memory_limit, MB. The grand total of SGA should not exceed 75% available RAM on node. memory_limit: 8192 # Local NFS lif ip address to access database volumes nfs_lif: 172.30.136.68
劇本執行
Details
自動化工具包中共有五個劇本。每個執行不同的任務區塊並服務於不同的目的。
0-all_playbook.yml - execute playbooks from 1-4 in one playbook run. 1-ansible_requirements.yml - set up Ansible controller with required libs and collections. 2-linux_config.yml - execute Linux kernel configuration on Oracle DB servers. 4-oracle_config.yml - install and configure Oracle on DB servers and create a container database. 5-destroy.yml - optional to undo the environment to dismantle all.
有三個選項可以使用以下命令運行劇本。
-
在一次組合運行中執行所有部署劇本。
ansible-playbook -i hosts 0-all_playbook.yml -u azureuser -e @vars/vars.yml
-
依照 1-4 的數字序列逐一執行劇本。
ansible-playbook -i hosts 1-ansible_requirements.yml -u azureuser -e @vars/vars.yml
ansible-playbook -i hosts 2-linux_config.yml -u azureuser -e @vars/vars.yml
ansible-playbook -i hosts 4-oracle_config.yml -u azureuser -e @vars/vars.yml
-
使用標籤執行 0-all_playbook.yml。
ansible-playbook -i hosts 0-all_playbook.yml -u azureuser -e @vars/vars.yml -t ansible_requirements
ansible-playbook -i hosts 0-all_playbook.yml -u azureuser -e @vars/vars.yml -t linux_config
ansible-playbook -i hosts 0-all_playbook.yml -u azureuser -e @vars/vars.yml -t oracle_config
-
撤銷環境
ansible-playbook -i hosts 5-destroy.yml -u azureuser -e @vars/vars.yml
執行後驗證
Details
劇本運行後,登入 Oracle DB 伺服器 VM 以驗證 Oracle 是否已安裝和配置,以及是否已成功建立容器資料庫。以下是主機 ora-01 上的 Oracle 資料庫驗證的範例。
-
驗證 NFS 掛載
[azureuser@ora-01 ~]$ cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Sep 14 11:04:01 2023 # # Accessible filesystems, by reference, are maintained under '/dev/disk/'. # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. # # After editing this file, run 'systemctl daemon-reload' to update systemd # units generated from this file. # /dev/mapper/rootvg-rootlv / xfs defaults 0 0 UUID=268633bd-f9bb-446d-9a1d-8fca4609a1e1 /boot xfs defaults 0 0 UUID=89D8-B037 /boot/efi vfat defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2 /dev/mapper/rootvg-homelv /home xfs defaults 0 0 /dev/mapper/rootvg-tmplv /tmp xfs defaults 0 0 /dev/mapper/rootvg-usrlv /usr xfs defaults 0 0 /dev/mapper/rootvg-varlv /var xfs defaults 0 0 /mnt/swapfile swap swap defaults 0 0 172.30.136.68:/ora-01-u01 /u01 nfs rw,bg,hard,vers=3,proto=tcp,timeo=600,rsize=65536,wsize=65536 0 0 172.30.136.68:/ora-01-u02 /u02 nfs rw,bg,hard,vers=3,proto=tcp,timeo=600,rsize=65536,wsize=65536 0 0 172.30.136.68:/ora-01-u03 /u03 nfs rw,bg,hard,vers=3,proto=tcp,timeo=600,rsize=65536,wsize=65536 0 0 [azureuser@ora-01 ~]$ df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.7G 0 7.7G 0% /dev tmpfs 7.8G 0 7.8G 0% /dev/shm tmpfs 7.8G 8.6M 7.7G 1% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/mapper/rootvg-rootlv 22G 17G 5.8G 74% / /dev/mapper/rootvg-usrlv 10G 2.0G 8.1G 20% /usr /dev/mapper/rootvg-varlv 8.0G 890M 7.2G 11% /var /dev/sda1 496M 106M 390M 22% /boot /dev/mapper/rootvg-homelv 1014M 40M 975M 4% /home /dev/sda15 495M 5.9M 489M 2% /boot/efi /dev/mapper/rootvg-tmplv 12G 8.4G 3.7G 70% /tmp tmpfs 1.6G 0 1.6G 0% /run/user/54321 172.30.136.68:/ora-01-u01 500G 11G 490G 3% /u01 172.30.136.68:/ora-01-u03 250G 1.2G 249G 1% /u03 172.30.136.68:/ora-01-u02 250G 7.1G 243G 3% /u02 tmpfs 1.6G 0 1.6G 0% /run/user/1000
-
驗證 Oracle 偵聽器
[azureuser@ora-01 ~]$ sudo su [root@ora-01 azureuser]# su - oracle Last login: Thu Feb 1 16:13:44 UTC 2024 [oracle@ora-01 ~]$ lsnrctl status listener.ntap1 LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 01-FEB-2024 16:25:37 Copyright (c) 1991, 2022, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora-01.internal.cloudapp.net)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER.NTAP1 Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production Start Date 01-FEB-2024 16:13:49 Uptime 0 days 0 hr. 11 min. 49 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/19.0.0/NTAP1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/ora-01/listener.ntap1/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora-01.hr2z2nbmhnqutdsxgscjtuxizd.jx.internal.cloudapp.net)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=ora-01.hr2z2nbmhnqutdsxgscjtuxizd.jx.internal.cloudapp.net)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/19.0.0/NTAP1/admin/NTAP1/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "104409ac02da6352e063bb891eacf34a.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "104412c14c2c63cae063bb891eacf64d.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "1044174670ad63ffe063bb891eac6b34.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "NTAP1.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "NTAP1XDB.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "ntap1_pdb1.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "ntap1_pdb2.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... Service "ntap1_pdb3.solutions.netapp.com" has 1 instance(s). Instance "NTAP1", status READY, has 1 handler(s) for this service... The command completed successfully
-
驗證 Oracle 資料庫和 dNFS
[oracle@ora-01 ~]$ cat /etc/oratab # # This file is used by ORACLE utilities. It is created by root.sh # and updated by either Database Configuration Assistant while creating # a database or ASM Configuration Assistant while creating ASM instance. # A colon, ':', is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, '#', are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third field indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # NTAP1:/u01/app/oracle/product/19.0.0/NTAP1:Y [oracle@ora-01 ~]$ sqlplus / as sysdba SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 1 16:37:51 2024 Version 19.18.0.0.0 Copyright (c) 1982, 2022, Oracle. All rights reserved. Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.18.0.0.0 SQL> select name, open_mode, log_mode from v$database; NAME OPEN_MODE LOG_MODE --------- -------------------- ------------ NTAP1 READ WRITE ARCHIVELOG SQL> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 NTAP1_PDB1 READ WRITE NO 4 NTAP1_PDB2 READ WRITE NO 5 NTAP1_PDB3 READ WRITE NO SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- /u02/oradata/NTAP1/system01.dbf /u02/oradata/NTAP1/sysaux01.dbf /u02/oradata/NTAP1/undotbs01.dbf /u02/oradata/NTAP1/pdbseed/system01.dbf /u02/oradata/NTAP1/pdbseed/sysaux01.dbf /u02/oradata/NTAP1/users01.dbf /u02/oradata/NTAP1/pdbseed/undotbs01.dbf /u02/oradata/NTAP1/NTAP1_pdb1/system01.dbf /u02/oradata/NTAP1/NTAP1_pdb1/sysaux01.dbf /u02/oradata/NTAP1/NTAP1_pdb1/undotbs01.dbf /u02/oradata/NTAP1/NTAP1_pdb1/users01.dbf NAME -------------------------------------------------------------------------------- /u02/oradata/NTAP1/NTAP1_pdb2/system01.dbf /u02/oradata/NTAP1/NTAP1_pdb2/sysaux01.dbf /u02/oradata/NTAP1/NTAP1_pdb2/undotbs01.dbf /u02/oradata/NTAP1/NTAP1_pdb2/users01.dbf /u02/oradata/NTAP1/NTAP1_pdb3/system01.dbf /u02/oradata/NTAP1/NTAP1_pdb3/sysaux01.dbf /u02/oradata/NTAP1/NTAP1_pdb3/undotbs01.dbf /u02/oradata/NTAP1/NTAP1_pdb3/users01.dbf 19 rows selected. SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------------- /u02/oradata/NTAP1/control01.ctl /u03/orareco/NTAP1/control02.ctl SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u03/orareco/NTAP1/onlinelog/redo03.log /u03/orareco/NTAP1/onlinelog/redo02.log /u03/orareco/NTAP1/onlinelog/redo01.log SQL> select svrname, dirname, nfsversion from v$dnfs_servers; SVRNAME -------------------------------------------------------------------------------- DIRNAME -------------------------------------------------------------------------------- NFSVERSION ---------------- 172.30.136.68 /ora-01-u02 NFSv3.0 172.30.136.68 /ora-01-u03 NFSv3.0 SVRNAME -------------------------------------------------------------------------------- DIRNAME -------------------------------------------------------------------------------- NFSVERSION ---------------- 172.30.136.68 /ora-01-u01 NFSv3.0
-
登入 Oracle Enterprise Manager Express 來驗證資料庫。
將 Oracle 資料庫遷移到 AzureMigrate Oracle database to Azure
Details
Oracle 資料庫從本機遷移到雲端是一項繁重的工作。使用正確的策略和自動化可以使流程更加順暢,並最大限度地減少服務中斷和停機時間。按照這個詳細的說明操作"資料庫從本地遷移到 Azure 雲端"指導您的資料庫遷移之旅。
使用SnapCenter進行 Oracle 備份、復原和克隆
Details
NetApp建議使用SnapCenter UI 工具來管理部署在 Azure 雲端的 Oracle 資料庫。請參考TR-4988:"使用SnapCenter在 ANF 上進行 Oracle 資料庫備份、復原和克隆"了解詳情。
在哪裡可以找到更多信息
要了解有關本文檔中描述的信息的更多信息,請查看以下文檔和/或網站:
-
使用SnapCenter在 ANF 上進行 Oracle 資料庫備份、復原和克隆
-
Azure NetApp Files
-
部署 Oracle Direct NFS
-
使用回應檔案安裝和配置 Oracle 資料庫