[20171223]grid用户的环境变量问题.txt

[20171223]grid用户的环境变量问题.txt

--//oracle 11G 安装RAC,一般需要建立grid用户,使用这个用户管理asm,群集信息.
--//在安装过程中,同事的疑问实际上也是我以前的疑问.

--//grid用户:
$ id
uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

$ env| egrep "ORACLE_BASE|ORACLE_HOME"
ORACLE_BASE=/u01/app/grid
ORACLE_HOME=/u01/app/11.2.0/grid

--//oracle用户:
$ id
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)

$  env| egrep "ORACLE_BASE|ORACLE_HOME"
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1

--//为什么oracle用户建立ORACLE_HOME在ORACLE_BASE之中,而grid用户建立ORACLE_HOME却没有建立为
--//ORACLE_HOME目录之下,例如:/u01/app/grid/product/11.2.0/dbhome_1

--//我开始一直以为也许是一种约定,按照文档操作就ok了.昨天别人问这个问题,我google:

https://community.oracle.com/message/12310012

For ASM installation of software:

. The directories are located by the operating system environment variables.
-- ORACLE_BASE is the top-level directory for a particular software owner.
-- ORACLE_HOME is used to identify the top-level directory of the Grid Infrastructure software.

. Use a common ORACLE_BASE for all Oracle products owned by the same user.
. Use an isolated ORACLE_HOME location from other Oracle products even if they are the same version.
. Do not place Grid ORACLE_HOME below ORACLE_BASE.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. ORACLE_HOME requires 3 GB to 5 GB of disk space.


--//对方的解答:

The recommendation is correct.  GRID_HOME should be separate.  The root.sh script for the GRID_HOME changes ownership
and permissions for certain files to rooot so it should be separate.

...

Gridhome must not be a subdirectory of gridbase, because of the permission change to root.  It works good in production
and hopefully survives a deinstall of grid base after e.g. an upgrade.

--//按照官方的解析,许多文件目录在按照后修改为root用户.

$ ls -l $ORACLE_HOME |grep " root "
drwxrwxrwt  6 root oinstall  4096 2016-12-24 12:12:53 auth
drwxr-xr-x  2 root oinstall 12288 2016-12-24 12:12:53 bin
drwxr-x---  4 root oinstall  4096 2016-12-24 12:12:53 crf
drwxr-xr-x 17 root oinstall  4096 2016-12-24 12:12:53 crs
drwxr-xr-x  3 root oinstall  4096 2016-12-24 12:12:53 ctss
drwxr-x---  3 root oinstall  4096 2016-12-24 12:12:53 gnsd
drwxr-xr-x  3 root oinstall 12288 2016-12-24 12:12:53 lib
drwxr-xr-x  3 root oinstall  4096 2016-12-24 12:12:53 ologgerd
drwxr-xr-x  3 root oinstall  4096 2016-12-24 12:12:53 osysmond
drwxr-xr-x  4 root root      4096 2016-12-24 12:13:13 tfa

$ find /u01/app/11.2.0 -uid 0  -exec ls -ld {} \;
--//能查询到许多目录文件都是root用户.

$ ls -l /u01/app
total 16
drwxr-xr-x. 3 root   oinstall 4096 2016-12-18 14:47:35 11.2.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drwxrwxr-x. 9 grid   oinstall 4096 2016-12-30 12:09:18 grid
drwxrwxr-x. 7 oracle oinstall 4096 2016-12-24 12:52:35 oracle
drwxrwx---  6 grid   oinstall 4096 2016-12-24 12:42:52 oraInventory

--//11.2.0 目录的owner=root.我估计安装在子目录下安装也能过去,问题也许更多在取消安装或者升级.
--//实际上有许多帖子是关于grid中文件目录权限的问题.总之按照安装文档要求实施总是有一定道理.

--//实际上最好的方法是保存一份权限目录的文件,必须时查询与用于恢复.
getfacl -R /u01/app/11.2.0/grid > dir_privs.txt
setfact -restore dir_privs.txt
--//注意这样保存的是相对路径.保存绝对路径使用如下命令:
getfacl -R --absolute-names /u01/app/11.2.0/grid > dir_privs.txt

--//grid在安装后还保存一份文件目录的权限在如下目录:
# find /u01 -name "crsconfig_*" -exec ls -l {} + | grep utl
-rw-r--r-- 1 root   root       8159 Dec 24  2016 /u01/app/11.2.0/grid/crs/utl/crsconfig_dirs
-rw-r--r-- 1 root   root      12877 Dec 24  2016 /u01/app/11.2.0/grid/crs/utl/crsconfig_fileperms
-rw-r--r-- 1 root   root      11936 Dec 24  2016 /u01/app/11.2.0/grid/crs/utl/crsconfig_files

上一篇:python自动化测试应用-第7篇(WEB测试)--Selenium进阶篇


下一篇:别在乎流量了 小心免费WiFi的钓鱼攻击