Oracle Architecture (i)

Source: Internet
Author: User
Tags file copy set time dedicated server

(1) Oracle Database Server = instance + databases   Typically, we refer to the system that hosts our core data as a database server, but in a strict sense it is made up of two parts. 1. The instance is composed of a memory structure and a background process.    Whenever an instance is started, a shared memory area called the system Global Area (SGA) is allocated and a background process is started. 2. The database includes physical and logical structures. Because physical and logical structures are separate, managing the physical storage of data does not affect access to the logical storage structure.  (2) Connect to database 1) connection: Communication between the user process and the instance can be seen as a physical path.  2) session: A specific connection that a user makes to an instance through a user process can be viewed as a logical communication interaction between the user and the server. 0, one, or more sessions can be established on a connection. Each session is separate and independent.  (3) User process and server process interaction ① starts an instance on a node that has Oracle DB installed (often called a "host" or "Database Server"). ② user launches an application that derives a user process.  The application attempts to establish a connection to the server (this connection may be a local connection, a client/server connection, or a three-tier connection from the middle tier).  The ③ server runs a listener listener with the appropriate Oracle NET Services handler detects the connection request made by the application and creates a dedicated server process that represents the user process. The ④ user runs a DML-type SQL statement and commits the transaction. For example, the user changes the customer address in the table and commits the change ⑤ the server process accepts the statement and checks whether the shared pool contains the same SQL statement as the shared SQL region. If a SQL region is found, the server process checks the user for access to the requested data and processes the statement using the existing shared SQL zone.  If a shared SQL region is not found, a new shared SQL region is assigned to the statement for parsing and processing.  The ⑥ server process retrieves any required data values from the actual data files (tables) or values stored in the database buffer cache. The ⑦ server process modifies data in the SGA. Because four or five processing is committed, the log write process (LGWR) immediately logs the transaction to the Redo log file.  The database write process (DBWN) writes the modified block to disk permanently when it is executed efficiently. ⑧ If the transaction succeeds, the server process sends a message over the network to the application.  If the transaction is unsuccessful, an error message is sent. ⑨ throughout the process, other background processes are running at the same time to monitor for situations where intervention is required. In addition, severalThe library server manages transaction processing for other users and prevents contention between transactions that request the same data.                (4) Memory structure detailed   PGA (program Global Area): Process global Zone, which is proprietary to each service process, background process, and each process has a PGA.    A memory area that contains data and control information for a server process or background process. SGA: System global Area, shared by all service processes and background processes.  Contains data and control information for a single Oracle DB instance.    Mainly contains the following data structure 1) database buffer cache (Database Cache): a copy of the data block read from the data file. The Oracle DB user process searches for data in the database buffer cache when a specific piece of data is needed for the first time. If the process finds data in the cache (called a cache hit), the data is read directly from memory. If the process cannot find data in the cache (known as a cache miss), the data blocks in the data file on the disk must be copied to the buffer in the cache before accessing the data.  Cache hits are faster when accessing data than when the cache misses. 2) Redo log buffer (redo log buffer): Cyclic buffers that hold information about changes made to the database, including redo entries that contain information about important changes made by operations such as DML and DDL.  If necessary, the redo entries are used for database recovery.  3) Shared pool: used to cache a variety of structures that can be shared among users, including libraries that tell the cache, data dictionary caches, SQL query results telling the cache, the results of a PL/a function cache, and the buffers that execute the message and the control structure.  4) Large pool (large pool): An optional region that provides large memory allocations for some large processes, such as Oracle Backup and restore operations, I/O server processes, session memory for shared servers, and Oracle XA interfaces (used when transactional processing is interacting with multiple databases).  5) Java pool: Used for all session-specific Java code and data in the Java Virtual Machine (JVM). 6) Streams pool (Stream pool): Oracle streams uses it to store the information needed to capture and apply operations. (5) Process architecture The processes of the Oracle DB System are divided into two groups: 1. User processes running the application or Oracle Tool code 2. Oracle running Oracle DB Server codeDB processes (including server processes and background processes)   When a user runs an application or Oracle tool (for example, Sql*plus), Oracle DB creates a user process to run the user's application. Oracle DB also creates a "server process" to execute commands issued by the user process.  In addition, the Oracle server creates a set of "background processes" for the instance that not only interact with each other, but also interact with the operating system to manage the memory structure, write data to disk asynchronously by performing I/O operations, and perform other required tasks.     Process structure diagram

