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)05/31 Report--
This article mainly introduces "how to set automatic startup and shutdown in Oracle 11g system". In daily operation, I believe many people have doubts about how to set automatic startup and shutdown in Oracle 11g system. I have consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to set automatic startup and shutdown in Oracle 11g system". Next, please follow the editor to study!
Setting method of automatic start-up and shutdown of Oracle 11g system
Step 1: set in Linux to allow the ORACLE system to start automatically, because it is not allowed by default.
1. Modify the / etc/oratab file under the root account:
# vi / etc/oratab
Find orcl=/db/app/oracle/product/11.1.0/db_1: n
Changed to: orcl=/db/app/oracle/product/11.1.0/db_1: y
That is, change the last N to Y, which will not allow automatic start to allow automatic start.
two。 Modify the startup and shutdown scripts included with ORACLE, which are dbstart and dbshut, respectively. By executing these two scripts, you can start and shut down the ORACLE script.
Modify the $ORACLE_HOME/bin/dbstart file under the oracle account:
$vi $ORACLE_HOME/bin dbstart
Find the ORACLE_HOME_LISTNER=$1 business.
Changed to: ORACLE_HOME_LISTNER=$ORACLE_HOME
The reason for this step is that when the script is automatically generated, that is, when ORACLE is installed into Linux, the script does not know what your ORACLE_HOME_LISTNER is, and now you need to specify this parameter so that it will not report an error that ORACLE_HOME_LISTNER is not specified when executing the script.
Note: the dbstart and dbshut scripts have incorporated the startup and shutdown of listeners into the startup and shutdown scripts of the database instance after the 10g version, rather than separately.
In the same way, you need to modify this parameter of dbshut. They are no longer written in detail here, they are in the same directory.
Step 2: write a script, register it as a system service, and have it run on and off. Its purpose is to call and execute dbstart and dbshut. In this way, the database is started and shut down.
The script is placed in the / etc/init.d directory, and the name of the script is oracle
The script code is as follows:
#! / bin/bash
# chkconfig: 2345 96 11
# description:Startup Script for oracle Databases
# / etc/rc.d/init.d/oradbstart
ExportORACLE_BASE=/u01/app/oracle/
Export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ExportORACLE_SID=ORDB
ExportPATH=$PATH:$ORACLE_HOME/bin
Case "$1" in
Start)
Echo "- startup oracle-" > > / var/log/oraclelog
Su-oracle-c "$ORACLE_HOME/bin/dbstart"
Touch/var/lock/subsys/oracle
Echo "- startup oracle successful-" > > / var/log/oraclelog
Echo "OK"
Stop)
Echo "- shutdwn oracle-" > > / var/log/oraclelog
Su-oracle-c "$ORACLE_HOME/bin/dbshut"
Rm-f/var/lock/subsys/oracle
Echo "- shutdown oracle successful-" > > / var/log/oraclelog
Echo "OK"
Reload | restart)
$0 stop
$1 start
*)
Echo "Usage:'basename $0' start | stop | reload | restart"
Exit 1
Esac
Exit 0 saves and exits.
Now, I'm going to make a key explanation for this script:
First: # chkconfig: 2345 99 10 is a comment line, but it is a critical essential line, unless you automatically generate symbolic link files without the chkconfig command, but create them entirely by hand. Otherwise, without this line, the system executing chkconfig will report an error that oracle does not have chkconfig service permissions.
Second: the purpose of the lines su-oracle-c $ORACLE_HOME/bin/dbstart and touch / var/lock/subsys/oracle is to first execute the dbstart script to start oracle, and then create a file in the service activity list directory with the same name as oracle, indicating that the service is active, that is, started.
The purpose of the lines su-oracle-c $ORACLE_HOME/bin/dbshut and rm-f / var/lock/subsys/oracle is to first execute the dbshut script to shut down oracle, and then delete the file with the same name as oracle from the service activity list directory, indicating that the service is not active, that is, it has been shut down.
So why touch / var/lock/subsys/oracle and rm-f / var/lock/subsys/oracle? The reason is related to the mechanism of the Linux system: Linux determines whether a service is started based on whether there is a file in the / var/lock/subsys/ directory with the same name as the service. If so, it means that the service has been started. When the system shuts down, Linux will shut down all the services listed in it and delete the files with the same name as the service. If a service is started but there is no file with the same name for that service in this directory, that service will not be shut down.
All the articles on the Internet set this place wrong, so you will find that ORACLE can be started with the system, but not shut down with the system. I also discovered this principle after analyzing / etc/rc.d/rc.local. After the experiment, it was so. Then analyze the startup and shutdown scripts of mysql do the same, and finally suddenly realize. I see. Please pay attention to this place.
Finally, just register the script as a system service in two ways:
One: first assign permissions to the script that can be executed. Execute the following command:
The code is as follows:
# su-root
Chown oracle / etc/init.d/oracle
Chmod 775 / etc/init.d/oracle
Then create a symbolic link file.
Chkconfig-- add / etc/init.d/oracle, to execute this command, you need to write
# chkconfig: 2345 99 10. So when the command is executed, it will look for the comment in the oracle file, and parse the comment, according to the parsing result in / etc/rc.d/rc2.d;/etc/rc.d/rc3.d;/etc/rc.d/rc4.d / etc/rc.d/rc5.d to create a symbolic link file S99oracle file, this file is to be executed when the system starts, in fact, this file points to / etc/init.d/oracle, when starting, the system sends a start parameter to this file, and then executes the start branch in the oracle file.
In addition, a K10oracle file will be created in / etc/rc.d/rc0.d;/etc/rc.d/rc1.d;/etc/rc.d/rc6.d, which will be executed when the system shuts down. In fact, this file also points to / etc/init.d/oracle. When it is closed, the system sends a stop parameter to this file, which executes the stop branch in the oracle file.
I think you understand the meaning of these numbers in # chkconfig: 2345 99 10:
It is pointed out that the service is started at level 2, etc/rc.d/rcN.d 3, 4 and 5, and 99 is the sequence number (startup priority) of the linked file generated under the corresponding / etc/rc.d/rcN.d (N is the previously specified level, here is 2345). 10 the sequence number (priority of service stop) K10oracle of the linked file generated for the / etc/rc.d/rcN.d (N is the level other than 2345) directory corresponding to the level indicated earlier. As for why files and file naming conventions are created in these directories, you need to have a familiar understanding of Linux's system startup process, which is not discussed in detail here.
Second: if you want to try the fun of manually creating symbolic link files, execute the following command:
The code is as follows:
# su-root
Ln-s / etc/init.d/oracle/etc/rc.d/rc2.d/S99oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc3.d/S99oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc4.d/S99oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc5.d/S99oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc0.d/K10oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc1.d/K10oracle
Ln-s / etc/init.d/oracle/etc/rc.d/rc6.d/K10oracle
In fact, the effect of manual operation is the same as that of performing chkconfig-add oracle.
At this point, all the settings are complete, so let's test it:
# cd / etc/init.d
Sh oracle start or service oracle start
After execution, take a look at the oraclelog file in the / var/log directory to see if there is the startup branch output information of the script.
Sh oracle stop or service oracle stop
After execution, take a look at the oraclelog file in the / var/log directory to see if there is a script to close the branch output information.
If you see the message, you have successfully set it. If not, please set it carefully again and pay attention to the permissions of the file.
At this point, the study on "how to set up automatic startup and shutdown of Oracle 11g system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.