当前位置:网站首页>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 .
边栏推荐
- [asp.net core] set the format of Web API response data -- formatfilter feature
- 【sciter Bug篇】多行隐藏
- bat脚本学习(一)
- MySQL related terms
- C# 如何在dataGridView里设置两个列comboboxcolumn绑定级联事件的一个二级联动效果
- Four data streams of grpc
- 插入排序与希尔排序
- Some problems about the use of char[] array assignment through scanf..
- What is the RDD operator in spark
- Unity3d Learning Notes 6 - GPU instantiation (1)
猜你喜欢
![[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials](/img/a5/94bdea3a871db5305ef54e3b304beb.jpg)
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials

GPS from entry to abandonment (XVII), tropospheric delay

GPS从入门到放弃(十七) 、对流层延时
![[daily] win10 system setting computer never sleeps](/img/94/15f5a368e395b6948f409c5f6fc871.jpg)
[daily] win10 system setting computer never sleeps

功能强大的国产Api管理工具
![[asp.net core] set the format of Web API response data -- formatfilter feature](/img/95/b7e7b5e9e9ac1d9295c17640beccb3.jpg)
[asp.net core] set the format of Web API response data -- formatfilter feature

2500个常用中文字符 + 130常用中英文字符

20 large visual screens that are highly praised by the boss, with source code templates!

UNI-Admin基础框架怎么关闭创建超级管理员入口?

Barcodex (ActiveX print control) v5.3.0.80 free version
随机推荐
Mongodb (III) - CRUD
【MySQL】Online DDL详解
Enhance network security of kubernetes with cilium
GPS从入门到放弃(十四)、电离层延时
【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
GPS from getting started to giving up (12), Doppler constant speed
ZABBIX proxy server and ZABBIX SNMP monitoring
Support multiple API versions in flask
Broadcast variables and accumulators in spark
C # realizes crystal report binding data and printing 4-bar code
Force buckle 575 Divide candy
[asp.net core] set the format of Web API response data -- formatfilter feature
JS method to stop foreach
Uni app app half screen continuous code scanning
Realization of epoll reactor model
关于程序员的职业操守,从《匠艺整洁之道》谈起
关于char[]数组通过scanf赋值使用上的一些问题。。
MySQL removes duplicates according to two fields
Huawei has launched attacks in many industries at the same time, and its frightening technology has made European and American enterprises tremble
bat脚本学习(一)