1) Server process

Reference: Http://blog.csdn.net/sunansheng/article/details/51281605?locationNum=4&fps=1

: http://www.cnblogs.com/lamiyiyi/p/lamiyiyi_oracle.html

Oracle DB creates a server process to handle requests for user processes that connect to the instance. In some cases, when the application and Oracle DB are operating on the same computer, the user process and the corresponding server process can be combined into a single process to reduce the overhead of the system. However, when the application and Oracle DB are running on different computers, the user process always communicates with Oracle DB through a separate server process.

Server processes created on behalf of each user's application can perform one or more of the following actions:

① parses and runs the SQL statements that are emitted by the application.

② reads the necessary chunks of data from the data file on the disk into the shared database buffer of the SGA (if the corresponding data block is not currently in the SGA).

③ returns the result so that the application can process the information.

2) Background process

    1.database write--Data Write Dbwn

    

Effect: Synchronizes the modified data in the SGA to a disk file. Ensure that there is sufficient number of free blocks in the buffer cache.

PS: If the LGWR fails, DBWR will not obey the CKPT command strike, because Oracle writes the data buffer data to the disk, the log buffers will be written into the log file operation, and patiently wait for its first to complete, to complete the memory brush to disk action, This is what is called a record of everything.

Trigger condition: 1, checkpoint ckpt trigger DBWN process.

2, a service process did not find the free block within the set time

3, automatically wake up every three seconds

For a large database or a system with very frequent modifications, only one DBWN process can serve the write operations of all data files and may be overwhelmed. As a result, Oracle allows multiple dbwn processes to be run concurrently to offload heavy write loads. This is the origin of N in Dbwn. A maximum of 20 dbwn processes (n from 0~9, a~i) can be used in the database. The database initialization parameter db_writer_processes is used to define the number of dbwn processes. If this parameter is not defined, Oracle defaults to the number of processes required depending on the amount of CPU. Each of the 8 CPUs is assigned a process.

Oracle recommends that you consider using asynchronous IO before increasing the number of dbwn processes, with the possibility that asynchronous IO will solve the problem without increasing the number of processes.

Settings: Db_writer_process is used to define the number of dbwn processes. (The commit command simply writes the record modification to the log file, instead of writing the modified data to the data file)

    2.log write:--log File write lgwr

    

Role: The role of the LGWR process is that the log contents in log buffer are written to the online log file, freeing the log user buffer space. All modifications to the database (add, delete, change) generate logs that are first saved in Redo log Buffer and then written to the online log file of the disk at some point by the LGWR process.

Trigger condition: 1, the user issued a commit command. (called Fast commit in Oracle): Writes a record in redo log buffer to a log file and writes a committed record

2, every three seconds to wake up regularly;

3, if the use of the Log Buffer exceeds the configured 1/3, that is, 1/3 full will trigger the LGWR write operation;

4, log Buffer in the number of logs more than 1MB, that is, the 1MB limit will also trigger LGWR write operations;

5, online log file switching will also trigger LGWR;

6. DBWR Process trigger: DBWN View writes dirty chunks to disk first detects if his related redo records are written to the online log file, and if not, notifies the LGWR process. Become an advance write mechanism in Oracle (write ahead): Redo records are written to disk before data records.

(1) write ahead.

Oracle uses the advance write (write-ahead) mechanism, that is, the redo record associated with a block of data must be logged to disk before the data block itself. This means that when the DBWN process attempts to write a dirty chunk to disk, the DBWN process will first determine that all redo records associated with the Block have been written to the online log file, and if this precondition is not met, the DBWN process will notify the LGWR process and wait for After the LGWR process has written all the relevant logs, the DBWN process then writes the data block contents to the disk file.

(2) Quick submission.

Whenever a user issues a Commit command, Oracle simply writes the records in redo log Buffer to the log file, and writes a record (commit record) that represents the transaction that was committed in the log. But the data blocks modified by this firm will not be written to the data file. Or Oracle's definition of the success of the commit operation is this: as long as the transaction's Redo record is written to the log file, the transaction is a successful commit, as to whether the transaction modified data is recorded in the data file has no relationship. This is the fast commit mechanism for Oracle.

write Ahead (write Ahead) and Quick commit (fast commit) are Oracle's two important operating mechanisms that ensure that transactional commits do not have to wait for data to be written to disk, and that this mechanism is used to balance performance and The use of sexual results.

