Oracle cainiao's Oracle recovery notes

Source: Internet
Author: User

Recently, the disk space of the Oracle server in the development environment is full, so I began to delete things everywhere and finally delete the files. I started to think about oracle data files again, due to the lack of knowledge about oracle, it also caused a series of oracle errors. Later, after unremitting efforts, oracle finally survived. After the success, you must record the waste of several hours.
Due to the abnormal use, the hard disk space of the oracle server is full, and there is no way to delete things everywhere. It is found that a tablespace is useless but not sure. Therefore, the tablespace has not been modified, instead, data files in the tablespace are directly moved from one disk to another in linux (/data/is mounted to another disk ):
[Root @ localhost ~] # Cp/u01/app/oracle/oradata/sj/sj_test.dbf/data/
[Root @ localhost ~] #Rm/u01/app/oracle/oradata/sj/sj_test.dbf
(Music videos can be used for mobile devices. Please forgive me .)
At this time, I thought that oracle should report errors when using this tablespace, rather than when it is started (ignorance is terrible !)

There is space, so I began to create a model database happily, and the results were not half done!

Oracle is dead!

At this point, you must restart the server:
SQL> Startup 

Useless!

Force restart:
SQL>Startup force;
ORACLE instance started. 

Total System Global Area 1073741824 bytes
Fixed Size 1223540 bytes
Variable Size 197133452 bytes
Database Buffers 868220928 bytes
Redo Buffers 7163904 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 12-see DBWR trace file
ORA-01110: data file 12: '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf' 

Step-by-step restart:
SQL> Startup mount;
SQL> Alter database open;
Alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 12-see DBWR trace file
ORA-01110: data file 12: '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf' 

Dizzy, start online crazy search!

Find an article

Yes, according to B:
SQL>Shutdown immediate;
ORACLE instance shut down.
SQL>Startup mount;
ORACLE instance started. 

Total System Global Area 1073741824 bytes
Fixed Size 1223540 bytes
Variable Size 197133452 bytes
Database Buffers 868220928 bytes
Redo Buffers 7163904 bytes
Database mounted. 

Change the location of the tablespace data file:
SQL>Alter database rename file '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf' to'/data/sourcejoy.com. test. dbf '; 

Alter database rename file '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf'
*
ERROR at line 1:
ORA-01511: error in renaming log/data files
ORA-01141: error renaming data file 12-new file
'/Data/sourcejoy.com. test. dbf' not found
ORA-01110: data file 12: '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf'
ORA-27041: unable to open file
Linux Error: 13: Permission denied
Additional information: 2 

What's going on? File not found? What is no permission?

Exit sqlplus and go to/data/. The file exists. (This is an oracle account)

Try to copy the file back to its original location:
[Oracle @ localhost data] # Cp sourcejoy.com. test. dbf/u01/app/oracle/oradata/sourcejoy.com/
Permission denied! 

Insufficient permissions, dizzy! Next, you must modify the permissions.

Jump back to the root user:
[Oracle @ localhost data] #Su-root
Password: 

After entering the password, start to modify the permission:
[Root @ localhost ~] # Cd/data/
[Root @ localhost data] # Chmod 777 sourcejoy.com. test. dbf 

Return to sqlplus:
SQL>Alter database rename file '/u01/app/oracle/oradata/sourcejoy.com/sourcejoy.com.test.dbf'
2To
3'/Data/sourcejoy.com. test. dbf ';
Database altered. 

Successful!

Open the database!
SQL> Alter database open;
Alter database open
*
ERROR at line 1:
ORA-01113: file 12 needs media recovery
ORA-01110: data file 12: '/data/sourcejoy.com. test. dbf' 

Wipe it!

Baidu:
SQL>Recovery database;
SP2-0734: unknown command beginning "recovery d..."-rest of line ignored.

Endure for the moment, and follow the command here (if not, I plan to swear by the mother !)

SQL> Alter database datafile '/data/sourcejoy.com. test. dbf' online;
Database altered. 

SQL>Alter database open;
Alter database open
*
ERROR at line 1:
ORA-01113: file 12 needs media recovery
ORA-01110: data file 12: '/data/sourcejoy.com. test. dbf' 

The error message is the same as described by this buddy!

SQL>Recover database;
Media recovery complete. 

SQL> Alter database open;
Database altered. 

Successful! 

Lessons learned, experiences, and summary:
1. Don't treat oracle as an idiot. This guy must be the first to know if there is any problem with the database!

2. oracle is profound and profound. You should have a solid understanding of its basic knowledge and common knowledge. Even if you are not a DBA, you will be aware of what you do at ordinary times, it won't be as if I were a headless fly.

3. A lot of oracle operations are not as complicated as you think. Do not be afraid to operate oracle. In fact, it is very gentle. Many oracle operations on the Internet are very complicated. Many things are considered, so it will scare some new oracle beginners, just like the tablespace data files in the mobile oracle database. The online descriptions are all about the startup of the archive mode, these things may be important to the production environment, but it does not matter for beginners or non-DBA programmers to simply consider removing files.

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.