十年DB两茫茫、不思量,自难忘。漫漫长夜,加班话沧桑。纵使相逢应不识,尘满面,鬓如霜。
writer : starhu
常在河边走,哪有不湿鞋!
当你一不小心 chown -R 了以后,你会发现:我丢TMD,oracle数据库can't start !!!
此时此刻 一万个草泥马奔腾都不足以形容你那奔腾挣扎法克的内心
辣么.何以解忧.唯有permission.pl
Doc ID 1515018.1)
APPLIES TO:
Gen 1 Exadata Cloud at Customer (Oracle Exadata Database Cloud Machine) - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Oracle Database Cloud Service - Version N/A and later
Generic UNIX
Generic Linux
MAIN CONTENT
PURPOSE
This script is intended to capture and restore the file permission of a given directory example - ORACLE_HOME. The script will create a output file called permission_<timestamp> and permission_<timestamp>.cmd
REQUIREMENTS
The script needs to be run on command prompt of Unix platform .
Perl is required to execute this script
Shell is required to run the shell script .
CONFIGURING
Download and save the script on your server as permission.pl
Provide the execute permission on the script
INSTRUCTIONS
Run the script from the location where you have downloaded and saved it
./permission.pl <Path name to capture permission>
CAUTION
This sample code is provided for educational purposes only and not supported by Oracle Support Services. It has been tested internally, however, and works as documented. We do not guarantee that it will work for you, so be sure to test it in your environment before relying on it.
Proofread this sample code before using it! Due to the differences in the way text editors, e-mail packages and operating systems handle text formatting (spaces, tabs and carriage returns), this sample code may not be in an executable state when you first receive it. Check over the sample code to ensure that errors of this type are corrected.
Note : This script can restore permission back to the point at which it was captured. It is not intended to reset the permission.
SCRIPT
Execute the script from the dollar ($) prompt
Steps to capture permission of a directory
1. Download the script from here
2. Log in as "oracle" user
3. copy the file to a location say /home/oracle/scripts
4. Give execute permission
$ chmod 755 permission.pl
5. Execute the script to capture permission
$ cd /home/oracle/scripts
$ ./permission.pl <Path name to capture permission>
Script generates two files
a. permission-<time stamp> - This contains file permission in octal value, owner and group information of the files captured
b. restore-perm-<time stamp>.cmd - This contains command to change the permission, owner, and group of the captured files
Steps to restore captured permission of the directory
1. Copy the "restore-perm-<time stamp>.cmd" to desired location or NODE
2. Give execute permission to file generated during capture
chmod 755 restore-perm-<timestamp>.cmd
3. execute .cmd file to restore the permission and the ownership
$ ./restore-perm-<timestamp>.cmd
Note: In case of RAC setup for GRID_HOME, execute permission.pl and restore-perm-<timestamp>.cmd as root user.
Note: In case of RAC setup review the file restore-perm-<time stamp>.cmd to check for the node specific information like NODENAME, if any make necessary changes.
permission-<time stamp>
restore-perm-<time stamp>.cmd
chown oracle:oinstall <ORACLE_HOME>
chmod 755 <ORACLE_HOME>
chown oracle:oinstall <ORACLE_HOME>/root.sh
chmod 750 <ORACLE_HOME>/root.sh
chown oracle:oinstall <ORACLE_HOME>/install.platform
chmod 644 <ORACLE_HOME>/install.platform
chown oracle:oinstall <ORACLE_HOME>/oraInst.loc
chmod 640 <ORACLE_HOME>/oraInst.loc
chown oracle:oinstall <ORACLE_HOME>/afiedt.buf
chmod 644 <ORACLE_HOME>/afiedt.buf
chown oracle:oinstall <ORACLE_HOME>/a.out
chmod 644 <ORACLE_HOME>/a.out
chown root:root <ORACLE_HOME>/tsh.sh
chmod 6755 <ORACLE_HOME>/tsh.sh
chown oracle:oinstall <ORACLE_HOME>/Readme.txt
chmod 644 <ORACLE_HOME>/Readme.txt
chown oracle:oinstall <ORACLE_HOME>/oraorcl1122
chmod 640 <ORACLE_HOME>/oraorcl1122
chown oracle:oinstall <ORACLE_HOME>/SQLtraining_day1.lst
chmod 644 <ORACLE_HOME>/SQLtraining_day1.lst
chown oracle:oinstall <ORACLE_HOME>/bin/nid
chmod 751 <ORACLE_HOME>/bin/nid
chown oracle:oinstall <ORACLE_HOME>/bin/oracle
chmod 6751 <ORACLE_HOME>/bin/oracle
chown oracle:oinstall <ORACLE_HOME>/bin/orapwd
chmod 751 <ORACLE_HOME>/bin/orapwd
chown oracle:oinstall <ORACLE_HOME>/bin/wrap
chmod 751 <ORACLE_HOME>/bin/wrap
chown oracle:oinstall <ORACLE_HOME>/bin/grdcscan
chmod 750 <ORACLE_HOME>/bin/grdcscan
执行到这里,你的数据库可以startup了,回头再来看看你当时的内心。
人生可比是海上的波浪,有时起有时落,就像我们的大A市场,落时多起时少
好运歹运 ,总嘛要照起工来行!!!