In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use Java program to call expdp data pump to realize automatic logical backup of Oracle database", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use Java program to call expdp data pump to realize automatic logical backup of Oracle database"!
The complete design process is described below: 1. Preparation
(1) Create directory and operating system directory, configure read and write permissions.
(2) Check that the Oracle instance whose data is scheduled to be backed up is currently read, write.
(3) Manually backup hr users and test whether the expdp command can run normally. I have encountered directory for NFS file system, backup error prompt.
(4) Estimate the space required for backup, using estimate=statistics of data pump expdp| The blocks and estimate_only=y parameters estimate the database backup size.
(5) Check whether the storage space of logical backup is sufficient, you can execute the command df -k or df -h to check.
2. programming
Design Java program, deploy it under a node of Oracle database server (it can be deployed in middleware such as Tomcat, Weblogic, etc., or it can be independently deployed by developers according to specifications), interact with Oracle users of the server, and initiate the backup command of expdp.
Here is an explanation of the timer + log retrieval + status query + message center design pattern, the role of each function:
(1) Status inquiry
The function of status query is to determine whether expdp is still running, query database sql every few seconds through scheduled tasks, view server progress and other ways to confirm, where the time interval can be selected 3 seconds, 5 seconds, etc., short time deviation will not affect the functional experience.
① The program calls sql to query whether the job is still running when expdp is initiated.
② ps -ef | grep expdp |grep job_name Check if Linux system processes exist
(2) Log retrieval design
After the expdp command is executed, check whether the ORA character exists in the export log. If it exists, it means that there is an error message.
(Note: If you want to design more intelligent, you can grab ORA information, call oerr to get error information, and send it to technicians through the message center)
(3) Timer
The timer starts when the program calls the expdp command to the system and stops when the status query confirms that it has been executed. If the expdp process does not stop for more than 1 hour, the program sends an alert message to the technician through the message center.
(Note: The threshold of timeout time can be adjusted according to the actual situation, 30 minutes, 2 hours are OK)
(4) Message Center
Message Center is a set of independent message sending programs, there are many options, here are four commonly used programs:
① The simpler is to return a message to the operation interface and display it on the page;
② Those with low timeliness can choose to call the mail server to send success/failure/alarm emails to relevant personnel;
③ The higher timeliness is to call the API interface of Internet communication software such as WeChat/QQ to push messages to users;
④ The most timely is to send short messages to users 'mobile phones through mobile, Unicom, telecommunications and other operators.
At this point, there should be a rudiment of a program in mind.
However, one thing to note is that the expdp command is best designed to be configurable, and do not hardcode it into the program, otherwise the extensibility and maintainability of the program will be greatly reduced.
3. Preparation of test cases/scenarios
In order to be able to fully test various application scenarios and test convenience, here are some conventions and design some test scenarios/cases.
The agreement reads as follows:
(1) Mount a new 50 MB disk, and the directory backup path points to the disk.
(2) Use the simplest interface operation to return messages.
Test scenarios/cases
(1) success: backup scott user, expdp quickly complete backup, operation interface within 1 minute to display backup success message.
(2) Failure: Fully backup database, backup will report error because disk space is full, and the operation interface will receive backup failure message later.
(3) Failure: After deleting the backup directory directory, backup the scott user, and the operation interface will receive a backup failure message.
(4) Failure: When expdp backs up the database, kill the backup process, and the operation interface will receive a backup failure message.
(5) Failure: When expdp backs up the database, suspend the job, and the operation interface will receive a backup failure message.
(6) Alarm: Change the timer timeout time to 1 minute, fully prepare the database, and the operation interface receives the alarm message after 1 minute.
If readers are interested, they can develop their own WeChat API to push messages, or push mail messages through mail servers.
If you want to send text messages, you need to sign an agreement with the operator. Friends with conditions can test in the company's test environment.
4. Program tuning/BUG fixing
After several rounds of testing, you may find that some parts of the program are not designed reasonably, you may find that the program does not run as expected, and you may also find that the program has BUG errors.
Then the next step, that is, program tuning and BUG repair work, until their own convenience, business use comfortable, development use satisfaction. Come on ~
At this point, I believe that we have a deeper understanding of "how to use Java programs to call expdp data pumps to achieve automatic logical backup of Oracle databases," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.