0% found this document useful (0 votes)
78 views8 pages

8 - Backup Va Restore He Thong

The document outlines backup and restore procedures for databases, processes, gateways, and web/wap/api applications running on two servers (App01 and App02). It describes: 1) Daily automatic full and incremental backups of databases using RMAN scripts with backups stored for 7 days and synced between servers. 2) Daily backups of the process, gateway, and web/wap/api applications on each server using tar files stored for 7 days and synced. 3) Procedures for restoring files, control files, tablespaces, and full databases from backups in failure scenarios, as well as restoring process, gateway, and application files.

Uploaded by

... Pavolusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views8 pages

8 - Backup Va Restore He Thong

The document outlines backup and restore procedures for databases, processes, gateways, and web/wap/api applications running on two servers (App01 and App02). It describes: 1) Daily automatic full and incremental backups of databases using RMAN scripts with backups stored for 7 days and synced between servers. 2) Daily backups of the process, gateway, and web/wap/api applications on each server using tar files stored for 7 days and synced. 3) Procedures for restoring files, control files, tablespaces, and full databases from backups in failure scenarios, as well as restoring process, gateway, and application files.

Uploaded by

... Pavolusa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

BACKUP VÀ RESTORE

Dịch vụ Thuốc

ĐẠI DIỆN TT PTDV – ĐẠI DIỆN CÔNG TY

CÔNG TY VINAPHONE INET

Hà Tài Đức Nguyễn Văn Duy


1. Backup và Restore Database

Trên 2 server sẽ có các thư mục với cấu trúc như sau:

#tree -d /backup/

/backup/

├── db

├── gateway

├── log

├── process

├── scripts

└── web-wap-api

Trong đó

 db/ chứa dữ liệu backup trong 7 ngày gần nhất ( đồng bộ theo server
App02)

 gateway/ là nơi chứa dữ liệu gateway (ko bao gồm log) trong 7 ngày gần
nhất ( đồng bộ theo server App02)

 process/ chứa dữ liệu Process (N và S process) (không bao gồm log)


trong 7 ngày gần nhất ( đồng bộ theo server App01)

 web-wap-api/ chứa dữ liệu (không bao gồm log) trong 7 ngày gần nhất
của web/wap và api (đồng bộ theo server App02)

 scripts/ chứa các đoạn mã thực hiện việc backup / xóa dữ liệu cũ và
đồng bộ.

 log/ ghi lại quá trình backup / xóa và đồng bộ dữ liệu , tiện cho việc tra
cưus

Hệ thống Dịch vụ Thuốc

2
1.1. Backup dữ liệu database trên 2 server App01/02 (192.168.42.170/171)
Hệ thống backup database theo quy trình sau:

B1: Hệ thống backup rman tự động dùng crontab chạy script backup database trên
2 database App01/02, thời gian chạy vào buổi đêm để tránh ảnh hưởng tới performace
chung của hệ thống, cụ thể như sau

 Tên, đường dẫn file dữ liệu backup cho bản backup full trên 2 server (Level 0):
/backup/db/rman/$ORACLE_SID/backupset/yyyy_mm_dd/%U_ DB_BKP_FULL_%S_.bkp
/backup/db/rman/$ORACLE_SID/backupset/yyyy_mm_dd/%U_ ARCL_BKP_FULL_%S_.bkp
/backup/db/rman/$ORACLE_SID/autobkp_ctlfile_%F

Crontab chạy vào 0h30 ngày chủ nhật hàng tuần. Scripts rman có thực hiện nén dữ
liệu, crosscheck, delete expired & obsolete các bản backup, archivelog.

 Tên, đường dẫn file dữ liệu backup cho bản backup incr trên 2 server (Level 1):
/backup/db/rman/$ORACLE_SID/backupset/yyyy_mm_dd/%U_ DB_BKP_INCR_%S_.bkp
/backup/db/rman/$ORACLE_SID/backupset/yyyy_mm_dd/%U_ ARCL_BKP_INCR_%S_.bkp
/backup/db/rman/$ORACLE_SID/autobkp_ctlfile_%F

Crontab chạy vào 0h30 từ thứ 2 đến thứ 7 hàng tuần. Scripts chạy rman có thực hiện
nén dữ liệu, crosscheck, delete expired & obsolete các bản backup, archivelog.

B2: Chương trình rsync tự động đẩy dữ liệu sau khi backup sang server còn lại &
xóa dữ liệu đó trên server local ( dữ liệu backup của App01 lưu trên App02, dữ liệu
của App02 sẽ lưu trên App01).

B3. Hệ thống tự động thực hiện xóa các file backupset lâu quá 7 ngày tại thư mục
lưu file backup rman:
Trên App01: /backup/db/rman/INETDB02/backupset/ (nơi lưu file backup của server App02)

Trên App02: /backup/db/rman/INETDB01/backupset/ (nơi lưu file backup của server App01)

1.2. Khôi phục database trong một số trường hợp.


 Trường hợp lỗi spfile. Thực hiện restore dựa vào bản auto backup control file
gần nhất:

Hệ thống Dịch vụ Thuốc

