检查环境:
su - oracle
ps -ef|grep smon
echo $ORACLE_HOME
lsnrctl status
su - oralce echo “export LANG=en_US” >> ~/.bash_prefile echo “export ORACLE_BASE=/opt/oracle” >> ~/.bash_prefile echo “export ORACLE_HOEM=$ORACLE_BASE/product/19c/dbhome_1” >> ~/.bash_prefile echo “export ORACLE_UNQNAME=itpuxdg” >> ~/.bash_prefile echo “export ORACLE_SID=itpuxdb1” >> ~/.bash_prefile echo “export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG” >> ~/.bash_prefile echo “exoprt PATH=.:P A T H : PATH:PATH:HOME:/bin:$ORACLE_HOME/bin” >> ~/.bash_prefile source ~/.bash_profile env |grep ORACLE
准备备库监听配置
vi /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora LISTNER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 主机名)(PORT = 1521) (ADDRESS = (PROTOCOL = TCP)(KEY = EXTPROC1521) ) SID_LIST_LISTENER= (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = 数据库名) (SID_NAME = 数据库实例名) (ORACLE_HOME = /opt/oracle/product/19c/dbhome_1) ) )
oracle19c DB创建过程
01.enable force logging alter database force logging; 02.enable archivelog mode alter system set db_recovery_file_dest_size=10g; alter system set db_recovery_file_dest=‘/opt/oracle’; startup mount; alter database archivelog; alter database open; alter system swtch logfile; 03.create standby redolog alter database add stan logfile group 4 ‘/opt/oracle/oradata/ITPUXDB/strdo04.log’ size 200m; alter database add stan logfile group 5 ‘/opt/oracle/oradata/ITPUXDB/strdo05.log’ size 200m; alter database add stan logfile group 6 ‘/opt/oracle/oradata/ITPUXDB/strdo06.log’ size 200m; alter database add stan logfile group 7 ‘/opt/oracle/oradata/ITPUXDB/strdo07.log’ size 200m;
主备库监听tnsnames.ora :
vi /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora itpuxdb = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVER_NAME = 实例名) ) )
备库
itpuxdb = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVER_NAME = 实例名) ) )
准备数据库密码文件
主库:
orapwd file=/opt/oracle/product/19c/dbhome_1/dbs/orapwitpuxdb password=ITPUX-123
备库:
cd /opt/oracle/product/19c/dbhome_1/dbs/
scp IP:/opt/oracle/product/19c/dbhome_1/dbs/orapwitpuxdb
mv orapwitpuxdb orapwitpuxdg
登录
sqlplus “sys/ITPUX-123@itpuxdg as sysdba”
主库:
create pflie = ‘/opt/oracle/pfile.ora’ from spfile
主库参数(重启生效)(itpuxdb主库 itpuxdg备库)
alter system set db_unique_name=‘itpuxdb’ scope=spfile; alter system set LOG_ARCHIVE_CONFIG='DG _CONFIG=(itpuxdb,itpuxdg)’scope=both; alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=itpuxdb’ scope=both; alter system set LOG_ARCHIVE_DEST_2='SERVICE=itpuxdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=itpuxdgscope=both; alter system set fal_client=‘itpuxdb’ scope=both; alter system set FAL_SERVER=‘itpuxdg’ scope=both; alter system set DB_FILE _NAME_CONVERT=‘ITPUXDG’,ITPUXDB’ scope=spfile; alter system set LOG _FILE_NAME_CONVERT=‘ITPUXDG’,‘ITPUXDB’ scope=spfile; alter system set standby_file_management=AUTO scope=both;
备库参数:
cd /opt/oracle
vi pfile.ora
db_unique_name=‘itpuxdg’
LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(itpuxdg,itpuxdb)’
LOG_ARCHIVE_DEST_1=‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=itpuxdg’
LOG_ARCHIVE_DEST_2=‘SERVICE=itpuxdb LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=itpuxdb’ fal_client=‘itpuxdg’
FAL_SERVER=‘itpuxdb’
DB_FILE_NAME_CONVERT=‘ITPUXDB’,‘ITPUXDG’
LOG_FILE_NAME_CONVERT=‘ITPUXDB’,‘ITPUXDG’
standby_file_management=AUTO
oracle19c DG创建过程
创建目录
mkdir -p /opt/oracle/admin/itpuxdg/adump
mkdir -p /opt/oracle/oradata/ITPUXDG