误删除Oracle家目录的恢复方法

--创建oracle目录
[root@zw home]# mkdir oracle
[root@zw home]# ll
total 8
drwxr-xr-x 2 root   root 4096 Jan  7 21:22 oracle
drwx------ 3 oracle dba  4096 Jan  7 19:25 oracle.bak
[root@zw home]# chown -R oracle:dba oracle
[root@zw home]# ll
total 8
drwxr-xr-x 2 oracle dba 4096 Jan  7 21:22 oracle
drwx------ 3 oracle dba 4096 Jan  7 19:25 oracle.bak
[root@zw home]#
 
 
--复制骨架文件:
[root@zw home]# cp /etc/skel/.*  /home/oracle/
cp: omitting directory `/etc/skel/.'
cp: omitting directory `/etc/skel/..'
cp: omitting directory `/etc/skel/.mozilla'
[root@zw home]#
 
 
[root@dg1 home]# ls -la /home/oracle
[root@zw home]#  ls -la /home/oracle
total 28
drwxr-xr-x 2 oracle dba  4096 Jan  7 21:23 .
drwxr-xr-x 4 root   root 4096 Jan  7 21:22 ..
-rw-r--r-- 1 root   root   33 Jan  7 21:23 .bash_logout
-rw-r--r-- 1 root   root  176 Jan  7 21:23 .bash_profile
-rw-r--r-- 1 root   root  124 Jan  7 21:23 .bashrc
-rw-r--r-- 1 root   root  515 Jan  7 21:23 .emacs
 
[root@zw home]#  chown -R oracle:dba  /home/oracle
[root@zw home]# cd /home/oracle
[root@dg1 oracle]# ls -la
 
total 28
drwxr-xr-x 2 oracle dba  4096 Jan  7 21:23 .
drwxr-xr-x 4 root   root 4096 Jan  7 21:22 ..
-rw-r--r-- 1 oracle dba    33 Jan  7 21:23 .bash_logout
-rw-r--r-- 1 oracle dba   176 Jan  7 21:23 .bash_profile
-rw-r--r-- 1 oracle dba   124 Jan  7 21:23 .bashrc
-rw-r--r-- 1 oracle dba   515 Jan  7 21:23 .emacs
 
 
 
//修改oracle 用户的环境变量:
[root@zw oracle]# cat .bash_profile
# .bash_profile
 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
     . ~/.bashrc
fi
 
# User specific environment and startup programs
 
PATH=$PATH:$HOME/bin
export PATH
 
# Oracle Settings
# .bash_profile
 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
     . ~/.bashrc
fi
 
# User specific environment and startup programs
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1
export ORACLE_SID=ogg02
#export NLS_LANG=american_america.zhs16gbk
#PATH=$PATH:$HOME/bin
alias  sqlplus="rlwrap sqlplus"
alias  rman="rlwrap rman"
export PATH=$ORACLE_HOME/bin:$PATH
export PATH
 
 
 [root@zw oracle]# . ./.bash_profile   --使文件生效
 
切换一下用户看有没有问题
[root@zw home]# cd oracle
 
[oracle@zw ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 7 21:31:28 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
SQL>
 
恢复成功!

猜你喜欢

转载自blog.csdn.net/shipeng1022/article/details/53126581