当前位置:网站首页>Oracle control file and log file management
Oracle control file and log file management
2022-07-06 22:09:00 【Mr. Li, a genius】
I can't bear the pain of learning , It's about the pain of life
Articles are constantly updated , You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .
List of articles
One 、 Management of control documents
The control file is oracle One of the physical files , Every oracle Every database must have at least one control file , It records the name of the database 、 The location of the data file . When starting the data instance ,oracle The control file will be located according to the initialization parameters , then oracle The association will be established between the instance and the database according to the control file . The importance of control documents lies in , Once the control file is damaged , The database will not start .
1、 Overview of control documents
The control file is automatically created when the database is created , And it will be updated at the same time when the database changes physically . Ensure that the control documents are available at all times . Only oracle The process can safely update the contents of the control file , therefore , Do not try to edit the control file manually at any time .
2、 Control file creation
When the database is created , According to the initialization parameter file control_files Create a control file . In the later use of the database , If the control file is missing or damaged , You can create a new control file by hand .
The basic syntax for manually creating control files is as follows .
create controlfile
reuse database db_name
logfile
group 1 redofiles_list1
...
datafile
...
maxlogfiles max_value1
maxlogmembers max_value2
maxinstances max_value3
maxdatafiles max_value4
noresetlogsiresetlogs
archiveloginoarchivelog;
The parameters are described as follows .
db_name: Database name .
logfile: Indicates the following defined log group file .
redofiles_list1: List of redo log files in the redo log group 1 Name and path .
datafile: Indicates the following definition data file .
max_value1: Maximum number of redo log files .
max_value2: Maximum number of redo log group members .
max_value3: Maximum number of instances .
max_value4: Maximum number of data files .
The basic steps of creating a new control file are as follows .
1、 Check the names and paths of all data files and redo log files in the database .
2、 Close the database .
3、 Back up all data files and redo log files .
4、 Start the database instance .
5、 Create a new control file .
6、 Edit initialization parameters .
7、 Reopen the database .
1、 Re establishment of control documents
1、 Check the names and paths of all data files and redo log files in the database .
If the database can be opened , Then you can use the data dictionary to obtain the basic information of data files and log files , As shown below .
Use a data dictionary v$logfile Get log file information .
select member from v$logfile;
Use a data dictionary v$datafile Get data file information .
select name from v$datafile;
Use a data dictionary v$controlfile Get control file information .
select name from v$controlfile;
2、 Close the database
If the database is running , Before creating the control file , First of all sys The user login , Close the database .
conn sys/change_on_install as sysdba
shutdown normal
3、 Back up all data files and redo log files .
4、 Start the database instance .
When the backup is complete , Start database , But don't load the database first , This is mainly because if the database is loaded , The control file will be opened at the same time , The purpose of creating a new control file cannot be achieved .
startup nomount
3、 Backup of control files
In the process of daily database maintenance , In order to avoid the database system crash caused by the loss or damage of the control file , The control files need to be backed up frequently . Especially after modifying the database structure , For example, adding data files 、 Delete etc. , Need to back up the control file in time .
The backup control file can be realized by using the following statement .
alter database backup controlfile
There are generally two kinds of backups using this statement , One is to back up in the form of binary files , The other is to back up in the form of text files . Now let's take a look at how to realize the backup of control files .
1、 Back up the control file as a binary file
alter database backup controlfile to 'c:\bak.bkp';
The above code backs up the control file to C Under the root directory , The file named bak.bkp, The file exists in binary form .
2、 Back up the control file as a text file
alter database backup controlfile to trace;
4、 Control file recovery
When the database is damaged due to various conditions , At this time, you can use the backed up files to restore the database . In daily maintenance , There are often two situations , One is control file corruption , Another case is disk failure .
When the control file is damaged , This situation is relatively simple , Just replace the damaged file with the backup file , But shut down the database before copying , And then copy , You need to restart after replication .
5、 Add multiplexed control file
In order to improve the reliability of the database , You can create multiple mirror control files , And they are stored in different disks for multiplexing , In this way, you can avoid the situation that the database cannot be started due to a single device failure , This management strategy is called multiplexing control file . When a disk is physically damaged, the control file is damaged , The database will be shut down , At this point, you can use the control file saved in another disk to recover the damaged control file , Then restart the database , Achieve the purpose of protecting control documents .
Two 、 Redo the management of log files
Redo log files are also called log files , It is to record the daily operation of the system 、 Abnormal behavior files , It is a file containing system information , Include kernel 、 service 、 Applications running on the system, etc . Redo log file is the basic guarantee of database security and recovery , When the database fails , Administrators can back up files based on log files and databases , Restore the crashed database to the state of the last logging .
1、 Overview of redo log files
stay oracle In the database , The redo log file is used to record the data changes caused by various changes made by users to the database , here , The resulting operation will be written to the redo log buffer first , When a user submits a transaction ,LGWR The process writes all redo records related to this transaction to the redo log file , Generate a “ Number of system changes ”,scn It will be saved to the redo log file group together with the redo record , To identify the successful submission of the transaction . If a transaction commits an error , You can find the contents of the database before modification by redoing the records , Data recovery .
2、 Query redo log file information
stay oracl During the daily operation of the database , The database administrator can view the redo log file information , Used to understand the operation of the database . This can be done by querying the data dictionary view v l o g 、 v log、v log、vlogfile and v l o g h i s t o r y Come on real present , through too it People can With check Inquiry Of Letter Rest Such as Next . v log_history To achieve , The information that can be queried through them is as follows . v loghistory Come on real present , through too it People can With check Inquiry Of Letter Rest Such as Next .vlog: Contains information about redo log filegroups .
v l o g f i l e : package contain heavy do Japan Records writing Pieces of become member Letter Rest . v logfile: Contains redo log file member information . v logfile: package contain heavy do Japan Records writing Pieces of become member Letter Rest .vlog_history: Contains log history information .
3、 Redo the creation of log file groups and members
In the daily maintenance of the database , The database administrator can manually add new redo log groups or log files to the database , You can also change the name and location of the redo log file , Or delete the redo log group or its members .
1、 Create redo log filegroup
The grammar is as follows :
alter database add logfile [group] [ Number ]( Log files ) size
In the above statement group Optional , When not choosing , The system will automatically generate a group number , Add 1.
4、 Redo the deletion of log file groups and members
When redoing the log file group , When the member is inappropriate or the storage location is wrong , At this time, you can delete the redo log file group or its members .
1、 Delete redo log member file
Delete redo log file members using the following syntax .
alter database drop logfile member file name
Delete group5 New member file added
alter database drop logfile member 'd:\app\redo05_3.log';
5、 Modify the name or location of the redo log file
In normal use of the database , If you want to change the name or location of the redo log file , You can follow the following steps to modify the redo log file .
1、 Close the database .
2、 Copy or modify the location of the log file .
3、 Start the database instance , But don't open the database , Only load the database .
4、 Reset the name or location of the redo log file .
5、 Open database .
3、 ... and 、 Archive log file management
stay oracle In the database , The redo log file is used to record the data changes caused by various changes made by users to the database . When writing these changes to the redo log file , Generally, there are multiple redo log file groups , Each filegroup has multiple files ,oracle When writing to these redo files , Generally, there are multiple redo log file groups , Each filegroup has multiple files ,oracle When writing to these redo files , It writes to the files in these redo log file groups in a circular way , When the file contents in the last redo log file group are full , The files in the first redo log file group will be rewritten . under these circumstances , How to deal with the contents of the original redo log file , Whether to directly overwrite or save the original records , This is the archive log we want to introduce .
1、 Overview of archive log files
The so-called archive log file refers to when the redo log file is full , Save the contents in a new file , These new file collections are archive log files . But redo log files are not necessarily actively saved to new files , According to the database settings ,oracle There are two logging modes : Archive log mode and non archive log mode . In non archive log mode , The contents of the original log file will be overwritten by the new log contents ; In archive log mode ,oracle First, the original log files will be archived and stored , And it is not allowed to overwrite the original log before archiving .
2、 Query of archived log information
Database administrators can modify archived log files and non archived log files , But first, you need to understand the archived log information . stay oracle in , You can learn some basic information about archived logs by querying the data dictionary , Common data dictionaries are v a r c h i v e d l o g 、 v archived_log、v archivedlog、varchive_dest、v$database etc.
3、 Setting of Archive Mode
By default ,oracle The database is in non archive log mode , That is, when the redo log file is full , Directly cover the contents , The original log record will not be written to the archive log file . according to oracle The application system corresponding to the database is different , The database administrator can switch the log mode of the database between archive mode and non archive mode . Can pass alter database archivelog or noarchivelog Statement to switch the database between archive mode and non archive mode .
The switching steps are as follows :
1、 Close the database
shutdown immediate;
2、 Start the database to the loading state .
startup mount;
3、 Modify the archive mode or non Archive Mode of the database
Archive mode is changed to non archive mode
alter database noarchivelog;
The non archive mode is changed to archive mode
alter database archivelog;
4、 Reopen the database
alter database open;
Four 、 summary
The relevant contents here have not been sorted out yet , The article continues to be updated later , Recommended collection .
The commands involved in the article must be typed several times each like me , Only in the process of knocking can you find out whether you really master the command .
You can search by wechat 【 Xiaoqi JAVA interview 】 First time reading , reply 【 Information 】 Access to benefits , reply 【 project 】 Get the source code of the project , reply 【 The resume template 】 Get resume template , reply 【 Learning Roadmap 】 Get a learning roadmap .
边栏推荐
- [MySQL] online DDL details
- Record the process of cleaning up mining viruses
- 华为在多个行业同时出击,吓人的技术让欧美企业瑟瑟发抖
- LeetCode学习记录(从新手村出发之杀不出新手村)----1
- 小常识:保险中的“保全”是什么?
- [sciter]: encapsulate the notification bar component based on sciter
- GNN, please deepen your network layer~
- MySQL related terms
- From campus to Tencent work for a year of those stumbles!
- What can one line of code do?
猜你喜欢
C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
GPS from getting started to giving up (12), Doppler constant speed
GPS从入门到放弃(十九)、精密星历(sp3格式)
BarcodeX(ActiveX打印控件) v5.3.0.80 免费版使用
关于程序员的职业操守,从《匠艺整洁之道》谈起
Yyds dry goods inventory C language recursive implementation of Hanoi Tower
GPS du début à l'abandon (XIII), surveillance autonome de l'intégrité du récepteur (raim)
嵌入式常用计算神器EXCEL,欢迎各位推荐技巧,以保持文档持续更新,为其他人提供便利
About the professional ethics of programmers, let's talk about it from the way of craftsmanship and neatness
随机推荐
[10:00 public class]: basis and practice of video quality evaluation
Intelligent online customer service system source code Gofly development log - 2 Develop command line applications
PostgreSQL install GIS plug-in create extension PostGIS_ topology
HDU 2008 数字统计
The relationship between root and coefficient of quadratic equation with one variable
插入排序与希尔排序
Kohana database
Record the process of cleaning up mining viruses
Oracle性能分析3:TKPROF简介
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
Maximum product of three numbers in question 628 of Li Kou
What a new company needs to practice and pay attention to
Adjustable DC power supply based on LM317
Sql: stored procedures and triggers - Notes
GPS从入门到放弃(十九)、精密星历(sp3格式)
【sciter Bug篇】多行隐藏
[daily] win10 system setting computer never sleeps
GPS from entry to abandonment (XVII), tropospheric delay
Oracle-控制文件及日志文件的管理
Sparkshuffle process and Mr shuffle process