Linux platform mistakenly delete home Oracle root directory solution

Source: Internet
Author: User
Tags dba sqlplus



1 Background notes

Normally, when we install an Oracle database, we create an Oracle user. Its root directory is/home/oracle.

and according to Oracle's OFA architecture, it is also recommended to use directories such as/U01 to install Oracle software separately, including data files.

Refer to the following connection for OFA:

Oracle OFA ( Optimal Flexible Architecture ) Description

http://blog.csdn.net/tianlesoftware/article/details/7086104

But in fact, there are always a few databases that are not created and managed in accordance with the recommendations of the official website, and have seen too many years. Dave has been recommending strict compliance with Oracle's standards, because this is a common standard, and if every company has its own standards, then every substitution management will be cumbersome and prone to problems.

As the saying goes: Iron camp, running water soldiers, DBAs always have fluctuations in the position, the rules are not the same, will bury the pit, as for the last who stepped on, is the character.

Last night a friend came up with this problem, single-instance database, non-archive, no backup. Delete the entire/home/oracle directory, if it is in accordance with OFA, this is not very serious things, the key is/home/oracle under a few data files, tossing for a long time, the data restored.

Immediately on the new year, fire, anti-theft, anti-down library, incredibly also committed such a low-level error, this is not want the year-end award of Rhythm Ah, this does not say, DBA is a cautious of life, need to slowly experience.

This blog mainly look at the mistake of deleting the/home/oracle directory solution. This does not involve data file recovery issues, later in the collation.

2 Linux User creation instructions

When we install the Oracle database, we create users and groups.

Oracle Installation Reference:

Oracle Installation documentation for 64-bit Linux platforms

http://blog.csdn.net/tianlesoftware/article/details/6062816

Groupadd Oinstall

Groupadd dba

Groupadd Oper

USERADD-G oinstall-g dba Oracle

This is created with the command of Linux. As with database creation, we typically create instances through Oui, which can be created in a quiet way.

So before we talk about this failure process, we need to understand how Linux manually creates users and groups.

Each user's creation involves the following files:

/etc/passwd (user)

/etc/group (user group)

/etc/shadow (key file)

/home/username (home directory)

/etc/skel/.* (skeleton file)

When the user is created, the user's information is added to the/etc/passwd,/etc/group,/etc/shadow three files, a user root directory is created under/home, and all skeleton files are copied to the user's root directory.

[Email protected] ~]$ Cat/etc/passwd|grep Oracle

Oracle:x:502:507::/home/oracle:/bin/bash

[Email protected] ~]$

[Email protected] ~]$ Cat/etc/group |grepoinstall

oinstall:x:507:

[[email protected] ~]$ Cat/etc/group |grep dba

Dba:x:502:oracle

Asmdba:x:506:oracle

[Email protected] ~]$

[Email protected] ~]# Cat/etc/shadow |grep Oracle

Oracle:$6$7xde3zwd$jonusztwfdwor9jmvr33iijhdj/vgncl5xgpcembx3xpiov0nnxrbvdihflbtwpzxsnz.hbqeoit7paxuf9r70 : 15595:0:99999:7:::

[Email protected] ~]#

When we delete/home/oracle this user's root directory, the user's configuration information also exists in the system configuration file, so only need to restore skeleton files, modify the environment variable information, you can.

3 Example

--Database normal operation:

[Email protected] ~]$ Ps-ef|grep ora

Root 1388 1347 0 Aug26? 00:00:37 Hald-addon-storage:polling/dev/sr0 (every 2 sec)

Oracle 9946 1 0 00:49? 00:00:05 Ora_pmon_dave

Oracle 9948 1 0 00:49? 00:00:11 Ora_psp0_dave

Oracle 9950 1 2 00:49? 00:16:17 Ora_vktm_dave

Oracle 9954 1 0 00:49? 00:00:01 Ora_gen0_dave

Oracle 9956 1 0 00:49? 00:00:01 Ora_diag_dave

Oracle 9958 1 0 00:49? 00:00:01 Ora_dbrm_dave

Oracle 9960 1 0 00:49? 00:00:14 Ora_dia0_dave

Oracle 9962 1 0 00:49? 00:00:01 Ora_mman_dave

Oracle 9964 1 0 00:49? 00:00:02 Ora_dbw0_dave

Delete the/home/oracle directory directly, I move directly here.

[Email protected] ~]# Cd/home

[[email protected] home]# ls

Oracle

[Email protected] home]# mv Oracle Oracle.bak

