Tóm tắt:
control_files trỏ local
startup nomount bằng PFILE → dùng RMAN restore controlfile vào +DATA_CUST và +RECO_CUST
control_files về ASM → create spfile vào +DATA_CUST
srvctl modify database -d custcloud -p <spfile ASM> → restart và verifyChi tiết:
Dưới đây là runbook chuẩn để chuyển controlfile từ local filesystem vào ASM +DATA_CUST (và mirror sang +RECO_CUST), đồng thời chuyển spfile vào ASM giống DC (đường dẫn kiểu +DATA_GOLD/.../parameterfile/spfile...). Mình viết theo kiểu copy/paste và an toàn cho RAC 11.2.
Điều kiện: ASM (+DATA_CUST, +RECO_CUST) đã MOUNT, bạn có quyền SYSDBA và SYSASM.
0) Chuẩn bị: tạo PFILE tạm từ SPFILE hiện tại (đang ở filesystem)
Bạn đang có spfile:
-
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilecust1.ora
Trên instance đang chạy (cust1):
create pfile='/backupdb/initcust1_migrate.ora' from spfile;
Mở file /backupdb/initcust1_migrate.ora, chỉnh 2 tham số như sau:
*.control_files='/backupdb/control01.ctl','/backupdb/control02.ctl'
(Đảm bảo đúng 2 file controlfile local bạn đang có.)
1) Dừng DB (bắt buộc vì đổi control_files)
shutdown immediate;
2) Startup NOMOUNT bằng PFILE (để DB đọc controlfile local)
startup nomount pfile='/backupdb/initcust1_migrate.ora';
3) Tạo controlfile mới trong ASM bằng RMAN (từ controlfile local)
3.1 Vào RMAN
rman target /
3.2 Restore/copy controlfile sang ASM (2 bản: DATA_cust + RECO_cust)
Cách an toàn nhất: “restore controlfile from … to …” (đọc file local, ghi sang ASM)
shutdown immediate;
startup nomount pfile='/backupdb/initcust1_migrate.ora';
restore controlfile to '+DATA_GOLD/custcloud/controlfile/control01.ctl'
from '/backupdb/control01.ctl';
restore controlfile to '+RECO_GOLD/custcloud/controlfile/control02.ctl'
from '/backupdb/control02.ctl';
✅ Nếu bạn chỉ có 1 file controlfile local (control01.ctl) thì restore cả hai từ cùng 1 nguồn cũng được.
4) Mount DB bằng controlfile ASM (xác nhận OK)
Thoát RMAN hoặc SQL*Plus đều được.
Trên SQL*Plus:
shutdown immediate;
startup mount pfile='/backupdb/initcust1_migrate.ora';
Lúc này DB vẫn đang dùng pfile nên control_files trong pfile chưa đổi sang ASM. Ta sẽ đổi ngay bước kế tiếp.
5) Tạo SPFILE mới trong ASM và trỏ control_files về ASM
5.1 Sửa pfile tạm để control_files trỏ ASM giống DC
Mở lại /backupdb/initgold1_migrate.ora và sửa:
*.control_files='+DATA_cust/custcloud/controlfile/control01.ctl','+RECO_cust/custcloud/controlfile/control02.ctl'
5.2 Tạo SPFILE vào ASM (đúng chuẩn DC)
Trong SQL*Plus (đang MOUNT):
create spfile='+DATA_cust/custcloud/parameterfile/spfilecustcloud.ora'
from pfile='/backupdb/initcust1_migrate.ora';
Bạn có thể đặt tên file bất kỳ. Khi restart, Oracle sẽ dùng chính file này.
DC của bạn là+DATA_cust/custcloud/parameterfile/spfile.256....(OMF). Nếu muốn ra đúng kiểu OMF luôn, có 2 cách:
- tạo bằng RMAN/ASMCMD OMF (khó hơn)
- hoặc tạo tên “tĩnh” như trên, vẫn chuẩn và dùng ổn định.
6) Cập nhật Clusterware để RAC dùng SPFILE trong ASM (quan trọng)
Nếu DB là RAC dùng srvctl, bạn phải set spfile mới:
srvctl modify database -d goldcloud -p "+DATA_cust/custcloud/parameterfile/spfilecustcloud.ora"
Kiểm tra:
srvctl config database -d custcloud | egrep -i "Spfile|Control"
7) Restart DB bằng srvctl (để chắc chắn đọc spfile ASM)
srvctl stop database -d custcloud -o immediate
srvctl start database -d custcloud
8) Verify sau cùng (giống DC)
Vào SQL*Plus:
show parameter spfile;
show parameter control_files;
Kỳ vọng:
-
spfile=+DATA_cust/custcloud/parameterfile/... -
control_files=+DATA_cust/...control01.ctl, +RECO_cust/...control02.ctl
Lưu ý quan trọng (tránh lỗi hay gặp)
- Không thể đổi control_files khi DB OPEN → phải shutdown/startup mount.
-
Nếu ASM “nhạy cảm” (bạn từng gặp ORA-600 ASM I/O path), nên:
-
kiểm tra
asmcmd lsdgtrước, - ưu tiên ghi controlfile vào diskgroup ổn định (thường +RECO_cust) trước.
-
kiểm tra
-
Đảm bảo thư mục ASM tồn tại (ASM “folder”):
-
asmcmd mkdir +DATA_cust/custcloud/controlfile -
asmcmd mkdir +DATA_cust/gcustcloud/parameterfile
-
- Xong hết rồi mới OPEN DB
- Bước 6 không được thì sửa lại file $ORACL_HOME/dbs/initcust1.ora và $ORACL_HOME/dbs/initcust2.ora, nội dung: +DATA_cust/custcloud/parameterfile/spfilecustcloud.ora
TƯ VẤN: Click Here 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