[2017070伍]驾驭linux su命令.txt

By admin in 美高梅手机版4858 on 2019年4月10日

[20170705]理解linux su命令.txt

[20170705]理解linux su命令.txt

[20170705]理解linux su命令.txt,20170705.txt

[20170705]理解linux su命令.txt

–//笔者1般在保证时日常接纳root用户登录,然后su – oracle
转到其他用户操作
–//壹般都进入 – 参数.这几个早已成了原则反射…^_^.

# man su       
Change the effective user id and group id to that of USER.

-, -l, –login
make the shell a login shell

–//也便是使用login里面包车型地铁shell,设置好相应的环境.
–//假设执行未有-,也正是可是run a shell with substitute user and group
IDs,不替换里面包车型客车环境变量可能相关参数.

1.测试1:
–//当前以root用户登录:
# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $ORACLE_HOME
#[2017070伍]驾驭linux su命令.txt。 export aaa=test
# echo $aaa
test

# su  – oracle
$ id
uid=1001(oracle) gid=1001(oinstall)
groups=101(fuse),1001(oinstall),1002(dba),1003(racoper),1004(asmdba)

$ echo $aaa

–//无显示.

$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

贰.1旦履行不加参数 – 呢?

$ echo $ORACLE_HOME

–//环境变量ORACLE_HOME未有安装,而root设置的环境变量aaa呢?
$ echo $aaa
test

–//能够窥见可以显得环境变量aaa.

三.这么看来应该很少使用-参数.
–//实际上rac的管制oracle引进许多事物,建立grid用户.通过壹些非正规例子来注脚难点:
–//以grid用户登录:
[[email protected]
~ ]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3852
         Available space (kbytes) :     258268
         ID                       : 2101855892
         Device/File Name         :   +DBFS_DG
                                    Device/File integrity check
succeeded
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
         Cluster registry integrity check succeeded
         Logical corruption check bypassed due to non-privileged user

–//OK.就算你进入参数:
$ ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

–//跟踪看看:
$ strace -f -o /tmp/b1.txt ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

$ grep ‘Permission denied’ /tmp/b1.txt
14849 open(“/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr”,
O_RDONLY|O_SYNC) = -1 EACCES (Permission denied)

–//要打开文件/u01/app/11.二.0.4/grid/cdata/dm0一dbadm0贰.olr.

$ ls -l /u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
-rw——- 1 root oinstall 272756736 2017-07-05 09:45:15
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
–//注意看用户,组是root,oinstall,grid用户根本未曾权限打开这一个文件.

–//要化解那么些题材部分dba采纳把root用户里面参与grid的成都百货上千环境变量.以root用户执行,不过如此笔者以为不是很好!!
–//实际上很简单的法子便是切换成root用户执行,注意那年不能投入-
参数,因为如此grid的环境参数就不见了,实际上那样就以
–//root用户执行,而选拔的条件依旧grid用户的.

$ su root
Password:

# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $PATH
/usr/local/bin:/bin:/usr/bin:/u01/app/11.2.0.4/grid/bin:.:/u01/app/11.2.0.4/grid/bin

# echo $ORACLE_HOME
/u01/app/11.2.0.4/grid

–//你能够发现grid的环境参数还在.那几个应用以root用户执行如下:
# ocrcheck -local
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

–//当然还足以以别的的点子,正是采取sudo命令. sudo ocrcheck -local
–//注意要修改/etc/sudoers,参预:
grid    ALL=(ALL)   ALL

$ sudo ocrcheck -local
[sudo] password for grid:
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

su命令.txt,20170705.txt
[20170705]知道linux su命令.txt
–//小编一般在维护时平日使用root用户登录,然后su – oracle
转到其余用户操作…

RedHat Linux
5.7下Oracle RAC
10.2.0.5 升级到11.2.0.4

–//作者壹般在维护时平时选取root用户登录,然后su – oracle
转到其余用户操作
–//1般都进入 – 参数.那么些早已成了原则反射…^_^.

–//作者壹般在保安时常常利用root用户登录,然后su – oracle
转到其余用户操作
–//1般都参预 – 参数.那一个早已成了条件反射…^_^.

