Brief description of Oracle physical storage structure
The database is actually composed of a pile of physical files, mainly including four:
1. control files)
2. Data files (Date files)
3. redolog)
1. Control File
The control file is the root file of the database. It is used to locate database files.
There are:
- The name, DBID, and unique identifier of the database.
- Database creation date
- Data files, redo logs, and archived log files.
- Tablespace information.
- Rman backup
The control file has two purposes:
- Contains some data files and redo files where they are stored. Therefore, without the control file, the database cannot be mounted because it cannot locate the basic data file.
- Some metadata allowed by the database will be recorded in it, such as information about the checkpoint.
Query Control File Information
show parameter control_files;select name from v$controlfile;
Control file
It is actually specified in pfile. It is specified when dbca creates a database.
2. Data Files
The database data is actually stored in the data file ). Generally, it is closely related to tablesapce. A tablespace can contain several data files, but a data file can only be used for one tablespace. Tablespace is a logical concept. Data files are a physical concept.
Query data files
SQL> select name,status from v$datafile;
Data File status
Online, offline, and system are mainly in the first two States: online and offline. offline, data cannot be accessed.
For example, you can run an offline data file.
SQL> alter database datafile '/u01/app/Oracle/oradata/test58/zabbix.dbf' offline;
However, you must note that the data file can be offline only when the archive mode is enabled for db. Otherwise, an error is reported.
ORA-01145: offline immediate disallowed unless media recovery enabled
View error information
SQL> !oerr ora 0114501145, 00000, "offline immediate disallowed unless media recovery enabled"// *Cause: ALTER TABLESPACE ... OFFLINE IMMEDIATE or ALTER DATABASE DATAFILE// ... OFFLINE is only allowed if database is in ARCHIVELOG mode.// *Action:Take tablespace offline normally or shutdown abort. Reconsider your// backup strategy. You could do this if you were archiving your logs.
For more information about the archive mode, see operations in redo log.
3. redo log files
Redo logs are actually very important. redo logs are generally specified during database creation.
SQL> select * from v$log
Enable archive Mode
1. Check whether the archive mode is used:
SQL> archive log list;Database log mode No Archive ModeAutomatic archival DisabledArchive destination /u01/app/oracle/product/11.2.0/dbhome_1/dbs/archOldest online log sequence 36Current log sequence 38
2. Back up the database
3. Edit pfile
LOG_ARCHIVE_DEST="/u01/app/oracle/oradata/test58/archive"
Make sure this directory exists.
4. Start the database, but do not open
Startup mount
5. Enable the archive mode and open the database.
alter database ARCHIVELOG;alter database open;
6. view the status
SQL> archive log list;Database log mode Archive ModeAutomatic archival EnabledArchive destination /u01/app/oracle/oradata/test58/archiveOldest online log sequence 36Next log sequence to archive 38Current log sequence 38