oracle 19c dataguard silent install (oracle 19c dataguard 靜默安裝)

翰墨文海發表於2020-12-26

 環境說明

 

1.關閉透明大頁

   RHEL  6:

# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

[oracle@rhel 6 ~]$ cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
[always] madvise never

 

  RHEL  7:

# cat /sys/kernel/mm/transparent_hugepage/enabled

[root@rhel 7 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

 

2.禁用透明大頁

RHEL 6:

(1).編輯 /etc/grub.conf 檔案,在kernel 那一行後面追加 transparent_hugepage=never

例如:

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux 6 (2.6.32-642.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/rootvg-lvroot rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_LVM_LV=rootvg/lvswap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=rootvg/lvroot rd_NO_DM rhgb quiet transparent_hugepage=never
initrd /initramfs-2.6.32-642.el6.x86_64.img

(2).重啟系統生效。


RHEL 7:
(1).編輯/etc/sysconfig/grub 檔案,在 GRUB_CMDLINE_LINUX 那一行後面追加 transparent_hugepage=never

例如:

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"

(2).再使用 grub2-mkconfig 生成grub.cfg配置檔案。
# grub2-mkconfig -o /boot/grub2/grub.cfg

(3).重啟系統使配置生效。
grep Huge /proc/meminfo

2.HugePages 啟用大頁(oracle安裝完成啟動好後設定)

檢視是否啟用

$cat /proc/sys/vm/nr_hugepages

$ grep -i HugePages_Total /proc/meminfo

HugePages_Total:     0

HugePages_Total為0,說明hugepage沒有使用。 nr_hugepages為0,意味著沒有設定。

計算合適的大頁數量:

hugepages_settings.sh

#!/bin/bash
#
# hugepages_settings.sh
#
# Linux bash script to compute values for the
# recommended HugePages/HugeTLB configuration
# on Oracle Linux
#
# Note: This script does calculation for all shared memory
# segments available when the script is run, no matter it
# is an Oracle RDBMS shared memory segment or not.
#
# This script is provided by Doc ID 401749.1 from My Oracle Support
# http://support.oracle.com

# Welcome text
echo "
This script is provided by Doc ID 401749.1 from My Oracle Support
(http://support.oracle.com) where it is intended to compute values for
the recommended HugePages/HugeTLB configuration for the current shared
memory segments on Oracle Linux. Before proceeding with the execution please note following:
 * For ASM instance, it needs to configure ASMM instead of AMM.
 * The 'pga_aggregate_target' is outside the SGA and
   you should accommodate this while calculating the overall size.
 * In case you changes the DB SGA size,
   as the new SGA will not fit in the previous HugePages configuration,
   it had better disable the whole HugePages,
   start the DB with new SGA size and run the script again.
And make sure that:
 * Oracle Database instance(s) are up and running
 * Oracle Database 11g Automatic Memory Management (AMM) is not setup
   (See Doc ID 749851.1)
 * The shared memory segments can be listed by command:
     # ipcs -m


Press Enter to proceed..."

read

# Check for the kernel version
KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`

# Find out the HugePage size
HPG_SZ=`grep Hugepagesize /proc/meminfo | awk '{print $2}'`
if [ -z "$HPG_SZ" ];then
    echo "The hugepages may not be supported in the system where the script is being executed."
    exit 1
fi

# Initialize the counter
NUM_PG=0

# Cumulative number of pages required to handle the running shared memory segments
for SEG_BYTES in `ipcs -m | cut -c44-300 | awk '{print $1}' | grep "[0-9][0-9]*"`
do
    MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
    if [ $MIN_PG -gt 0 ]; then
        NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
    fi
done

RES_BYTES=`echo "$NUM_PG * $HPG_SZ * 1024" | bc -q`

# An SGA less than 100MB does not make sense
# Bail out if that is the case
if [ $RES_BYTES -lt 100000000 ]; then
    echo "***********"
    echo "** ERROR **"
    echo "***********"
    echo "Sorry! There are not enough total of shared memory segments allocated for
HugePages configuration. HugePages can only be used for shared memory segments
that you can list by command:

    # ipcs -m

of a size that can match an Oracle Database SGA. Please make sure that:
 * Oracle Database instance is up and running
 * Oracle Database 11g Automatic Memory Management (AMM) is not configured"
    exit 1
fi

# Finish with results
case $KERN in
    '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
           echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
    '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    '3.8') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    '3.10') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    '4.1') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    '4.14') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
    *) echo "Kernel version $KERN is not supported by this script (yet). Exiting." ;;
esac
  1. 示例:

    For 2.4 kernel systems:
    $ ./hugepages_settings.sh
    ...
    Recommended setting: vm.hugetlb_pool = 764
    
    For 2.6 and later kernel systems:
    $ ./hugepages_settings.sh
    ...
    Recommended setting: vm.nr_hugepages = 67
    
  2. 修改/etc/sysctl.conf

    echo "vm.nr_hugepages = 4098" >> /etc/sysctl.conf
    
  3. 重啟資料庫
  4. 檢查大頁使用情況

    grep -i huge /proc/meminfo

 

 

一.安裝軟體初始化環境指令碼(yun已經配置好了)

cat 19cinstall.sh


#!/bin/bash

##需要7.0+ 版本的Linux
#關閉selinux

sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
systemctl stop firewalld
systemctl disable firewalld

#禁用avahi-daemon
systemctl stop avahi-daemon
systemctl disable avahi-daemon
systemctl status avahi-daemon

#關閉 NetworkManager

systemctl stop NetworkManager
systemctl disable NetworkManager


#設定RemoveIPC=false
echo "RemoveIPC=no" >> /etc/systemd/logind.conf


#配置/etc/hosts檔案 新增
cat >> /etc/hosts<<EOF

##XXXX    HOSTNAME

EOF

#增大共享記憶體
#mount -t tmpfs shmfs -o size=7g /dev/shm
#echo 'shmfs /dev/shm tmpfs size=24g' >> /etc/fstab


#新增組
groupadd -g 1200 oinstall
groupadd -g 1201 dba
groupadd -g 1202 oper
groupadd -g 1203 backupdba
groupadd -g 1204 dgdba
groupadd -g 1205 kmdba


#新增使用者

useradd -m -d /home/oracle -u 1101 -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle
echo 'oracle' | passwd --stdin oracle


#建立安裝目錄

mkdir -p /u01/app/oracle/product/19c/dbhome_1

mkdir -p /u01/app/oracle/oradata/
mkdir -p /u01/app/oraInventory

#更改目錄許可權
chown -R oracle:oinstall /u01/app/oracle
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01

#改變核心引數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 19c

fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
kernel.shmall = 16097152
kernel.shmmax = 128849018880
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

EOF

#使核心引數立即生效
sysctl -p

#新增使用者資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 3145728
oracle soft memlock 3145728

 

#編輯配置檔案
cat >> /etc/profile<<EOF

#this is for oracle user
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF


#編輯登陸配置檔案
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF


#為oracle使用者新增環境變數 dg加一個  export DB_UNIQUE_NAME=ttfcdg
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=ttfc

export PDB_NAME=ttfcpdb

export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務
/sbin/service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org

systemctl stop chronyd
systemctl disable chrnyd

#安裝oracle所需要的包
yum clean all

yum install -y bc    
yum install -y binutils
yum install -y compat-libcap1
yum install -y compat-libstdc++-33
#yum install -y dtrace-modules
#yum install -y dtrace-modules-headers
#yum install -y dtrace-modules-provider-headers
yum install -y dtrace-utils
yum install -y elfutils-libelf
yum install -y elfutils-libelf-devel
yum install -y fontconfig-devel
yum install -y glibc
yum install -y glibc-devel
yum install -y ksh
yum install -y libaio
yum install -y libaio-devel
yum install -y libdtrace-ctf-devel
yum install -y libXrender
yum install -y libXrender-devel
yum install -y libX11
yum install -y libXau
yum install -y libXi
yum install -y libXtst
yum install -y libgcc
yum install -y librdmacm-devel
yum install -y libstdc++
yum install -y libstdc++-devel
yum install -y libxcb
yum install -y make
yum install -y net-tools # Clusterware
yum install -y nfs-utils # ACFS
yum install -y python # ACFS
yum install -y python-configshell # ACFS
yum install -y python-rtslib # ACFS
yum install -y python-six # ACFS
yum install -y targetcli # ACFS
yum install -y smartmontools
yum install -y sysstat

# Added by me.
yum install -y unixODBC

二.靜默安裝19c軟體

cd  /u01/app/oracle/product/19c/dbhome_1/

chown -R oracle:oinstall *

oracle 使用者執行一下:

/u01/app/oracle/product/19c/dbhome_1/runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile ${ORACLE_HOME}/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true

 

As a root user, execute the following script(s):
root使用者執行以下指令碼:
/u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/19.0.0/dbhome_1/root.sh

 

 

啟動監聽就可以啦!!

 

 

三.靜默安裝資料庫

 設定了1個PDB,sys,system 密碼SysPassword1,記憶體12000M,redo日誌256M

 

/u01/app/oracle/product/19c/dbhome_1/bin/dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword SysPassword1 \
-systemPassword SysPassword1 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName ${PDB_NAME} \
-pdbAdminPassword PdbPassword1 \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 12000 \
-storageType FS \
-datafileDestination /u01/app/oracle/oradata/ \
-redoLogFileSize 256 \
-nationalCharacterSet AL16UTF16 \
-emConfiguration NONE \
-ignorePreReqs

 

 

 

 

/u01/app/oracle/product/19c/dbhome_1/bin/dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword SysPassword1 \
-systemPassword SysPassword1 \
-createAsContainerDatabase false \
-databaseType MULTIPURPOSE \
-memoryMgmtType auto_sga \
-totalMemory 10000 \
-storageType FS \
-datafileDestination /u01/app/oracle/oradata/ \
-redoLogFileSize 256 \
-nationalCharacterSet AL16UTF16 \
-emConfiguration NONE \
-ignorePreReqs

   

編輯 /etc/oratab 檔案,將每個例項的重啟標誌設定為“ Y”。

vi /etc/oratab

ttfc:/u01/app/oracle/product/19c/dbhome_1/:Y

啟用Oracle託管檔案(OMF),並確保在例項啟動時啟動PDB。

sqlplus / as sysdba 

alter system set db_create_file_dest='/u01/app/oracle/oradata/';
alter pluggable database ttfcpdb save state;

show pdbs;

show con_id;

 

 

四.DG的搭建和配置

 

在 12cR2 ( 12.2.0.1 )之前建立物理備庫的方法有:

1 、Oracle 10g可以使用 RMAN 備份恢復方法;

2 、在 11g 時可以選擇 duplicate 方式建立物理備庫;通過這種方式直接線上從主庫搭建物理備庫。

到 12cR2 ( 12.2.0.1 )後, Oracle 又提供更簡單的方式來建立物理備庫,即使用 DBCA 方式直接建立物理備庫。這個功能再次簡化了建立備庫的複雜度。

通過 DBCA 提供的引數 createDuplicateDB 可以很容易的搭建一個物理備庫。

雖然通過 DBCA 能非常簡單的建立一個物理備庫,但是要使用這個功能,必須滿足以下條件:

①  主庫必須是單機環境,非 RAC 資料庫;

②  主庫必須是非 CDB 環境;

也就說通過 DBCA 搭建出來的備庫也是一個單機非 CDB 的備庫。

需要注意的是,在 12cR2 ( 12.2.0.1 )中,通過 DBCA 建立物理需要保證主庫是單機非 CDB 的庫,但是從 Oracle 18c ( 12.2.0.2 )開始,這些限制條件已經取消了,即主庫是 CDB 或 rac 環境都可以通過 dbca 來建立物理備庫。

  

4.1主庫啟動FORCE LOGGING

select name,open_mode from v$pdbs;
select force_logging from v$database;

 

alter database force logging;
select force_logging from v$database;

 4.2主庫啟動歸檔模式

archive log list;

 

 我的已經開啟了歸檔模式了。

alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog' scope=spfile ;
alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;
設定好後重啟。

  

4 .3 在主庫新增 standby redo logfile

在Oracle 19c的多租戶架構裡,online redo log 和控制檔案是儲存在CDB中的,PDB中只有執行需要的資料檔案,所以我們這裡加standby redo log,也是在CDB中加。

alter database add standby logfile thread 1 group 11 '/u01/app/oracle/oradata/TTFC/standby01.log' size 256M;
alter database add standby logfile thread 1 group 12 '/u01/app/oracle/oradata/TTFC/standby02.log' size 256M;
alter database add standby logfile thread 1 group 13 '/u01/app/oracle/oradata/TTFC/standby03.log' size 256M;
alter database add standby logfile thread 1 group 14 '/u01/app/oracle/oradata/TTFC/standby04.log' size 256M;
alter database add standby logfile thread 1 group 15 '/u01/app/oracle/oradata/TTFC/standby05.log' size 256M;
alter database add standby logfile thread 1 group 16 '/u01/app/oracle/oradata/TTFC/standby06.log' size 256M;
alter database add standby logfile thread 1 group 17 '/u01/app/oracle/oradata/TTFC/standby07.log' size 256M;
alter database add standby logfile thread 1 group 18 '/u01/app/oracle/oradata/TTFC/standby08.log' size 256M;

standby logfile比logfile要多一組7+1=8組(logfile我的有7組,調整引數後加了三組)

4.4 在主庫建立備庫pfile 檔案並修改pfile 內容

 如果主庫與備庫資料檔案位置不相同,則需要使用db_file_name_convert來轉換,如果主庫與備庫線上日誌檔案位置不相同,則需要使用log_file_name_convert來轉換。

LOG_ARCHIVE_DEST_1,LOG_ARCHIVE_DEST_2可以不用重啟生效,但是db_file_name_convert,log_file_name_convert必須要重啟生效。

alter system set LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ttfc' ;
alter system set LOG_ARCHIVE_DEST_2='service=ttfcdg SYNC VALID_FOR=(online_logfiles,primary_role) DB_UNIQUE_NAME=ttfcdg' scope=both;
alter system set log_archive_config='dg_config=(ttfc,ttfcdg)';
alter system set db_file_name_convert='/u01/app/oracle/oradata/TTFCDG','/u01/app/oracle/oradata/TTFC' scope=spfile;
alter system set log_file_name_convert='/u01/app/oracle/oradata/TTFCDG','/u01/app/oracle/oradata/TTFC' scope=spfile;
alter system set standby_file_management=auto scope=spfile;
alter system set fal_server='ttfcdg' sid='*';
alter system set log_archive_dest_state_1 = ENABLE;
alter system set log_archive_dest_state_2 = ENABLE;
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXX)(PORT=1521)))','(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXX)(PORT=1521)))';

 

4.5 修改備庫pfile 檔案

後主庫資料庫進行重啟,並且配置

shutdown immediate;

startup;

create pfile='/home/oracle/standby.ora' from spfile;

vi /home/oracle/standby.ora

備庫修改後引數如下:


*.audit_file_dest='/u01/app/oracle/admin/ttfcdg/adump'
*.audit_trail='NONE'
*.compatible='19.0.0'
*.control_files='/u01/app/oracle/oradata/TTFCDG/control01.ctl','/u01/app/oracle/oradata/TTFCDG/control02.ctl'#Restore Controlfile
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata/'
*.db_file_name_convert='/u01/app/oracle/oradata/TTFC','/u01/app/oracle/oradata/TTFCDG'
*.db_files=2000
*.db_name='ttfc'
*.db_recovery_file_dest_size=53687091200
*.db_recovery_file_dest='/u01/app/oracle/flashback'
*.db_unique_name='ttfcdg'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ttfcXDB)'
*.enable_pluggable_database=true
*.fal_client='ttfcdg'
*.fal_server='ttfc'
*.fast_start_mttr_target=300
*.local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXX)(PORT=1521)))','(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXX)(PORT=1521)))'
*.log_archive_config='dg_config=(ttfcdg,ttfc)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ttfcdg'
*.log_archive_dest_2='service=ttfc ASYNC  VALID_FOR=(online_logfiles,primary_role) DB_UNIQUE_NAME=ttfc'
*.log_archive_format='arch_%t_%s_%r.arc'
*.log_archive_max_processes=10
*.log_file_name_convert='/u01/app/oracle/oradata/TTFC','/u01/app/oracle/oradata/TTFCDG'
*.nls_date_format='yyyy-mm-dd hh24:mi:ss'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=3000
*.pga_aggregate_target=3000m
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=9000m
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

 

同時建目錄如下:

mkdir -p /u01/app/oracle/admin/ttfcdg/adump

mkdir -p /u01/app/oracle/oradata/TTFCDG

 

4.6 配置主備tns和監聽

/u01/app/oracle/product/19c/dbhome_1/network/admin

主庫監聽

vi listener.ora

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ttfc)
(ORACLE_HOME = /u01/app/oracle/product/19c/dbhome_1)
(SID_NAME = ttfc)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xx)(PORT = 1521))
)

ADR_BASE_LISTENER = /u01/app/oracle

 

 備庫監聽

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ttfcdg)
(ORACLE_HOME = /u01/app/oracle/product/19c/dbhome_1)
(SID_NAME = ttfc)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx)(PORT = 1521))
)

ADR_BASE_LISTENER = /u01/app/oracle

 

 主備庫tns如下:

vi tnsnames.ora

ttfc =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ttfc)
)
)

ttfcdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ttfcdg)
)
)

tnsping ttfc

tnsping ttfcdg

 

配置sqlnet.ora

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

ADR_BASE = /u01/app/oracle
SQLNET.ALLOWED_LOGON_VERSION_SERVER=10
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=10

將主庫的口令檔案copy到備庫


scp /u01/app/oracle/product/19c/dbhome_1/dbs/orapwttfc oracle@stanby_IP:/u01/app/oracle/product/19c/dbhome_1/dbs

 sqlplus sys/xx@ttfc as sysdba

sqlplus sys/xx@ttfcdg as sysdba

測試連線沒有問題。

  

4.6在備庫建立必要的目錄(根據自己配置的情況)

oracle使用者執行:

mkdir -p /u01/app/oracle/oradata/TTFCDG

mkdir -p /u01/app/oracle/flashback/

mkdir -p /u01/app/oracle/admin/ttfcdg/adump

mkdir -p /u01/app/oracle/expdp_dir

 

4.7 開始進行Active duplicate

將備庫啟動到nomount 狀態,主庫

執行:

rman target sys/xx@ttfc auxiliary sys/xx@ttfcdg

duplicate target database for standby from active database nofilenamecheck dorecover;

  

 

 

  

 duplicate 完成之後,備庫是mount的。

 

show pdbs;
show con_id;
select open_mode from v$database;
alter database open;
show pdbs;
alter pluggable database all open;
show pdbs;

 

 

 

 alter database recover managed standby database disconnect using current logfile;

  

4.8 開始進行驗證(自行驗證)

 大多數我都是寫好failover的指令碼(並做failover測試,閃回備庫),個人不做switchover,因為真正發生故障直接是failover,故障的那一臺伺服器弄好了在重新搭建備庫就好;

主庫:

 

 備庫:

 

  

 

 

五.主備HugePages 啟用大頁

 

 

 vi /etc/sysctl.conf 

vm.nr_hugepages = 4514

sysctl  -p

cat /proc/sys/vm/nr_hugepages
grep -i HugePages_Total /proc/meminfo

 

相關文章