For a busy OLTP system, there will be a large number of transactions at the same time, so there will be a large number of commit requests at the same time, the LGWR process can write many commit requests in bulk to the log file, rather than for each commit request processing immediately, this mechanism is called Group Commit.

3.checkpoint:--Checkpoint Event CKPT

    


Role: "Checkpoint" is a data structure that defines the system change number (SCN (System or system commit) in the redo thread of the database. Checkpoints are recorded in the control file and in each data file header, which are key elements of the recovery operation. At the time of the detection point, the content of the data file is consistent with the content in the SGA, which is not a separate process and works with the first two processes. DBWR writes dirty data while triggering the LGWR process, while the CKPT process is only responsible for updating the checkpoint record in the control file, its task volume is not as onerous as the dbwn process and the LGWR process.

Note: The data consistency that the checkpoint represents and the transaction isolation level say read consistency is not a concept, and the latter is from a data integrity perspective. The data of the checkpoint is identical to the data of the memory and the disk, it is from the point of view of recovery, the two must not be confused. Although there are many uncommitted transactions in the system at checkpoint time, the modified dirty data may eventually be committed, permanently valid, and may be rolled back to revert to the pre-modified look, but this is not the checkpoint's concern. The checkpoint only cares if the recovery operation can begin at this point.

CKPT update the checkpoint record in the control file. Control the trigger time of the CKPT by setting a parameter adjustment.       The parameter is fast START MTTR TARGET. Trigger condition: Log switch will trigger a checkpoint. 4.system monitor:--Instance Maintenance Process System Monitor Smon     

If the database is unexpectedly closed, the SGA has not yet written to the disk information is lost, the database starts again, the first to restore work, this recovery is called instance recovery (Instance Recovery). The Smon process is responsible for instance recovery, and the instance recovery is divided into 3 stages.

Roll Forward: This stage reads the online log, finds the log contents after the last checkpoint, and re-logs the database to the state when the last instance was closed, when the system contains committed and uncommitted transactions.

Open the database: To reduce user wait time, Oracle chooses to open the database as early as possible, open the database, and resume work. The database is now available to users.

Rollback (Roll back): The Smon process rolls back uncommitted transactions, and Server process can also perform partial rollback .

In addition to instance recovery, the Smon process is also responsible for some of the space management work, including:

If you use the dictionary management Tablespace (DMT), the Smon process needs to merge idle extents to avoid disk fragmentation, a function called COALESCE, which executes every 3 seconds;

The Smon process is responsible for clearing the temporary segment to free up space;

Trigger condition: The Smon process is also periodically awakened or actively awakened by another process

    5.process monitor:--Maintenance User Process Process Monitor Pmon

    

Role: 1, the discovery of the user process abnormally terminated, and to clean up. Frees up resource usage. (Clean up the lock used by the user to terminate the exception)

2, to the listener dynamic registration instance.

Trigger Condition: The timer is awakened, and the other process will actively wake it.

    6.Distributed database Recovery:--for the recovery of distributed databases RECO

    

    Role: An application spans multiple databases, requires both commits to succeed, the transaction succeeds, or all rolls back

    7.archive:--Archive Operation ARCn

    

Role: The archive (archiver) process is responsible for archiving the archive mode of the database. We know that every database has to create at least two sets of online logs that are recycled, that is, when a set of logs is full, LGWR switches to another set of logs to continue writing. Therefore, the early generation of the log will eventually be overwritten by the new log, which is non-archival mode. While the archive mode is more than the non-archive mode of processing is, in the event of log switchover, the ARCn process is awakened, the log is filled with a file copy, the copy is saved to a special directory-archive directory, this copy is called the archive log. The prerequisites for each online log to be overwritten are correspondingly one more, and the archive must be completed in addition to completing the checkpoint.

The archive mode is to ensure that all database operations logs are retained, which maximizes the recoverability of the database.

ARCN process is to complete this copy action, and the DBWN process, the ARCN process can have multiple, up to 10 (n value range is 0~9). The initialization parameters of the database log_archive_max_processes the number of ARCN that are running when the database starts.

Trigger condition: The log switch is LGWR awakened.

   8.LCKn is available only for RAC databases and can have up to 10 processes (LCK0,LCK1,...,LCK9) for blocking between instances.

Oracle Architecture (i)

Related Article

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.