Thứ Hai, 19 tháng 1, 2026

RMAN duplicate Two-Node RAC thành Single-Instance Database

Bước 1:  Sao lưu cơ sở dữ liệu nguồn, bao gồm tệp điều khiển, tệp spfile và nhật ký lưu trữ.
(Kiểm tra xem tất cả nhật ký lưu trữ đã được sao lưu chưa và xác minh quá trình sao lưu đã hoàn tất thành công mà không có lỗi nào). 

Kiểm tra số lượng lõi CPU trên máy chủ và phân bổ kênh tương ứng.

vi rman_backup.rcv
run
{
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch5 device type disk;
allocate channel ch6 device type disk;
allocate channel ch7 device type disk;
allocate channel ch8 device type disk;
allocate channel ch9 device type disk;
allocate channel ch10 device type disk;
allocate channel ch11 device type disk;
allocate channel ch12 device type disk;
allocate channel ch13 device type disk;
allocate channel ch14 device type disk;
allocate channel ch15 device type disk;
allocate channel ch16 device type disk;
allocate channel ch17 device type disk;
allocate channel ch18 device type disk;
allocate channel ch19 device type disk;
allocate channel ch20 device type disk;
backup as compressed backupset database format='/opt/rpc/scripts/backup/RMAN_TEST/FULL_DB_TEST_24042017_%U' plus archivelog format='/opt/rpc/scripts/backup/RMAN_TEST/Arch_TEST_24042017_%U';
backup current controlfile format='/opt/rpc/scripts/backup/RMAN_TEST/Con_TEST_24042017_%F';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
release channel ch7;
release channel ch8;
release channel ch9;
release channel ch10;
release channel ch11;
release channel ch12;
release channel ch13;
release channel ch14;
release channel ch15;
release channel ch16;
release channel ch17;
release channel ch18;
release channel ch19;
release channel ch20;
}

$nohup rman target / cmdfile=rman_backup.rcv log=rman_backup.log & 

Bước 2: Tạo tệp pfile trên máy chủ nguồn từ tệp spfile, đồng thời chỉnh sửa tệp đó để chỉ sử dụng cho một phiên bản duy nhất.
 
SQL> create pfile='/opt/rpc/scripts/backup/RMAN_Test/initTEST_bkp.ora' from spfile; 
 
Modified file:
 
$ cat initTEST_bkp.ora
 
CLONE.__db_cache_size=6408896512
CLONE.__java_pool_size=201326592
CLONE.__large_pool_size=234881024
CLONE.__pga_aggregate_target=2113929216
CLONE.__sga_target=10502537216
CLONE.__shared_io_pool_size=0
CLONE.__shared_pool_size=3590324224
CLONE.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/CLONE/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='+DATAC1/clone/controlfile/con01.ctl','+RECOC1/clone/controlfile/con02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATAC1'
*.db_create_online_log_dest_1='+DATAC1'
*.db_create_online_log_dest_2='+RECOC1'
*.db_domain=''
*.db_name='CLONE'
*.db_recovery_file_dest='+RECOC1'
*.db_recovery_file_dest_size=214748364800
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=CLONEXDB)'
*.instance_number=1
*.log_archive_dest_1='LOCATION=+RECOC1'
*.log_archive_format='clone_%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=2097152000
*.processes=600
*.remote_login_passwordfile='exclusive'
*.sessions=665
*.sga_target=10485760000
CLONE.thread=1
CLONE.undo_tablespace='UNDOTBS1'

Bước 3: Sao chép các phần sao lưu RMAN ở trên và tệp pfile mới tạo sang máy chủ đích.
(Vị trí sao lưu: /opt/rpc/scripts/backup/RMAN_TEST). Kiểm tra kích thước bản sao lưu trên cả máy chủ nguồn và máy chủ đích.  

Bước 4: Tạo tệp pfile từ tệp spfile cho cơ sở dữ liệu CLONE mục tiêu.

