Bài viết này sẽ hướng dẫn các bạn cách để Restore Oracle database từ bản backup piece sang 1 server mới (nhân bản CSDL) sử dụng RMAN trong Oracle Database 19c.
Clone database – Restore Oracle Database to New Server using Rman Oracle Database 19c
Cài đặt Oracle database: https://www.blogger.com/blog/post/edit/4187204636885547533/2855932999553439609
CHI TIẾT DB:
Ở đây tôi sẽ sử dụng IP lần lượt là 192.168.68.11 và 192.168.68.12 cho trùng với dải IP của tôi, các bạn cũng có thể đặt theo dải IP thực tế của các bạn.
SRV1 – server tôi đặt là Nguồn nhân bản, đã cài đặt cấu hình DB hoàn chỉnh.
SRV2 – server tôi đặt là DB sau khi nhân bản, chỉ cải đặt Software.
Mục tiêu là nhân bản Database từ SRV1 sang SRV2, không thay đổi thông tin gì về DB name….
Trên 2 SRV: cài đặt hosts file, và hostname như sau
vi /etc/hosts 192.168.68.11 srv1.localdomain srv1 192.168.68.12 srv2.localdomain srv2 trên SRV1: hostnamectl set-hostname srv1.localdomain trên SRV2: hostnamectl set-hostname srv2.localdomain
Ping kiểm tra kết nối giữa 2 host:
ping srv2 -c 5 ping srv1 -c 5
SRV1 + SRV2: Tắt firewall trên cả Source và Target (quan trọng nếu không sẽ không tnsping được) (sử dụng user root)
systemctl stop firewalld.service systemctl disable firewalld.service
SRV1 – Source: Open database và check thông tin sơ bộ, tạo parameter file từ spfile
su oracle cd . .bash_profile sqlplus / as sysdba startup select open_mode, name from v$database; create pfile from spfile;
– Copy password file sang SRV2 target từ SRV1:
exit cd /u01/app/oracle/product/19.3.0/dbhome_1/dbs scp orapwduodb oracle@srv2:/u01/app/oracle/product/19.3.0/dbhome_1/dbs/orapwduodb
– Copy pfile sang SRV2 target từ SRV1:
scp initduodb.ora oracle@srv2:/u01/app/oracle/product/19.3.0/dbhome_1/dbs/initduodb.ora
– Tạo bản babckup database:
mkdir -p /u01/backup sqlplus / as sysdba startup exit rman target / backup database format '/u01/backup/full_db_backup'; backup archivelog all format '/u01/backup/archivelog'; backup current controlfile format '/u01/backup/controlfile';
– Copy backup sang SRV2 target từ SRV1:
SRV2: tạo thư mục backup trên server để lưu file backup piece từ SRV1:
su oracle mkdir -p /u01/backup
Srv1: thực hiện copy (thay tên file theo thông tin file của bạn hiện tại)
cd /u01/backup ls scp archivelog oracle@srv2:/u01/backup/archivelog scp controlfile oracle@srv2:/u01/backup/controlfile scp full_db_backup oracle@srv2:/u01/backup/full_db_backup
SRV2 – Target:
– Tạo đường dẫn cần thiết, tương thích với pfile (xem các đường dẫn cần thiết trong pfile, các đường dẫn phải chính xác và đầy đủ, rất quan trọng nếu không sẽ fail khi duplicate)
su oracle mkdir -p /u01/app/oracle/oradata/DUODB mkdir -p /u01/app/oracle/oradata/DUODB/controlfile mkdir -p /u01/app/oracle/fast_recovery_area/DUODB mkdir -p /u01/app/oracle/archive/DUODB mkdir -p /u01/app/oracle/admin/duodb/adump
– Tạo biến bash_profile môi trường cho DUODB database
cd vi .bash_profile
# User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1 ORACLE_SID=duodb PATH=$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_HOME/bin export PATH ORACLE_BASE ORACLE_HOME ORACLE_SID
– Open Target database trong NOMount State:
cd . .bash_profile sqlplus / as sysdba startup nomount pfile ='/u01/app/oracle/product/19.3.0/dbhome_1/dbs/initduodb.ora' create spfile from pfile; shut immediate startup nomount; !ps -ef | grep pmon
SRV2 – Target: tiến hành restore và recover, thay controlfile_ bằng tên file backup hiện tại của bạn nhé
exit
ls /u01/backup/
-- kiểm tra tên file controlfile backup ở bên trên sau đó đưa vào file bên dưới thực hiện restore lại hệ thống.
rman target /
run {
restore controlfile from '/u01/backup/controlfile';
alter database mount;
restore database;
restore archivelog all;
recover database;
}
alter database open resetlogs;
SRV2 – Target: login vao SQLplus test db
exit sqlplus / as sysdba select open_mode, name from v$database;
[oracle@srv2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 – Production on Thu May 9 12:26:27 2024
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 – Production
Version 19.3.0.0.0
SQL> select open_mode, name from v$database;
OPEN_MODE NAME
——————– ———
READ WRITE DUODB
Restore Database sang New server 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