Day03_ starting and shutting down the database

Source: Internet
Author: User

############# #启动 ##############
1. Nomount mode "load instance and spfile (parameter file)"

What is an instance? Example is if you go to install Oracle, or run a platform Oracle, run the library, the first hardware resources have a certain occupation, for example, the most important is memory, load instance of memory has a certain occupation, If I occupy 1G of memory, this 1G of memory will be used for other programs?? The answer must be no, only the library can use it. Hardware resources are well under the instance. And you open the database. There are some basic processes that are initiated under the instance.

Like in life you want to build a house, can you cover it casually? The 1th thing is you want to buy a piece of land, then build a house to marry a daughter-in-law. The first thing you have to do is to have a homestead, then build a house on the block before you get married. This land is an example, the house you build is the library, and the person you live in is the data.




Path: CD $ORACLE _home/dbs

Views: Strings SPFile instance. Ora "It is not a text file, it is a binary file"
Strings Spfile$oracle_sid.ora
ecom.__db_cache_size=188743680   Data cache size ecom.__java_pool_size=4194304     Java pool size Ecom.__large_ pool_size=4194304     "Large pool size" ecom.__shared_pool_size=83886080     "Shared pool Size" ecom.__streams_pool_size =0           "Stream pool Size" *.audit_file_dest= '/oracle/app/admin/ecom/adump '   "Audit file storage Path" *. background_dump_dest= '/oracle/app/admin/ecom/bdump ' process capture file storage path *.compatible= ' 10.2.0.1.0 '   ' Current library version number '. Control_files= '/oracle/app/oradata/ecom/control01.ctl ', '/oracle/app/oradata/ecom/control02.ctl ', '/oracle/app/ Oradata/ecom/control03.ctl ' "Control file path" *.core_dump_dest= '/oracle/app/admin/ecom/cdump ' "core capture file storage path" *.db_block_size =8192 "Block Size" *.db_domain= "       " Domain name word "*.db_file_multiblock_read_count=16" up to how many blocks can be read at a time "*.db_name= ' Ecom '   ' Library name ' *.db_recovery_file_dest= '/oracle/app/flash_recovery_area ' "Flashback zone" *.db_recovery_file_dest_size= 2147483648   "Flashback zone Size: 2147483648/1024/1024/1024=2g" *.dispatchers= ' (protocol=tcp) (service=ecomxdb) ' "Open TCP network protocol, the number of "*.job_queue_processes=10  " working processes that are related to the listener, the number of cursors on the background of the scheduled task "*.open_cursors=300" *.pga_aggregate_target= 94371840 "PGA Size" *.processes=150   "maximum number of processes turned on" *.remote_login_passwordfile= ' EXCLUSIVE '   "How to login Authentication" *.sga_ target=285212672   "SGA size" *.undo_management= ' AUTO '   "Uodo table space Management" *.undo_tablespace= ' UNDOTBS1 ' "current rollback table space" *.user_dump_dest= '/oracle/app/admin/ecom/udump ' "User capture file storage path"



2. Mount load control file (record data file and log file location)
You go to mount state and load the control file to load the log files and control files back.
Control file path: cd $ORACLE _base/oradata/$ORACLE _sid/View: Strings Control01.ctl
Data file and log file path table space names


Oracle Single-instance single-Library, one instance can only create one library MySQL single instance multi-Library



Some companies have special requirements: A server multi-library, then how to build? Can build multiple instances, Oracle believes that if you build multiple libraries in one instance, hardware resources can not be allocated, hardware resources are loaded instance allocation, your number of processes, memory consumption, cache consumption, then I ran an instance of 10 libraries, I now have 1G of memory, how do I allocate? My average allocation? That's not right! By the order of the points? It's not right! There are resources to compete! So, you Oracle Big Library job is busy, for resource allocation problem, it developed into a single-instance single-Library.
MySQL may be less of a requirement for nature, and it can be made into an instance to run multiple libraries.
But some companies, some special needs, I have some small library, I ran on a high-end server, the cost is high, I want to run multiple libraries on a server. You can build a few more instances, of course an instance or a library,





3. Open load log file and data file
All the databases will have log files, log files record all your actions, through the log to ensure the integrity of your database. Data files, the tables we build, the data inserted into the table, are all inserted into the data file at the operational level.
Path: cd $ORACLE _base/oradata/$ORACLE _sid/

The above is a database start-up process.