Bước 5: Khởi động cơ sở dữ liệu ở chế độ nomount bằng cách sử dụng tệp pfile vừa tạo.

$env | grep ORA
 
SQL> startup nomount pfile='$ORACLE_HOME/dbs/initCLONE.ora';

Bước 6: Tại máy chủ đích, kết nối với RMAN như một cơ sở dữ liệu phụ trợ và chạy lệnh RMAN duplicate. 
 
$nohup rman auxiliary / cmdfile=rman_restore.rcv  log=rman_restore.log &
 
run
{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
allocate channel ch5 device type disk;
allocate channel ch6 device type disk;
allocate channel ch7 device type disk;
allocate channel ch8 device type disk;
allocate channel ch9 device type disk;
allocate channel ch10 device type disk;
allocate channel ch11 device type disk;
allocate channel ch12 device type disk;
allocate channel ch13 device type disk;
allocate channel ch14 device type disk;
allocate channel ch15 device type disk;
allocate channel ch16 device type disk;
allocate channel ch17 device type disk;
allocate channel ch18 device type disk;
allocate channel ch19 device type disk;
allocate channel ch20 device type disk;
duplicate target database to CLONE
backup location '/opt/rpc/scripts/backup/RMAN_TEST/' nofilenamecheck;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;
release channel ch7;
release channel ch8;
release channel ch9;
release channel ch10;
release channel ch11;
release channel ch12;
release channel ch13;
release channel ch14;
release channel ch15;
release channel ch16;
release channel ch17;
release channel ch18;
release channel ch19;
release channel ch20;
}
 
Bước 7: Bây giờ hãy vô hiệu hóa luồng của nút thứ 2 và xóa các tệp redolog liên quan. 

SQL> alter database disable thread 2;

select INST_ID,GROUP#,STATUS,MEMBER from gv$logfile;
 
INST_ID GROUP# STATUS  MEMBER                                       
------- ------ ------- ---------------------------------------------
      2      2         +DATAC1/test/onlinelog/group_2.927.934140781 
      2      2         +RECOC1/test/onlinelog/group_2.6234.934140781
      2      1         +DATAC1/test/onlinelog/group_1.928.934140781 
      2      1         +RECOC1/test/onlinelog/group_1.6427.934140781
      2      3         +DATAC1/test/onlinelog/group_3.1361.934140887
      2      3         +RECOC1/test/onlinelog/group_3.5647.934140887
      2      4         +DATAC1/test/onlinelog/group_4.1362.934140887
      2      4         +RECOC1/test/onlinelog/group_4.5646.934140887

SQL> select group# from v$log where THREAD#=2;
 
    GROUP#
----------
         3
         4
   
SQL> alter database drop logfile group 3;
 
SQL> alter database drop logfile group 4;
 
Bước 8: Xóa các tablespace hoàn tác đã tạo cho nút thứ 2.

SQL>  select tablespace_name from dba_tablespaces where contents='UNDO';
 
TABLESPACE_NAME
---------------------------------
UNDOTBS1
UNDOTBS2
 
SQL> drop tablespace UNDOTBS2 including contents and datafiles;
 
SQL> select tablespace_name from dba_tablespaces where contents='UNDO';

 
Bước 9: Tạo spfile từ pfile cho cơ sở dữ liệu đã sao chép.

SQL> create spfile='+DATAC1/clone/spfileclone.ora' from pfile='$ORACLE_HOME/dbs/initCLONE.ora'; 
 
Bước 10: Khởi động lại cơ sở dữ liệu để thực hiện thao tác. 
 
Modify the pfile with below entry:
 
SQL> shut immediate; 
 
$cat initCLONE.ora
spfile='+DATAC1/clone/spfileclone.ora'
 
SQL> startup;
 
SQL> show parameter spfile; 
=============================
TƯ VẤN: Click hoặc Hotline/Zalo 090.29.12.888
=============================
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

ĐỌC NHIỀU

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