Thứ Năm, 4 tháng 9, 2025

Oracle Data Guard convert physical thành snapshot standby Oracle 19c

Snapshot Standby trong Oracle Data Guard là một loại cơ sở dữ liệu dự phòng được sử dụng để tạo bản sao nhanh, có thể cập nhật của cơ sở dữ liệu chính Oracle. Nó khác với các loại cơ sở dữ liệu dự phòng khác như Physical Standby và Logical Standby.

THÔNG TIN CHI TIẾT 2 NODE:

ItemsPrimary – SRV1Standby – SRV2
hostnamesrv1srv2
ip192.168.1.11192.168.1.12
db nameduodbduodb
instance_nameduodbstand
db_unique_nameduodbstand
version DB19.319.3
DB_HOME/u01/app/oracle/ product/19.3.0/dbhome_1/u01/app/oracle/ product/19.3.0/dbhome_1
DB_BASE/u01/app/oracle/u01/app/oracle
global database namesrv1.localdomainsrv2.localdomain

do oracle data guard

SRV1 – server tôi đặt là Primary

SRV2 – server tôi đặt là Standby

Kiểm tra thông tin database:

Check thông tin 2 DB:

select status,instance_name,database_role,open_mode from v$database,v$Instance;

DB prim:

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS INSTANCE_NAME DATABASE_ROLE OPEN_MODE

———— —————- —————- ——————–

OPEN duodb PRIMARY READ WRITE

DB standby:

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS INSTANCE_NAME DATABASE_ROLE OPEN_MODE

———— —————- —————- ——————–

MOUNTED stand PHYSICAL STANDBY MOUNTED

SRV Primary: check status và đảm bảo không có cảnh báo hay lỗi:

select switchover_status from v$database;

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

——————–

TO STANDBY

Check GAP trên cả 2 node và đảm bảo không có cảnh báo gì: (nếu có => hãy khắc phục lỗi trước khi thực hiện các bước tiếp theo)

select status, gap_status from v$archive_dest_status where dest_id = 2;

SQL> select status, gap_status from v$archive_dest_status where dest_id = 2;

STATUS GAP_STATUS

——— ————————

VALID NO GAP

Check thông tin sequence đảm bảo 2 bên đồng bộ với nhau: (cùng số seq):

select thread#,max(sequence#) from v$archived_log group by thread#;

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)

———- ————–

1 16

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)

———- ————–

1 16

Standby stop the mrp process: (dừng quá trình đồng bộ bên Standby), sau đó shutdown và khởi động DB ở chế độ mount:

alter database recover managed standby database cancel;
shut immediate
startup mount

word image 1025 2

Standby: tiến hành convert thành Snapshot standby database, sau đó Open database trong read-write mode kiểm tra database sau khi Open:

alter database convert to snapshot standby;
alter database open;
select status, instance_name, database_role,open_mode from v$database, v$instance;

word image 1025 3

Standby Testing: thêm user, table và data vào trong Snapshot standby:

create user duo identified by oracle;
grant connect, resource to duo;
alter user duo quota unlimited on users;
conn duo/oracle
create table sample111(code number, name char(20));
insert into sample111 values(1,'duong duong');
commit;
select * from sample111;

word image 1025 4

word image 1025 5

Check seq trên cả 2 Node:

select thread#,max(sequence#) from v$archived_log group by thread#; 

select process,status,sequence# from v$managed_standby;

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

THREAD# MAX(SEQUENCE#)

———- ————–

1 16

word image 1025 6

Standby: tắt và mount database:

shut immediate

startup mount

Standby: chuyển đổi từ Snapshot tới Physical standby, sau đó shutdown và open lại:

alter database convert to physical standby;

shut immediate
startup
select status,instance_name,database_role,open_mode from v$database,v$Instance;

word image 1025 7

Standby: bật chế độ đồng bộ redo log để nhận redo apply từ Primary:

alter database recover managed standby database disconnect from session;

Check lại 2 node:

select status, gap_status from v$archive_dest_status where dest_id = 2;

select switchover_status from v$database;

SQL> select status, gap_status from v$archive_dest_status where dest_id = 2;

STATUS GAP_STATUS

——— ————————

VALID NO GAP

SQL> select status, gap_status from v$archive_dest_status where dest_id = 2;

STATUS GAP_STATUS

——— ————————

VALID

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

——————–

TO STANDBY

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS

——————–

NOT ALLOWED

Standby: kiểm tra xem còn user và table đã tạo trước đó không? (sẽ mất đi vì Standby bây giờ đã đồng bộ từ Primary nên clear hết)

select * from duo.sample111;

SQL> select * from duo.sample111;

select * from duo.sample111

*

ERROR at line 1:

ORA-00942: table or view does not exist

Primary: tạo user và table sau đó check bên Standby dữ liệu đã đồng bộ hay chưa:

create user duong identified by oracle;
grant connect, resource to duong;
alter user duong quota unlimited on users;
conn duong/oracle
create table tab1(code number, name char(20));
insert into tab1 values(1,'duong duong 222');
commit;
select * from tab1;

Sau đó sang bên Standby check xem có thông tin hay chưa:

sqlplus / as sysdba
conn duong/oracle
select * from tab1;

SQL> conn duong/oracle

select * from tab1;

Connected.

SQL>

CODE NAME

———- ——————–

1 duong duong 222

Chúc các bạn thành công.

=============================
Website không chứa bất kỳ quảng cáo nào, mọi đóng góp để duy trì phát triển cho website (donation) xin vui lòng gửi về STK 90.2142.8888 - Ngân hàng Vietcombank Thăng Long - TRAN VAN BINH
=============================
Nếu bạn không muốn bị AI thay thế và tiết kiệm 3-5 NĂM trên con đường trở thành DBA chuyên nghiệp hay làm chủ Database thì hãy đăng ký ngay KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE, được Coaching trực tiếp từ tôi với toàn bộ bí kíp thực chiến, thủ tục, quy trình của gần 20 năm kinh nghiệm (mà bạn sẽ KHÔNG THỂ tìm kiếm trên Internet/Google) từ đó giúp bạn dễ dàng quản trị mọi hệ thống Core tại Việt Nam và trên thế giới, đỗ OCP.
- CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
- Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
2 khóa học online qua video giúp bạn nhanh chóng có những kiến thức nền tảng về Linux, Oracle, học mọi nơi, chỉ cần có Internet/4G:
- Oracle cơ bản: https://bit.ly/admin_1200
- Linux: https://bit.ly/linux_1200
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile/Zalo: 0902912888
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: https://www.youtube.com/@binhguru
👨 Tiktok: https://www.tiktok.com/@binhguru
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhguru
👨 Podcast: https://www.podbean.com/pu/pbblog-eskre-5f82d6
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
cở sở dữ liệu, cơ sở dữ liệu quốc gia, database, AI, trí tuệ nhân tạo, artificial intelligence, machine learning, deep learning, LLM, ChatGPT, DeepSeek, Grok, oracle tutorial, học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,sql tutorial, khóa học pl/sql tutorial, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c/21c/23c/23ai, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail,oracle RAC, ASM, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, postgresql tutorial, mysql tutorial, mariadb tutorial, ms sql server tutorial, nosql, mongodb tutorial, oci, cloud, middleware tutorial, docker, k8s, micro service, hoc solaris tutorial, hoc linux tutorial, hoc aix tutorial, unix tutorial, securecrt, xshell, mobaxterm, putty
Sửa bài viết

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master