3
run {

restore spfile from ‘/backup/db/rman/$ORACLE_SID/autobkp_ctlfile_%F’;

 Trường hợp lỗi controlfile. Thực hiện restore dựa vào bản auto backup control
file gần nhất:

run {

restore controlfile from ‘/backup/db/rman/$ORACLE_SID/autobkp_ctlfile_%F’;


}

 Trường hợp lỗi tablespace THUOC, chỉ cần thực hiện recover tablespace theo
giá trị SCN tại thời điểm bị lỗi:

RMAN> recover tablespace THUOC until scn 10537589 auxiliary destination


'/backup/rman/THUOC';

 Trường hợp mất hết spfile, controlfile, datafile,…Cần restore toàn bộ database
theo khoảng thời gian, giá trị sequence, scn,…

run

restore controlfile from '/backup/db/rman/$ORACLE_SID/autobkp_ctlfile_%F';

sql ‘alter database mount’;

set until time “to_date(’08-01-2015 17:30:00’,’dd-mm-yyyy hh24:mi:ss’)”;

restore database;

recover database;

2. Back up dữ liệu process/gateway và web/wap/api


Hệ thống Dịch vụ Thuốc

4
2.1. Backup process trên server App01 (192.168.42.170)

Hệ thống backup theo quy trình sau:


B1. Hệ thống backup tự động dùng crontab chạy
/databackup/scripts/masterbk.sh (1h05 hàng ngày)

Sinh ra file ra file nén tại thư mục /databackup/process/ có dạng


N_ProcessDG-20140727-1913.tar.gz hay S_ProcessDG-20140727-
1913.tar.gz

B2. Hệ thống tự động xóa các file .tar.gz lâu quá 7 ngày tại thư
mục /databackup/process/ để tiết kiệm ổ đĩa

B3. Chương trình Rsync tự động đồng bộ qua thư mục /databackup/process/
trên server App02 .

2.2. Khôi phục process nếu có lỗi xảy ra


B1. Giải nén các Process tương ứng vào folder của chúng bằng câu lệnh (nên
backup folder chứa dữ liệu hiện thời lỗi để tra cứu log về sau)

tar –xvf /databackup/process/ S_ProcessDG-xxxx-xx.tar.gz –C


/home/oracle/ThuocVNP/
hoặc

tar –xvf /databackup/process/ N_ProcessDG-xxxx-xx.tar.gz –C


/home/oracle/ThuocVNP/
Câu lệnh sẽ ghi đè các S và N process tương ứng.

B2. Restart lại các Service tương ứng

N_Process

sudo -u oracle /home/oracle/ThuocVNP/N_ProcessDG/prosms.sh restart


S_Process

sudo -u oracle /home/oracle/ThuocVNP/S_ProcessDG/prosms.sh restart

2.3 Backup gateway trên server App02 (192.168.42.171)

Hệ thống Dịch vụ Thuốc

5
Hệ thống backup theo quy trình sau:
B1. Hệ thống backup tự động dùng crontab chạy /databackup/scripts/slavebk.sh
(1h10 hàng ngày)

Sinh ra file ra file nén tại thư mục /databackup/gateway/ có dạng


Gateway1538-20140727-1915.tar.gz hay Sub_ChargePr-20140727-
1915.tar.gz

B2. Hệ thống tự động xóa các file .tar.gz lâu quá 7 ngày tại thư
mục /databackup/gateway/ để tiết kiệm ổ đĩa

B3. Chương trình Rsync tự động đồng bộ qua thư mục /databackup/gateway/
trên server App01.

2.4 Khôi phục Gateway nếu có lỗi xảy ra


Hệ thống backup theo quy trình sau:

B1. Giải nén các gateway tương ứng vào folder của chúng bằng câu lệnh (nên
backup folder chứa dữ liệu hiện thời lỗi để tra cứu log về sau)

Giải nén SMPPGW:

tar –xvf /databackup/gateway/Gateway1588-xxxx-xx.tar.gz –C


/home/oracle/THUOC_VNP/

Giải nén SubCharge:

tar –xvf /databackup/gateway/Sub_ChargePr -xxxx-xx.tar.gz –C


/home/oracle/THUOC_VNP/
B2. Restart lại các Service tương ứng

SMPPGW:
sudo -u oracle /home/oracle/THUOC_VNP/Gateway1588/trx/smsgw.sh restart
SubCharge:
sudo -u oracle /home/oracle/THUOC_VNP/Sub_ChargePr/insms.sh restart

2.5 Backup web/wap/api trên server App02 (192.168.42.171)


Hệ thống Dịch vụ Thuốc

6
Hệ thống backup theo quy trình sau:
B1. Hệ thống backup tự động dùng crontab chạy /databackup/scripts/slavebk.sh
(1h10 hàng ngày)

Sinh ra file ra file nén tại thư mục /databackup/web-wap-api/ có dạng

 tomcat-20140727-1915.tar.gz

 thuoc_vas151-20140727-1915.tar.gz

 thuoc_vas151-20140727-1915.tar.gz

B2. Hệ thống tự động xóa các file .tar.gz lâu quá 7 ngày tại thư
mục /databackup/web-wap-api / để tiết kiệm ổ đĩa

B3. Chương trình Rsync tự động đồng bộ qua thư mục /databackup/ web-wap-
api / trên server App01.

2.6 Khôi phục web/wap/api nếu có lỗi xảy ra


B1. Giải nén các web/wap/api tương ứng vào folder của chúng bằng câu lệnh (nên
backup folder chứa dữ liệu hiện thời lỗi để tra cứu log về sau)

Giải nén API tomcat

tar –xvf /databackup/web-wap-api/tomcat-xxxx-xx.tar.gz –C /home/

Giải nén Web

tar –xvf /databackup/ web-wap-api/bantinxxx-xxxx-xx.tar.gz –C


/var/www/html
B2. Restart lại các Tomcat và HTTPD tương ứng

API:
Shutdown tomcat:
sh /home/tomcat/bin/shutdown.sh
Start tomcat
sh /home/tomcat/bin/startup.sh
Với WEB và WAP cần restart APACHE:
Hệ thống Dịch vụ Thuốc

7
service httpd restart

Hệ thống Dịch vụ Thuốc

You might also like