linux-oracle11g-dg搭建日誌
rpm -ivh compat-libstdc++* elfutils* ksh* libaio-devel* unixODBC* unixODBC-devel* --nodeps
cp compat-libstdc++* /u01
cp elfutils* /u01
cp ksh* /u01
cp libaio-devel* /u01
cp unixODBC* /u01
cp package unixODBC-devel* /u01
rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
#* soft core 0
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
# For Oracle
export DISPLAY=:0.0
export TMP=/tmp;
export TMPDIR=$TMP;
export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;
export ORACLE_SID=sales;
export ORACLE_TERM=xterm;
export PATH=/usr/sbin:$PATH;
export PATH=$ORACLE_HOME/bin:$PATH;
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;
rpm -q binutils-2.20.51.0.2-5.11.el6.i686 compat-libcap1-1.10-1.i686 compat-libstdc++-33-3.2.3-69.el6.i686 gcc-4.4.4-13.el6.i686 gcc-c++-4.4.4-13.el6.i686 glibc-2.12-1.7.el6.i686 glibc-devel-2.12-1.7.el6.i686 ksh libgcc-4.4.4-13.el6.i686 libstdc++-4.4.4-13.el6.i686 libstdc++-devel-4.4.4-13.el6.i686 libaio-0.3.107-10.el6.i686 libaio-devel-0.3.107-10.el6.i686 make-3.81-19.el6.i686 sysstat-9.0.4-11.el6.i686
rpm -ivh binutils*.rpm compat-libcap*.rpm compat-libstdc++*.rpm gcc*.rpm gcc-c++*.rpm glibc*.rpm glibc*.rpm ksh libgcc*.rpm libstdc++*.rpm libstdc++*.rpm libaio*.rpm libaio-devel*.rpm make*.rpm sysstat*.rpm --nodeps --force
#
# atrpms
# el6Server - i386 - ATrpms
#
[atrpms]
name=el6Server - i386 - ATrpms
baseurl=
type=rpm-md
export DISPLAY=172.16.254.4:0.0
prod.localdomain
scp orapwprod 192.168.17.247:/u01/app/oracle/product/11.2.0/db_1/dbs
scp initprod.ora 192.168.17.247:/u01/app/oracle/product/11.2.0/db_1/dbs
scp /u01/app/standby.ctl 192.168.17.247:/u01/app
mkdir -p /u01/app/oracle/admin/standby/adump
mkdir -p /u01/app/oracle/admin/standby/bdump
mkdir -p /u01/app/oracle/admin/standby/cdump
mkdir -p /u01/app/oracle/admin/standby/udump
mkdir -p /u01/app/oracle/admin/standby/dpdump
mkdir -p /u01/app/oracle/oradata/standby/archivelog
ls -l /u01/app/oracle/admin/standby
ls -l /u01/app/oracle/oradata/standby
create spfile from pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initstandby.ora';
startup nomount
alter system set log_archive_config='dg_config=(prod,standby)';
alter system set log_archive_dest_1='location=/u01/app/oracle/oradata/prod/archivelog valid_for=(all_logfiles,all_roles) db_unique_name=prod';
alter system set log_archive_dest_2='service=standby lgwr
async valid_for=(online_logfiles,primary_role)
db_unique_name=standby';
alter system set log_archive_dest_state_1=enable;
alter system set log_archive_dest_state_2=enable;
alter system set log_archive_max_processes=10;
alter system set fal_server=standby;
alter system set fal_client=prod;
alter system set standby_file_management=auto;
alter system set db_unique_name='prod'scope=spfile;
alter system set db_file_name_convert='/u01/app/oracle/oradata/standby','/u01/app/oracle/oradata/prod' scope=spfile;
alter system set log_file_name_convert='/u01/app/oracle/oradata/standby','/u01/app/oracle/oradata/prod' scope=spfile;
mkdir -p /u01/backupset
chown -R oracle.oinstall /u01/backupset
run
{
allocate channel d1 type disk format '/u01/backupset/%U';
backup database;
release channel d1;
}
scp -r /u01/backupset 192.168.17.247:/u01
rman target / auxiliary sys/redhat@standby
run
{
allocate auxiliary channel d1 type disk;
duplicate target database for standby nofilenamecheck;
release channel d1;
}
scp -r /u01/backupset 192.168.17.247:/u01
alter database add standby logfile ('/u01/app/oracle/oradata/standby/standby01.log') size 50m;
alter database add standby logfile ('/u01/app/oracle/oradata/standby/standby02.log') size 50m;
alter database add standby logfile ('/u01/app/oracle/oradata/standby/standby03.log') size 50m;
alter database add standby logfile ('/u01/app/oracle/oradata/standby/standby04.log') size 50m;
alter database recover managed standby database using current logfile disconnect from session;
select sequence#, applied from v$archived_log where
applied='YES' order by sequence#;
conn scott/tiger
create table t(i int);
insert into t values(1);
commit;
conn / as sysdba
alter system switch logfile;
alter system switch logfile;
select switchover_status from v$database
alter database recover managed standby database cancel;
alter database open;
conn scott/tiger
select * from t;
conn / as sysdba
select open_mode from v$database;
alter database recover managed standby database using current logfile disconnect from session;
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
select switchover_status from v$database;
select open_mode from v$database;
select status from v$instance;
---standby 在startup mount後
alter database recover managed standby database using current logfile disconnect from session;
alter database recover managed standby database cancel;
alter database open;
-- 切換失敗,注意殺掉殭屍程式
alter database commit to switchover to physical standby WITH SESSION SHUTDOWN;
看筆記
--切換回備庫
startup nomount
alter databasemount standby database;
select sequence#, applied from v$archived_log where
applied='YES' order by sequence#;
select switchover_status from v$database;
alter database commit to switchover to primary;--把備庫切為主庫
alter database recover managed standby database disconnect from session;--報錯media need recover 的處理
---prod上,建立備日誌
alter database add standby logfile
('/u01/app/oracle/oradata/prod/standby01.log') size 50m;
alter database add standby logfile
('/u01/app/oracle/oradata/prod/standby02.log') size 50m;
alter database add standby logfile
('/u01/app/oracle/oradata/prod/standby03.log') size 50m;
alter database add standby logfile
('/u01/app/oracle/oradata/prod/standby04.log') size 50m;
--執行同步語句
alter database recover managed standby database using current logfile disconnect from session;
select sequence#, applied from v$archived_log where
applied='YES'order by sequence#;
--standby上執行
conn scott/tiger
insert into t values(2);
commit;
conn / as sysdba
alter system switch logfile;
--prod上執行
alter database recover managed standby database cancel;
alter database open;
conn scott/tiger
select * from t;--物理DG切換成功
conn / as sysdba
select open_mode from v$database;--現在是read only
alter database recover managed standby database using current logfile disconnect from session;
select open_mode from v$database;--切換回同步模式mount
--切換回原來的狀態
select switchover_status from v$database;
alter database commit to switchover to physical standby;
shutdown immediate
startup nomount
alter database mount standby database;--standby標誌他為standby
---prod上
select sequence#, applied from v$archived_log where
applied='YES' order by sequence#;
select switchover_status from v$database;
alter database commit to switchover to primary;
select status from v$instance;--主庫標識為primary
shutdown immediate
startup
--standby上
alter database recover managed standby database using current logfile disconnect from session;
--prod上
conn scott/tiger
insert into t values(3);
commit;
conn / as sysdba
alter system switch logfile;
--standby上
alter database recover managed standby database cancel;
alter database open;
conn scott/tiger
select * from t;
conn / as sysdba
alter database recover managed standby database using current logfile disconnect from session;
select open_mode from v$database;
-----搭建虛擬備庫
--配置邏輯備庫
alter database recover managed standby database cancel;
--配置prod
exit
mkdir -p /u01/app/oracle/oradata/prod/lgarchive
ls -l /u01/app/oracle/oradata/prod/
sqlplus / as sysdba
alter system set log_archive_dest_3='location=/u01/app/oracle/oradata/prod/lgarchive valid_for=(standby_logfiles,standby_role) db_unique_name=prod'; alter system set log_archive_dest_state_3=enable;
execute dbms_logstdby.build;
--配置standby
exit
mkdir -p /u01/app/oracle/oradata/standby/lgarchive
ls -l /u01/app/oracle/oradata/standby/
sqlplus / as sysdba
alter system set log_archive_dest_3='location=/u01/app/oracle/oradata/standby/lgarchive valid_for=(standby_logfiles,standby_role) db_unique_name=standby';
alter system set log_archive_dest_state_3=enable;
--physical standby轉換為logical standby
select * from v$tempfile
select status from v$instance;
select database_role from v$database;
startup mount force
alter database recover to logical standby standby;
select status from v$instance;
startup mount force
select database_role from v$database;
alter database open resetlogs;
show parameter db_name
--prod環境
alter system switch logfile;
/
/
/
--standby
ls -l /u01/app/oracle/oradata/standby/archivelog
sqlplus / as sysdba
alter database start logical standby apply immediate;
--驗證 prod庫
conn scott/tiger
create table a(a varchar2(10));
insert into a values('a');
commit;
--驗證 standby庫
conn scott/tiger
select * from a;
----切換邏輯備庫,prod與standby都執行
conn / as sysdba
alter system set undo_retention=3600;
--prod執行
select switchover_status from v$database;
alter database prepare to switchover to logical standby;
select switchover_status from v$database;
--standby執行
select switchover_status from v$database;
alter database prepare to switchover to primary;
select switchover_status from v$database;
--prod執行
select switchover_status from v$database;--返回結果to logical standby
取消轉換的命令為:alter database prepare to switchover cancel;
alter database commit to switchover to logical standby;
--standby執行
select switchover_status from v$database;
alter database commit to switchover to primary;
--prod執行
alter database start logical standby apply immediate;
--standby執行
conn scott/tiger
insert into a values('b');
commit;
conn / as sysdba
--prod執行
conn scott/tiger
select * from a;
conn / as sysdba
alter database prepare to switchover to logical standby;
alter database prepare to switchover to primary;
select switchover_status from v$database;
alter database commit to switchover to logical standby;
alter database commit to switchover to primary;
alter database start logical standby apply immediate;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21302630/viewspace-1571799/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 搭建ELK日誌平臺(單機)
- 搭建node服務(1):日誌處理
- RHEL 6.5 搭建Rsyslog日誌伺服器和Loganalyzer日誌分析工具伺服器
- 使用Seq搭建免費的日誌服務
- Elasticsearch+Kibana日誌分析系統搭建Elasticsearch
- ELK+FileBeat+Kafka搭建日誌管理平臺Kafka
- Elasticsearch+Fluentd+Kafka搭建分散式日誌系ElasticsearchKafka分散式
- 在Docker上搭建ELK+Filebeat日誌中心Docker
- 使用docker搭建ELK分散式日誌同步方案Docker分散式
- mysql之 日誌體系(錯誤日誌、查詢日誌、二進位制日誌、事務日誌、中繼日誌)MySql中繼
- 日誌伺服器搭建之多伺服器日誌轉發與格式化處理伺服器
- Kubernetes 中 搭建 EFK 日誌搜尋中心
- Windows系統搭建ELK日誌收集伺服器Windows伺服器
- 利用ELK搭建Docker容器化應用日誌中心Docker應用日誌
- php日誌,記錄日誌PHP
- 日誌分析-apache日誌分析Apache
- 聯機重做日誌、歸檔日誌、備用重做日誌
- mysql 日誌之錯誤日誌MySql
- mysql 日誌之慢查詢日誌MySql
- 【Oracle日誌】- 日誌檔案重建Oracle
- MySQL 主從複製搭建,基於日誌(binlog)MySql
- 日誌
- [日誌分析篇]-利用ELK分析jumpserver日誌-日誌拆分篇Server
- mysql 日誌之普通查詢日誌MySql
- Apche日誌系列(4):日誌分析(轉)
- .NET Core + ELK搭建視覺化日誌分析平臺(上)視覺化
- Elasticsearch+kibana+logstash 搭建日誌收集分析平臺Elasticsearch
- 後續來啦:Winform/WPF中快速搭建日誌皮膚ORM
- docker-compose搭建grafana+loki+promtail日誌系統DockerGrafanaLokiAI
- 基於Docker的日誌分析平臺(二) 環境搭建Docker
- 【Lolttery】專案開發日誌 (一) 微服務框架搭建微服務框架
- mysql 日誌之二進位制日誌MySql
- MYSQL啟用日誌和檢視日誌MySql
- Apche日誌系列(1):訪問日誌(轉)
- Apche日誌系列(2):錯誤日誌(轉)
- Apche日誌系列(3):定製日誌(轉)
- 日誌篇:模組日誌總體介紹
- 日誌配置