Window 1sql> shutdown immediate;
CD $ORACLE _base/admin/$ORACLE _sid/bdump
Tail-f-N-alert_$oracle_sid.log "Some changes to ORACLE will be placed in the alert log to verify the startup process"


Window 2sql> Startup



############# #关闭 ##############
There are 4 ways to close a database:
Shutdown normal needs to wait for all transactions/processes to close to close the database "strictly forbidden, but no one with" shutdown transactional need to wait, but in the process of waiting, the idle transaction process is automatically closed, the active and other people to work, and then close.
"The above 2 kinds of closed way, my session is not disconnected, I write data in the inside, but did not submit, then it can not shut down the database, there is no active session is not over, it waits for the active session to end, to close the library you want in the production environment, you can constrain user behavior? You can't constrain user behavior, you can't say I want to close the library, you and the user said you don't write data. So the above 2 kinds of basic rarely used. 】

Shutdown immediate close before synchronizing the data "synchronization of the synchronization data, no synchronization will be released, for your current operation, it will tell you failed" (production shutdown database commonly used)



Give a life example:
Normal: The bank 5 o'clock off work, 5 o ' clock when there are 10 people there is a number, has not handled the business yet. The normal bank at 5 o ' clock, security will be the bank door will be closed, only a side door, security stand at the door said can not come in, we work. We Guanqu also, no matter which of the 3 modes, the 1th step outside of the new request, it does not accept, because it to close the library, but there are 10 people holding the number, no business, then how to do? You can't just leave the door open, you have to wait, wait for the 10 people to finish the business, you can close the door. It may close 5 o'clock, maybe 6 o'clock to work, because there are many people inside.


Transactional: Also 5 o'clock work, security closed the door, the hall 10 people have number, but there are some people to do business with others, but also some old lady walking tired, and then in the bank, cool, and other people's, about good one place, and then each other late, I did not stay, I sit in the bank, these people are not to do business, belong to the idle conversation or process, security guard in advance to the idle to clean out. It might be close 5 o'clock, maybe 5:50, and better than that.

Immediate: The same is 5 o'clock work, security door closed, Hall 10 people have number, at this time just 5 o'clock window on someone in the business, the normal processing completed. The rest of the 10 waiting for the people, security to clear away, said you will come to normal tomorrow morning, your number is also useful, you are in front of the first processing. So it may close 5 o'clock, maybe 5 o ' clock 10.
of the above 3 kinds, the 3rd way to close the fastest ah. The data is not lost in this way.

Dml:select Insert Update Delete "Oracle for rigor, insert update delete operation, to add a commit to take effect (open 2 windows, no commit operation, for example)"
Customer operation completed, a commit operation, transfer to the server side, first write in memory, and then write to the hard disk, because the memory of the data easily lost. Customer operation completed, no commit operation, transmission to the server side, first written in memory, and now I reboot, these operations did not commit, it is invalid.


Window 1insert operation, not commit; window 2shutdown normal; "Stuck still."

Example: Window 1insert operation, not commit; window 2shutdown immediate; "The submitted data is synced to the disk, but no submitted data is dropped directly. No data loss, it will tell you that the operation failed. 】


Shutdown abort force shut down the database is equivalent to a power outage (it is the fastest, this action is very dangerous, easy to lose data) is also 5 o'clock off, the hall 10 people have number, at this time, just 5 o'clock window on someone in the business, security cut off the electricity stopped, Then an electric stick will beat the 15 people who handle the business, and then close the door, no matter what.








Start the database
Startup direct hit this command the default option for open directly opens the database startup Nomount only launches the instance (Mount instance and open parameter file)
Startup Mount Mount Database (Mount instance and open control file, activate certain functions, user cannot access database to perform instance or data recovery processing)
ALTER DATABASE mount changes the databases from the Nomount state to the Mount state by changing the database open (the database is now read and written) ALTER DATABASE open Read only Open to read-only status (very rarely used)
Startup force Restart database "shutdown abort first, then startup, no use in production, especially dangerous"



----------------------------------------------------------
Production shut-down: some elder brother directly in the operating system directly reboot, so the operation of the library is prone to problems, unable to resume normal shutdown process: 1, close application 2, view database backup 3, normal off listening 4, normal Guanqu shutdown immediate "if particularly slow, you can write script implementation "5. Restart the operating system




From for notes (Wiz)

Day03_ starting and shutting down the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.