美高梅手机版4858 1

# man su       
Change the effective user id and group id to that of USER.

# man su       
Change the effective user id and group id to that of USER.

1.升级grid
当前rac状态:

-, -l, –login
make the shell a login shell

-, -l, –login
make the shell a login shell

[root@rac1 ~]# crs_stat -t

–//也正是使用login里面包车型客车shell,设置好相应的环境.
–//即便执行没有-,也便是仅仅run a shell with substitute user and group
IDs,不替换里面包车型大巴环境变量或然有关参数.

–//约等于使用login里面包车型大巴shell,设置好相应的环境.
–//假使执行未有-,也便是1味run a shell with substitute user and group
IDs,不替换里面包车型大巴环境变量可能连带参数.

NameTypeTargetStateHost

美高梅手机版4858 ,ora.rac.db application ONLINE ONLINE rac1
ora….c1.inst application ONLINE ONLINE rac1
ora….c2.inst application ONLINE ONLINE rac2
ora….SM1.asm application ONLINE ONLINE rac1
ora….C1.lsnr application ONLINE ONLINE rac1
ora.rac1.gsd application ONLINE ONLINE rac1
ora.rac1.ons application ONLINE ONLINE rac1
ora.rac1.vip application ONLINE ONLINE rac1
ora….SM2.asm application ONLINE ONLINE rac2
ora….C2.lsnr application ONLINE ONLINE rac2
ora.rac2.gsd application ONLINE ONLINE rac2
ora.rac2.ons application ONLINE ONLINE rac2
ora.rac2.vip application ONLINE ONLINE rac2
crs版本:

[root@rac1 ~]# crsctl query crs softwareversion
CRS software version on node [rac1] is [10.2.0.5.0]
数据库版本:

[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus:Release10.2.0.5.0-Production on TueNov2219:07:552016
Copyright(c)1982,2010,Oracle.AllRightsReserved.
Connected to:
OracleDatabase10gEnterpriseEditionRelease10.2.0.5.0-64bitProduction
With the Partitioning,RealApplicationClusters, OLAP,DataMining
and RealApplicationTesting options
SQL> select * from v$version;

1.测试1:
–//当前以root用户登录:
# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $ORACLE_HOME
# export aaa=test
# echo $aaa
test

1.测试1:
–//当前以root用户登录:
# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $ORACLE_HOME
# export aaa=test
# echo $aaa
test

BANNER

OracleDatabase10gEnterpriseEditionRelease10.2.0.5.0-64bi
PL/SQL Release10.2.0.5.0-Production
CORE 10.2.0.5.0Production
TNS forLinux:Version10.2.0.5.0-Production
NLSRTL Version10.2.0.5.0–Production
Ocr检查:

[oracle@rac1 ~]$ ocrcheck
Status of OracleClusterRegistry is as follows :
Version:2
Total space (kbytes):1043916
Used space (kbytes):3848
Available space (kbytes):1040068
ID :1371096888
Device/FileName:/dev/raw/raw1
Device/File integrity check succeeded
Device/File not configured
Cluster registry integrity check succeeded
表决盘检查:

[oracle@rac1 ~]$ crsctl query css votedisk
0.0/dev/raw/raw2
located 1 votedisk(s).
自笔者批评软件包安装

检查/etc/security/limit.conf

检查/etc/sysctl.conf

在hosts中添加scan ip信息:

[root@rac1 ~]# cat /etc/hosts
#Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.56.110 rac1
192.168.56.111 rac2
192.168.56.112 rac1-vip
192.168.56.113 rac2-vip
172.16.8.1 rac1-priv
172.16.8.2 rac2-priv
192.168.56.115 rac-scan
翻开Oracle用户消息:

[oracle@rac1 ~]$ id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)
鉴于是进步到1一.二.0.四,grid的装置用户也运用oracle来设置,可是急需相应的用户组,手工业来成立:
在颇具节点修改oracle用户组添加asmadmin,asmdba,asmoper,oper组

