In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Oracle Server mainly consists of two parts: Instance and Database. Instance refers to a set of background processes / threads and a shared memory area, while Database refers to a set of physical files stored on disk. This paper starts with how to start the database.
Startup of database
First of all, let's analyze the startup process of the database. The startup of Oracle database mainly includes three steps:
(1) start the database to nomount status
(2) start the database to mount status
(3) start the database to open state.
Let's take a look at the specific process of each step one by one and its meaning.
1. Start the database to nomount state
In the first step of startup, Oracle first looks for the parameter file (pfile/spfile), then creates an instance, allocates memory, and starts the background process according to the settings in the parameter file.
As you can see here, as long as you have a parameter file, you can start the instance (Instance) with it, and this step does not require the participation of any control file or data file.
When creating a database, if there is a problem at this step, there may usually be a problem with the system configuration (kernel parameters, etc.), and the user needs to check whether sufficient system resources are allocated, and so on. Take a look at the process of booting to the nomount state:
[oracle@dbtest dbs] $cd $ORACLE_HOME/ DBs [oracle @ dbtest dbs] $lshc_orcl.dat init.ora initorcl.ora lkORCL orapworcl spfileorcl.ora [oracle@dbtest dbs] $sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Wed May 4 10:36:45 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL > startup nomount;ORACLE instance started.Total System Global Area 1152450560 bytesFixed Size 2212696 bytesVariable Size 922750120 bytesDatabase Buffers 218103808 bytesRedo Buffers 9383936 bytesSQL >
Notice here that according to the contents of the parameter file, Oracle creates the instance, allocates the corresponding memory area, and starts the corresponding background process. When you observe the alarm log file (alert_.log; show parameter dump view path), you can see the startup process at this stage. Read the parameter file, and start the instance with parameters. All the non-default parameters defined in the parameter file will be recorded in the alarm log file:
Starting up:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit ProductionWith the Partitioning, OLAP Data Mining and Real Application Testing options.Using parameter settings in server-side spfile / u01/app/oracle/product/11.2.0/db_1/dbs/spfileorcl.oraSystem parameters with non-default values: processes = 150 sga_target = 176m memory_target = 1104M memory_max_target = 1104M control_files = "/ u01/app/oracle/oradata/orcl/control01.ctl" control_files = "/ u01/app/oracle/flash_recovery_area/orcl/" Control02.ctl "db_block_size = 8192 compatible =" 11.2.0.0.0 "db_recovery_file_dest =" / u01/app/oracle/flash_recovery_area "db_recovery_file_dest_size= 3882M undo_tablespace =" UNDOTBS1 "remote_login_passwordfile=" EXCLUSIVE "db_domain =" oracle.com "global_names = FALSE dispatchers =" (PROTOCOL=TCP) "shared_servers = 5 audit _ file_dest = "/ u01/app/oracle/admin/orcl/adump" audit_trail = "DB" db_name = "orcl" open_cursors = 300 diagnostic_dest = "/ u01/app/oracle"
Then the background process starts in turn:
Wed May 04 10:36:55 2016PMON started with pid=2, OS id=3128 Wed May 04 10:36:55 2016VKTM started with pid=3, OS id=3132 at elevated priorityVKTM running at (10) millisec precision with DBRM quantum (100) msWed May 04 10:36:55 2016GEN0 started with pid=4, OS id=3138 Wed May 04 10:36:55 2016DIAG started with pid=5, OS id=3142 Wed May 04 10:36:55 2016DBRM started with pid=6, OS id=3146 Wed May 04 10:36:55 2016PSP0 started with pid=7, OS id=3150 Wed May 04 10:36:55 2016DIA0 started with pid=8 OS id=3158 Wed May 04 10:36:55 2016MMAN started with pid=9, OS id=3162 Wed May 04 10:36:55 2016DBW0 started with pid=10, OS id=3166 Wed May 04 10:36:55 2016LGWR started with pid=11, OS id=3170 Wed May 04 10:36:55 2016CKPT started with pid=12, OS id=3175 Wed May 04 10:36:55 2016SMON started with pid=13, OS id=3179 Wed May 04 10:36:55 2016RECO started with pid=14, OS id=3184 Wed May 04 10:36:55 2016MMON started with pid=15 OS id=3189 starting up 1 dispatcher (s) for network address'(ADDRESS= (PARTIAL=YES) (PROTOCOL=TCP)) '... Wed May 04 10:36:55 2016MMNL started with pid=16, OS id=3193 starting up 5 shared server (s)... ORACLE_BASE from environment = / u01/app/oracle
Notice here the order in which Oracle selects parameter files:
Oracle preferred the spfile.ora file as the startup parameter file; if the file does not exist, Oracle selects the spfile.ora file; if the first two do not exist, Oracle will select the init.ora file; if the above three files do not exist, Oracle will not be able to create and start instance and Oracle will not be able to start.
You can check whether the database uses the spfile file through the show parameter spfile command in SQL*PLUS, and if the value is not Null, the database uses the spfile file:
SQL > show parameter spfileNAME TYPE VALUE---spfile string / u01/app/oracle/product/11.2.0 / db_1/dbs/spfileorcl.oraSQL >
At this time, you can also view the enabled background from the operating system:
[root@dbtest trace] # ps-ef | grep ora_ oracle 3128 10 10:36? 00:00:00 ora_pmon_orcloracle 3132 10 10:36? 00:00:00 ora_vktm_orcloracle 3138 10 10:36? 00:00:00 ora_gen0_orcloracle 3142 10 10:36? 00:00:00 ora_diag_orcloracle 3146 10 10:36? 00:00:00 ora_dbrm_orcloracle 3150 10 10:36 ? 00:00:00 ora_psp0_orcloracle 3158 10 10:36? 00:00:00 ora_dia0_orcloracle 3162 10 10:36? 00:00:00 ora_mman_orcloracle 3166 10 10:36? 00:00:00 ora_dbw0_orcloracle 3170 10 10:36? 00:00:00 ora_lgwr_orcloracle 3175 10 10:36? 00:00:00 ora_ckpt_orcloracle 3179 10 10:36 ? 00:00:00 ora_smon_orcloracle 3184 10 10:36? 00:00:00 ora_reco_orcloracle 3189 10 10:36? 00:00:00 ora_mmon_orcloracle 3193 10 10:36? 00:00:00 ora_mmnl_orcloracle 3197 10 10:36? 00:00:00 ora_d000_orcloracle 3201 10 10:36? 00:00:00 ora_s000_orcloracle 3205 10 10:36 ? 00:00:00 ora_s001_orcloracle 3209 10 10:36? 00:00:00 ora_s002_orcloracle 3213 10 10:36? 00:00:00 ora_s003_orcloracle 3217 10 10:36? 00:00:00 ora_s004_orclroot 3358 3253 0 10:50 pts/3 00:00:00 grep ora_
If none of these three files exist, Oracle will not be able to start:
[oracle@dbtest dbs] $mv init.ora init.ora.bak [oracle@dbtest dbs] $mv initorcl.ora initorcl.ora.bak [oracle@dbtest dbs] $mv spfileorcl.ora spfileorcl.ora.bak [oracle@dbtest dbs] $lshc_orcl.dat init.ora.bak initorcl.ora.bak lkORCL orapworcl spfileorcl.ora.bak [oracle@dbtest dbs] $sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Wed May 4 10:55:42 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL > startup nomount;ORA-01078: failure in processing system parametersLRM-00109'/ u01 apprenticeships: could not open parameter file'/ u01AccessUniverse productUniverse 11.2.0According to dbAction1anddbsUniplex initorcl.ora'
During the whole startup process of Oracle, the parameter file is the hard code written in the application program. Searching according to the above order can not change the search path and behavior of Oracle, but if the parameter file is not in the corresponding location, on the Linux/UNIX system, it can be relocated through symbolic links.
In the parameter file, the least required parameter is db_name. Once this parameter is set, the database instance can be started. Let's see a simple test:
SQL >! Echo "db_name=julia" > initorcl.oraSQL > startup nomount;ORACLE instance started.Total System Global Area 217157632 bytesFixed Size 2211928 bytesVariable Size 159387560 bytesDatabase Buffers 50331648 bytesRedo Buffers 5226496 bytes
In this way, the Oracle instance is started with minimal parameter requirements.
two。 Start the database to mount state
After starting to the nomount state, Oracle can obtain the location information of the control file from the parameter file. The record of this information in the parameter file is similar to the following. (Oracle creates three control files by default. The contents of these three control files are exactly the same, which is the mirror method used by Oracle for security. In a production environment, it is common to store three control files on different physical hard drives. Avoid damaging 3 control files at the same time due to media failure):
SQL > show parameter control_filesNAME TYPE VALUE---control_files string / u01/app/oracle/product/11.2.0 / db_1/dbs/cntrlorcl.dbf
In the nomount state, you can query the v$parameter view to get the control file information, which comes from the parameter file started. After the database mount, you can query the v$controlfile view to get the message about the control file. At this point, this information comes from the control file:
[oracle@dbtest dbs] $mv init.ora.bak init.ora [oracle@dbtest dbs] $mv initorcl.ora.bak initorcl.ora [oracle@dbtest dbs] $mv spfileorcl.ora.bak spfileorcl.ora [oracle@dbtest dbs] $sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Wed May 4 11:07:07 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to an idle instance.SQL > startup nomount;ORACLE instance started.Total System Global Area 1152450560 bytesFixed Size 2212696 bytesVariable Size 922750120 bytesDatabase Buffers 218103808 bytesRedo Buffers 9383936 bytesSQL > alter database mount; Database altered.SQL > select * from v$controlfile STATUS-NAME----IS_ BLOCK_SIZE FILE_SIZE_BLKS -/ u01/app/oracle/oradata/orcl/control01.ctlNO 16384 594/u01/app/oracle/flash_recovery_area/orcl/control02.ctlNO 16384 594STATUSmuri NAMEMAILUR- -IS_ BLOCK_SIZE FILE_SIZE_BLKS
In the process of mount database, Oracle needs to find the control file and lock the control file. If the entire control file is lost, the following error will be reported:
SQL > alter database mount; alter database mount*ERROR at line 1:ORA-00205: error in identifying control file, check alert log for more info
At this point, more detailed information is usually recorded in the alert.log file.
Because the contents of the three (default) control files in Oracle are exactly the same, if only one or two of them are lost, you can copy the intact control file, change it to the corresponding name, and start the database; if you lose all the control files, you need to restore or rebuild the control file to open the database.
During the process of a normal Mount database, the database alert log file records only the following information:
Alter database mountWed May 04 11:07:44 2016Successful mount of redo thread 1, with mount id 1438756220Database mounted in Exclusive ModeLost write protection disabledCompleted: alter database mount
In this step, the database needs to calculate the Mount id and record it in the control file, and then start Heartbeat (heartbeat), updating the control file every 3 seconds.
Another important file that the database must have when booting to the Mount state is the password file, which is located in the $ORACLE_HOME/dbs directory and is named orapw by default. Store the username and password of the sysdba/sysoper user in the password file:
[oracle@dbtest dbs] $strings orapworcl]\ [ZORACLE Remote Password fileINTERNAL769C0CD849F9B8B25638228DAF52805F [oracle@dbtest dbs] $
Before the database is started, the built-in users of the database can not verify their identity through the database itself. Through the password file, Oracle can authenticate the user, log in before the database is started, and then start the database. For password files, Oracle looks for the orapw file by default, and if it does not exist, it continues to look for the orapw file, and if neither exists, the database will get an error.
If the password file is lost, it can be rebuilt through the orapw tool, so you don't have to include the password file in the usual backup strategy:
[oracle@dbtest dbs] $orapwdUsage: orapwd file= entries= force= ignorecase= nosysdba= where file-name of password file (required), password-password for SYS will be prompted if not specified at command line, entries-maximum number of distinct DBA (optional), force-whether to overwrite existing file (optional), ignorecase-passwords are case-insensitive (optional), nosysdba-whether to shut out the SYSDBA logon (optional Database Vault only) There must be no spaces around the equal-to (=) character. [oracle@dbtest dbs] $
Usually under the Linux/UNIX platform, in the $ORACLE_HOME/dbs directory, there is another file named lk,lk refers to lock, which is created when the database starts and is used by the operating system to lock the database. It is locked when the database is started and released when the database is closed. The content of the file is usually only one line, prompted not to delete, the file is only used for locking.
3. Start the database open phase
Because important messages such as data files, log files and checkpoint information are recorded in the control file, during the open phase of the database, Oracle can find these files according to the information recorded in the control file, and then check the checkpoint and integrity.
If there is no problem, you can start the database, and if there are inconsistencies or missing files, you need to recover.
Further, in fact, during the process of database open, the check performed by Oracle includes the following two items:
Check for the first time that the checkpoint count (Checkpoint cnt) in the data file header is consistent with the checkpoint count (Checkpoint cnt) in the control file. This step check is used to confirm that the data file is from the same version, not from the backup (because the Checkpoint Cnt will not be frozen and will always be modified). Here is a simple test to illustrate the role of Checkpoint Cnt.
If the checkpoint count check passes, the database performs a second check. The second time checks whether the start SCN of the data file header is consistent with the end SCN of the file recorded in the control file. If the end SCN recorded in the control file is equal to the start SCN of the data file header, there is no need to restore that file.
Summary
The above is the whole content of the analysis of the startup phase of the oracle database in this article. I hope it will be helpful to you. Interested friends can refer to: Oracle to create a view with parameters code introduction, Oracle paging query performance optimization code detailed description, oracle virtual private database detailed introduction, thank you for your support. If you have any questions, you can leave a message at any time, and the editor will try his best to give you the answer you want.
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.