[[email protected] home]# ls

Oracle.bak

[Email protected] home]#

[Email protected] home]# su-oracle

Su:warning:cannot Change directory to/home/oracle:no such file or directory

-bash-4.1$

-bash-4.1$ Sqlplus/as SYSDBA

-bash:sqlplus:command not found

-bash-4.1$

-bash-4.1$ WhoAmI

Oracle

-bash-4.1$ pwd

/home

-bash-4.1$

Start recovery:

-- To Create a directory:

[Email protected] home]# pwd

/home

[Email protected] home]# mkdir Oracle

[Email protected] home]# chown oracle:oinstalloracle

[email protected] home]# LL

Total 8

Drwxr-xr-x 2 Oracle Oinstall 4096 14:17 Oracle

DRWX------. Oracle Oinstall 4096 2623:08 Oracle.bak

[Email protected] home]#

-- To copy a skeleton file:

[Email protected] ~]# cp/etc/skel/.*/home/oracle/

Cp:omitting directory '/etc/skel/. '

Cp:omitting directory '/etc/skel/. '

cp:omitting directory '/etc/skel/.gnome2 '

cp:omitting directory '/etc/skel/.mozilla '

[Email protected] ~]#

[Email protected] home]# ls-la/home/oracle

Total 24

Drwxr-xr-x 2 root root 4096 27 14:47.

Drwxr-xr-x. 4 root root 4096 27 14:47.

-rw-r--r--1 root root 14:47.bash_logout

-rw-r--r--1 root root 176 14:47.bash_profile

-rw-r--r--1 root root 124 14:47.BASHRC

-rw-r--r--1 root root 121 14:47.KSHRC

[Email protected] home]#

[Email protected] home]# chown-r oracle:oinstall/home/oracle

[Email protected] home]# cd/home/oracle

[Email protected] oracle]# Ls-la

Total 24

Drwxr-xr-x 2 Oracle Oinstall 4096 27 14:47.

Drwxr-xr-x. 4 root root 4096 27 14:47.

-rw-r--r--1 Oracle oinstall 2714:47. bash_logout

-rw-r--r--1 Oracle Oinstall 176 2714:47. Bash_profile

-rw-r--r--1 Oracle Oinstall 124 2714:47. BASHRC

-rw-r--r--1 Oracle Oinstall 121 2714:47. KSHRC

[Email protected] oracle]#

// Modify environment variables for Oracle users:

[email protected] ~]$ cat. Bash_profile

#. Bash_profile

# Get the aliases and functions

If [-f ~/.BASHRC]; Then

. ~/.BASHRC

Fi

# User specific environment and Startupprograms

Path= $PATH: $HOME/bin

Export PATH

# Oracle Settings

tmp=/tmp; Export TMP

Tmpdir= $TMP; Export TMPDIR

Oracle_hostname=dave; Exportoracle_hostname

Oracle_unqname=dave; Export Oracle_unqname

Oracle_base=/u01/app/oracle; Exportoracle_base

Oracle_home= $ORACLE _base/product/11.2.0/db_1;exportoracle_home

Oracle_sid=dave; Export Oracle_sid

Path=/u01:/usr/sbin: $PATH; Export PATH

Path= $ORACLE _home/bin: $PATH; Export PATH

Ld_library_path= $ORACLE _home/lib:/lib:/usr/lib;exportld_library_path

Classpath= $ORACLE _home/jlib: $ORACLE _home/rdbms/jlib;exportclasspath

[Email protected] ~]$

Back to normal. But if there are data files, then recovery is more complex than here.

--------------------------------------------------------------------------------------------

All rights reserved, the article prohibits reprint, otherwise investigates the legal liability!

Aboutdave:

--------------------------------------------------------------------------------------------

qq:251097186

Email: [email protected]

Blog:http://blog.csdn.net/tianlesoftware

Weibo:http://weibo.com/tianlesoftware

Twitter:http://twitter.com/tianlesoftware

Facebook:http://www.facebook.com/tianlesoftware

Linkedin:http://cn.linkedin.com/in/tianlesoftware

Dave's QQ Group:

--------------------------------------------------------------------------------------------

Note: Add group must indicate tablespace and data file relationship | Do not repeat the addition group

cndba_1:62697850 (empty) cndba_2:62697716 (full) cndba_3:283816689

cndba_4:391125754 cndba_5:104207940 cndba_6:62697977 cndba_7:142216823 (full)

Linux platform mistakenly delete home Oracle root directory solution

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.