In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
With the gradual launch of many systems, database backup is particularly important as an operation and maintenance personnel. considering that the current system resources are limited and the database is in non-archiving mode, data pumps are used for full preparation every day, and there are many online backup scripts. I also refer to some scripts on the Internet to share and modify them according to the existing environment.
Original reference link: http://www.osyunwei.com/archives/5960.html
Operating system environment: AIX 7.1.0.0
Database version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit Production
1. Preparatory work
Database creation directory
CREATE [OR REPLACE] DIRECTORY res_productdump AS'/ ogg/productbackup'
Create backup path / ogg/productbackup modify the user and user group to oracle.oinstall
two。 Backup script
First confirm the native shell type:
$echo $SHELL
/ usr/bin/ksh
The content of the script, take Zhejiang Province as an example:
Cat res_zhejiang_bk.sh
#
#! / usr/bin/ksh
Export ORACLE_BASE=/app/oracle
Export ORACLE_SID=resdb1
Export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
Export ORACLE_TERM=xterm
Export PATH=$PATH:$ORACLE_HOME/bin
Export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
# the above code is set by the system environment variable of the oracle user
# get the current date and time of the system
Export BAKUPTIME= `date +% Y% m% d% H% M`
# set to delete backup files 7 days ago
Export DELETE_DAYS=7
# specify directory path
Export BAK_DIR=/ogg/productbackup
# backup province users
Export BAK_USER=res_zhejiang
# specify directory name
Export DIRECTORE_NAME=res_productdump
# perform Zhejiang stock backup
Expdp system/systemres directory=$ {DIRECTORE_NAME} schemas=$ {BAK_USER} dumpfile=$ {BAK_USER} _% Utility ${BAKUPTIME} .DMP logfile=$ {BAK_USER} _ ${BAKUPTIME} .log parallel=4 cluster=no
# compress backup files and log files
Zip-r ${BAK_DIR} / ${BAK_USER} _ ${BAKUPTIME} .dmp.zip ${BAK_DIR} / ${BAK_USER} _ * .dmp ${BAK_DIR} / ${BAK_USER} _ * .log
# delete the backup files and log files of the same day after the backup is completed
Find ${BAK_DIR} / *-type f-name "${BAK_USER} * .dmp"-exec rm {}\; # Delete backup files
Find ${BAK_DIR} / *-type f-name "${BAK_USER} * .log"-exec rm {}\; # Delete log files
# Delete backup files from 7 days ago
Find ${BAK_DIR} / *-type f-name "${BAK_USER} * .zip"-mtime + ${DELETE_DAYS}-exec rm-rf {}\
#
3. The script gives execution permission
$chmod axix res_zhejiang_bk.sh
4. Add execution plan
Open the execution plan
Crontab-e
Crontab: you are not authorized to use cron. Sorry.
Deal with:
Root user actions, adding oracle
Vi / var/adm/cron/cron.allow
Root
Unionmon
Oracle
Use crontab-e to specify the execution plan
00 00 * / home/oracle/scripts/res_zhejiang_bk.sh
# View the execution plan
Crontab-l
5. Verify the backup and view the backup log
If the scheduled task is not performed during the verification process, check the email prompt message:
Email View: more / usr/spool/mail/oracle
Supplement 1: for AIX systems, there is no unzip decompression command by default, as follows
First download the unzip decompression package, personal network disk link: http://pan.baidu.com/s/1qXEDtQO
Or the official website FTP download address: ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/unzip/
Then copy the unzip package under the / app/soft/ path to the / usr/bin path and grant permissions, as follows:
# cp / app/soft/unzip / usr/bin
# chmod 755 / usr/bin/unzip
# chown-R grid:oinstall / app/soft/
In this way, the unzip decompression command of AIX system can be used normally.
Supplement several command subtotals commonly used by 2:unzip
-j parameter: the original directory path in the compressed file is not processed.
-d parameter: specify the decompression path
-t parameter: check whether the compressed file is correct
-v parameter: displays detailed information when executing yes
-o parameter: you do not need to ask the user first. The original file will be overwritten after unzip execution.
-l parameter: displays the files contained in the compressed file
-x parameter: specify which files in the .zip zip file should not be processed
Examples are as follows:
$unzip-j res_zhejiang_201612080000.dmp.zip-d / ogg/dumpfile-if the-j parameter is not specified, the original backup path will be decompressed together
$unzip-t res_zhejiang_201612080000.dmp.zip
Archive: res_zhejiang_201612080000.dmp.zip
Testing: ogg/productbackup/res_zhejiang_01_201612080000.dmp OK
Testing: ogg/productbackup/res_zhejiang_02_201612080000.dmp OK
Testing: ogg/productbackup/res_zhejiang_03_201612080000.dmp OK
Testing: ogg/productbackup/res_zhejiang_04_201612080000.dmp OK
Testing: ogg/productbackup/res_zhejiang_201612080000.log OK
No errors detected in compressed data of res_zhejiang_201612080000.dmp.zip
$unzip-j res_zhejiang_201612080000.dmp.zip-x * .dmp-d / ogg/dumpfile-extract only log log files
Supplement the processing method of database dmp backup on 3.1:AIX7.1 system. Zip compressed file is larger than 2G
Examples are as follows:
$du-sg res_jiangsu_201612080115.dmp.zip
4.89 res_jiangsu_201612080115.dmp.zip
$unzip-l res_jiangsu_201612080115.dmp.zip
Unzip: can't find res_jiangsu_201612080115.dmp.zip, res_jiangsu_201612080115.dmp.zip.zip or res_jiangsu_201612080115.dmp.zip.ZIP, so there.
The reason is that the unzip is 32-bit. The solution is as follows:
Go to IBM website to download bzip2
Http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/date.html
Currently available is bzip2-1.0.6-2.aix6.1.ppc.rpm
Download 64-bit unzip from the PERZL website
Http://www.perzl.org/aix/index.php?n=Main.Unzip
Currently available is unzip-64bit-6.0-3.aix5.1.ppc.rpm
Upload the above two packages to the AIX7.1 server and solve the problem after installation.
# rpm-ivh bzip2-1.0.6-2.aix6.1.ppc.rpm
Bzip2 #
# rpm-ivh unzip-64bit-6.0-3.aix5.1.ppc.rpm
Unzip-64bit #
$unzip-l res_jiangsu_201612080115.dmp.zip
Archive: res_jiangsu_201612080115.dmp.zip
Length Date Time Name
-
4905238528 12-08-2016 01:21 ogg/productbackup/res_jiangsu_01_201612080115.dmp
11686117376 12-08-2016 01:21 ogg/productbackup/res_jiangsu_02_201612080115.dmp
2106 5035776 12-08-2016 01:21 ogg/productbackup/res_jiangsu_03_201612080115.dmp
10216099840 12-08-2016 01:21 ogg/productbackup/res_jiangsu_04_201612080115.dmp
140789 12-08-2016 01:21 ogg/productbackup/res_jiangsu_201612080115.log
--
47872632309 5 files
Supplement situations where a single file in a file is larger than 2G by using the unzip command on a 3.2:AIX7.1 system
If a single file extracted by unzip is larger than 2G, an error will be reported when decompressing. Even if the file is decompressed forcefully, the file is incomplete. The example is as follows:
$unzip-t res_shanghai_201612110045.dmp.zip-backup file check
Archive: res_shanghai_201612110045.dmp.zip
Testing: oracle/productbackup/res_shanghai_01_201612110045.dmp OK
Testing: oracle/productbackup/res_shanghai_02_201612110045.dmp OK
Testing: oracle/productbackup/res_shanghai_03_201612110045.dmp OK
Testing: oracle/productbackup/res_shanghai_04_201612110045.dmp OK
Testing: oracle/productbackup/res_shanghai_201612110045.log OK
No errors detected in compressed data of res_shanghai_201612110045.dmp.zip.
$unzip-j res_shanghai_201612110045.dmp.zip-d / oracle/productbackup/-decompress
Archive: res_shanghai_201612110045.dmp.zip
Inflating: / oracle/productbackup/res_shanghai_01_201612110045.dmp
/ oracle/productbackup/res_shanghai_01_201612110045.dmp: write error (disk full?) Continue? (y/n/ ^ C)
$du-sg res_shanghai_01_201612110045.dmp-check that the extracted dmp file is 2G
2.00 res_shanghai_01_201612110045.dmp
As shown in the solution of supplement 3.1, install the two required software packages.
$du-sg res_shanghai*.dmp
2.85 res_shanghai_01_201612110045.dmp
2.50 res_shanghai_02_201612110045.dmp
0.76 res_shanghai_03_201612110045.dmp
0.02 res_shanghai_04_201612110045.dmp
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.