Thứ Hai, 19 tháng 1, 2026

Nhân bản từ Oracle 2 Node RAC database thành 1 instance

Bước 1: Thêm hai mục sau vào cả máy chủ nguồn và máy chủ đích để thiết lập kết nối TNS giữa chúng.

vi tnsnames.ora

CLONE =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = TCP)
(HOST = 10.75.*.*)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SID = CLONE)
(GLOBAL_NAME = CLONE.WORLD)
)
)

TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = SAP.WORLD)
(PROTOCOL = TCP)
(HOST = 10.5.*.*)
(PORT = 1521)
)
)
(CONNECT_DATA =
(SERVICE_NAME = TEST_SRV)
(SID = TEST)
(GLOBAL_NAME = TEST1.WORLD)
)
)

 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.

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:  Tạo tệp mật khẩu để xác thực từ xa trên cơ sở dữ liệu nguồn.

$orapwd file=orapwCLONE entries=20 password=******

 Bước 4:  Sao chép hai tập tin bên dưới lên máy chủ đích.
  • initTEST_bkp.ora
  • orapwCLONE

 Bước 5:  Thiết lập môi trường cho thao tác sao chép cơ sở dữ liệu trên máy chủ đích.

$export ORACLE_SID=CLONE

$export ORACLE_HOME= /u01/app/oracle/product/11.2.0.4/db_home_11g

$env | grep ORA

 Bước 6:  Di chuyển tập tin pfile đã chuyển như hình bên dưới và khởi động cơ sở dữ liệu ở trạng thái nomount:

$cp /opt/rpc/scripts/backup/RMAN_TEST/initTEST_bkp.ora /u01/app/oracle/product/11.2.0.4/db_home_11g/dbs/initCLONE.ora

SQL> startup nomount;

 Bước 7:  Bây giờ hãy thực hiện sao chép cơ sở dữ liệu RMAN từ phía máy đích.

$env | grep ORA

$nohup rman target sys/***@TEST nocatalog auxiliary sys/***@CLONE cmdfile=rman_duplicate_17042017.rcv log= rman_duplicate_17042017.log &

 
vi rman_duplicate_17042017.rcv

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 database to CLONE from active database 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 8:  Xác minh lệnh sao chép đã được thực thi thành công và kết thúc với kết quả như bên dưới.

contents of Memory Script:

{

Alter clone database open resetlogs;

}

executing Memory Script

database opened

Finished Duplicate

 Bước 9:  Bây giờ hãy vô hiệu hóa luồng của các Instance khác và xóa các tệp redolog liên quan.

SQL> alter database disable thread 2;

SQL> select * from gv$logfile;

INST_ID GROUP# STATUS TYPE MEMBER IS_
-- -- -- -- -- -- -- -- -- -- -- -- -- - -- -- -- - -- -- -- -- -- -- -- -- -- -- 
2 2 ONLINE +DATAC1/test/onlinelog/group_2.927.934140781 NO
2 2 ONLINE +RECOC1/test/onlinelog/group_2.6234.934140781 NO
2 1 ONLINE +DATAC1/test/onlinelog/group_1.928.934140781 NO
2 1 ONLINE +RECOC1/test/onlinelog/group_1.6427.934140781 NO
2 3 ONLINE +DATAC1/test/onlinelog/group_3.1361.934140887 NO
2 3 ONLINE +RECOC1/test/onlinelog/group_3.5647.934140887 NO
2 4 ONLINE +DATAC1/test/onlinelog/group_4.1362.934140887 NO
2 4 ONLINE +RECOC1/test/onlinelog/group_4.5646.934140887 NO

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 10:  Xóa các tablespace hoàn tác đã tạo cho các phiên bản khác.

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 11:  Bây giờ hãy tạo spfile từ pfile.

SQL> create spfile='+DATAC1/clone/spfileclone.ora'  from pfile='/u01/app/oracle/product/11.2.0.4/db_home_11g/dbs/initCLONE.ora';

Bước 12:  Khởi động lại cơ sở dữ liệu để thực hiện thao tác. Chỉnh sửa tệp pfile với mục nhập sau:

SQL> shut immediate;

vi 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