groupadd -g 1020 asmadmin
groupadd -g 1021 asmdba
groupadd -g 1022 asmoper
groupadd -g 1032 oper
usermod -g oinstall -G dba,oper,asmadmin,asmdba,asmoper oracle
查阅修改后的oracle用户组:
[root@rac1 ~]# id oracle
uid=500(oracle) gid=500(oinstall)
groups=500(oinstall),501(dba),1020(asmadmin),1021(asmdba),1022(asmoper),1032(oper)
在富有节点创制11g安装文件目录

mkdir -p /u01/11.2.0/grid
chown -R oracle:oinstall /u01/11.2.0/grid
chmod -R 775/u01/11.2.0/grid
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/app/oracle/product/11.2.0/db_1
chmod -R 775/u01/app/oracle/product/11.2.0/db_1
在有着节点添加oracle和grid的环境变量:

vi ~/.bash_profile

丰盛以下的小名:

alias ora=”export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export
PATH=/u01/app/oracle/product/11.2.0/db_1/bin:$CRS_HOME/bin:$PATH:$HOME/bin
export ORACLE_SID=rac1″
alias grid=”export ORACLE_HOME=/u01/11.2.0/grid
export PATH=/u01/11.2.0/grid/bin:$CRS_HOME/bin:$PATH:$HOME/bin
export ORACLE_SID=+ASM1″
设置cvudisk包,用来检查评定oracle环境

[root@rac1 ~]# cd /home/oracle/grid/rpm/
[root@rac1 rpm]# ls
cvuqdisk-1.0.9-1.rpm
[root@rac1 rpm]# rpm -ivh cvuqdisk-1.0.9-1.rpm
Preparing…###########################################[100%]
1:cvuqdisk
###########################################[100%]
[oracle@rac1 grid]$ pwd
/home/oracle/grid

RedHat Linux 伍.七下Oracle RAC 十.二.0.伍升级到1一.二.0.肆图文详解PDF到Linux公社财富站下载:

——————————————分割线——————————————

免费下载地址在

用户名与密码都是www.linuxidc.com

具体下载目录在 /2016年资料/12月/11日/RedHat Linux 5.7下Oracle RAC
10.2.0.5 升级到11.2.0.4/

下载情势见
http://www.linuxidc.com/Linux/2013-07/87684.htm

——————————————分割线——————————————

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-12/138204.htm

美高梅手机版4858 2

# su  – oracle
$ id
uid=1001(oracle) gid=1001(oinstall)
groups=101(fuse),1001(oinstall),1002(dba),1003(racoper),1004(asmdba)

# su  – oracle
$ id
uid=1001(oracle) gid=1001(oinstall)
groups=101(fuse),1001(oinstall),1002(dba),1003(racoper),1004(asmdba)

$ echo $aaa

$ echo $aaa

–//无显示.

–//无显示.

$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0.4/dbhome_1

二.万壹实施不加参数 – 呢?

二.只要推行不加参数 – 呢?

$ echo $ORACLE_HOME

$ echo $ORACLE_HOME

–//环境变量ORACLE_HOME未有设置,而root设置的条件变量aaa呢?
$ echo $aaa
test

–//环境变量ORACLE_HOME未有设置,而root设置的环境变量aaa呢?
$ echo $aaa
test

–//能够发现能够来得环境变量aaa.

–//能够发现能够显得环境变量aaa.

3.这么看来应该很少使用-参数.
–//实际上rac的治本oracle引进许多事物,建立grid用户.通过一些异样例子来表达难题:
–//以grid用户登录:
[grid@dm01dbadm02 ~ ]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3852
         Available space (kbytes) :     258268
         ID                       : 2101855892
         Device/File Name         :   +DBFS_DG
                                    Device/File integrity check
succeeded
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
         Cluster registry integrity check succeeded
         Logical corruption check bypassed due to non-privileged user

三.如此看来应该很少使用-参数.
–//实际上rac的保管oracle引进许多东西,建立grid用户.通过有个别与众不一致例子来注解难题:
–//以grid用户登录:
[grid@dm01dbadm02 ~ ]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       3852
         Available space (kbytes) :     258268
         ID                       : 2101855892
         Device/File Name         :   +DBFS_DG
                                    Device/File integrity check
