In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article takes CentOS 7.6 system and Oracle 11g as an example to teach you how to set up automatic backup of Oracle database every day under Linux.
one。 First find the environment variable of the database
If you are under a root account, you must first log in to the account where the database is located.
Su oraclecat / .bash_profile
Export PATHexport ORACLE_BASE=/home/nnc_db/appexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export PATH=$PATH:$ORACLE_HOME/binexport ORACLE_SID=orcl
The environment variable has been found!
two。 Edit the backed up script file
Vi bak.sh
Copy and paste the environment variables into the bak.sh first
Then define a variable date (its function is to name the files that are backed up every day for easy identification), and use the expdp command to export the database as follows:
Date=$ (date +% Y%m%d) expdp database account / database password @ database instance name dumpfile=$ {date} _ db_auto_backup.dmp schemas= database account name compression=all
Exit save.
three。 Set up scheduled tasks using the crontab command of Linux
Crontab-e
The role of crontab-e is to set up scheduled tasks using a text editor (the specific usage of crontab will not be discussed here)
Enter it in a text editor after input
0 0 * / home/nnc_db/bak.sh
The above code means that the bak.sh pieces under / home/nnc_db executed at 00:00 every day, that is, the files created in step 2, need to be adjusted according to their own backup time and file directory.
Then restart the crond service
Service crond restart
four。 Test whether the task runs successfully
According to the information I collected on the Internet, a friend said that the crontab-e setting will not take effect three minutes after the setting is successful! That is to say, if you set up a task at 10:00 in the morning and want to test whether it can be successful, set the next scheduled task to 10:02, there may be a problem! But here I use
* / home/nnc_db/bak.sh
Set to run every minute, and there is no problem. There is also a novice pit is that you directly run the script file will output a detailed process on the command line, while setting a scheduled task to run is unresponsive! So if you want to see whether your script runs automatically, you need to look at the log file under / var/spool/mail/, as shown in the figure.
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.