succeeded
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
                                    Device/File not configured
         Cluster registry integrity check succeeded
         Logical corruption check bypassed due to non-privileged user

–//OK.假如你进入参数:
$ ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

–//OK.假如你出席参数:
$ ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

–//跟踪看看:
$ strace -f -o /tmp/b1.txt ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

–//跟踪看看:
$ strace -f -o /tmp/b1.txt ocrcheck -local
PROTL-602: Failed to retrieve data from the local registry
PROCL-26: Error while accessing the physical storage Operating System
error [Permission denied] [13]

$ grep ‘Permission denied’ /tmp/b1.txt
14849 open(“/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr”,
O_RDONLY|O_SYNC) = -1 EACCES (Permission denied)

$ grep ‘Permission denied’ /tmp/b1.txt
14849 open(“/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr”,
O_RDONLY|O_SYNC) = -1 EACCES (Permission denied)

–//要打开文件/u01/app/1一.2.0.4/grid/cdata/dm0一dbadm0二.olr.

–//要打开文件/u01/app/1一.2.0.4/grid/cdata/dm0壹dbadm0贰.olr.

$ ls -l /u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
-rw——- 1 root oinstall 272756736 2017-07-05 09:45:15
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
–//注意看用户,组是root,oinstall,grid用户根本未曾权限打开那个文件.

$ ls -l /u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
-rw——- 1 root oinstall 272756736 2017-07-05 09:45:15
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
–//注意看用户,组是root,oinstall,grid用户根本未曾权限打开这么些文件.

–//要化解那么些题材部分dba选择把root用户里面参加grid的大队人马环境变量.以root用户执行,不过如此小编觉着不是很好!!
–//实际上很简短的法子正是切换来root用户执行,注意这一年无法进入-
参数,因为那样grid的环境参数就不见了,实际上那样就以
–//root用户执行,而利用的条件依然grid用户的.

–//要化解那么些标题部分dba选拔把root用户里面加入grid的多多环境变量.以root用户执行,不过如此作者觉着不是很好!!
–//实际上相当的粗略的章程就是切换来root用户执行,注意这年不能够投入-
参数,因为这么grid的环境参数就不见了,实际上那样就以
–//root用户执行,而使用的条件依然grid用户的.

$ su root
Password:

$ su root
Password:

# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $PATH
/usr/local/bin:/bin:/usr/bin:/u01/app/11.2.0.4/grid/bin:.:/u01/app/11.2.0.4/grid/bin

# id
uid=0(root) gid=0(root)
groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
# echo $PATH
/usr/local/bin:/bin:/usr/bin:/u01/app/11.2.0.4/grid/bin:.:/u01/app/11.2.0.4/grid/bin

# echo $ORACLE_HOME
/u01/app/11.2.0.4/grid

# echo $ORACLE_HOME
/u01/app/11.2.0.4/grid

–//你能够窥见grid的环境参数还在.那个动用以root用户执行如下:
# ocrcheck -local
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

–//你能够窥见grid的环境参数还在.这么些应用以root用户执行如下:
# ocrcheck -local
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

–//当然仍可以以其它的方法,正是应用sudo命令. sudo ocrcheck -local
–//注意要修改/etc/sudoers,参加:
grid    ALL=(ALL)   ALL

–//当然还能以此外的秘籍,正是选择sudo命令. sudo ocrcheck -local
–//注意要修改/etc/sudoers,到场:
grid    ALL=(ALL)   ALL

$ sudo ocrcheck -local
[sudo] password for grid:
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

$ sudo ocrcheck -local
[sudo] password for grid:
Status of Oracle Local Registry is as follows :
         Version                  :          3
         Total space (kbytes)     :     262120
         Used space (kbytes)      :       2800
         Available space (kbytes) :     259320
         ID                       : 1632195400
         Device/File Name         :
/u01/app/11.2.0.4/grid/cdata/dm01dbadm02.olr
                                    Device/File integrity check
succeeded
         Local registry integrity check succeeded
         Logical corruption check succeeded

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有