技术活动
CUUG学员就业信息
学员感言、就业资讯
报名热线
文档
当前您的位置:首页 > 技术活动 > 技术中心 > 文档
添加非oracle用户到dba, oinstall组-CUUG

  oracle用户所拥有的权限比较大,因此有些时候需要使用非oracle用户来完成相关数据库管理工作。尤其是多个人维护系统或数据库时,有必要为其添加不同的用户,然后将这些用户添加到dba组。同时这些用户也可以根据自己的喜好来设定不同的环境变量。本文描述了在linux下创建新用户以及使用新用户来连接数据库等。

  #查看当前的oracle用户id及其所属组

  oracle@SZDB:~> id

  uid=2000(oracle) gid=1000(oinstall) groups=1000(oinstall),1002(dba)

  #当前系统环境

  oracle@SZDB:~> cat /etc/issue

  Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l).

  #添加新用户robin

  oracle@SZDB:~> su - root

  Password:

  SZDB:~ # useradd -g oinstall -G dba robin

  #查看以添加用户的信息

  SZDB:~ # cat /etc/passwd | grep robin

  robin:x:2004:1000::/home/robin:/bin/bash

  #/home/robin是用户robin的家目录,下面将其修改为/users/robin(此为个人喜欢,可以不用修改)

  SZDB:~ # vi /etc/passwd

  #查看修改后的结果

  SZDB:~ # cat /etc/passwd | grep robin

  robin:x:2004:1000::/users/robin:/bin/bash

  #因此下面创建对应的家目录,

  SZDB:~ # mkdir /users/robin

  SZDB:~ # chown -R robin:oinstall /users/robin #修改家目录的属主,属组

  #修改新用户的密码

  SZDB:~ # passwd robin

  Changing password for robin.

  New Password:

  Bad password: too simple

  Reenter New Password:

  Password changed.

  #切换到新用户

  SZDB:~ # su - robin

  #查看新用户robin的相关信息

  robin@SZDB:~> id

  uid=2004(robin) gid=1000(oinstall) groups=1000(oinstall),1002(dba)

  #修改该新用户的环境变量

  robin@SZDB:~> vi ~/.bash_profile #可以将oracle用户的环境配置文件的内容复制过来

  robin@SZDB:~> source ~/.bash_profile #生效新的环境变量

  robin@SZDB:~> sid

  ORA_CRS_HOME=/opt/oracle/product/10gR2/crs

  ORACLE_PATH=.:/users/robin/dba_scripts/custom/sql:/users/robin/dba_scripts/common/sql

  ORA_ASM_HOME=/opt/oracle/product/10gR2/asm

  ORACLE_SID=CNMMBO

  ORACLE_BASE=/users/oracle

  ORACLE_HOME=/users/oracle/OraHome10g

  robin@SZDB:~> sql

  SQL*Plus: Release 10.2.0.3.0 - Production on Thu Nov 22 17:31:50 2012

  Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

  ERROR:

  ORA-01034: ORACLE not available

  ORA-27123: unable to attach to shared memory segment

  Linux-x86_64 Error: 13: Permission denied #提示许可拒绝

  Enter user-name: goex_admin

  Enter password:

  ERROR:

  ORA-01034: ORACLE not available

  ORA-27123: unable to attach to shared memory segment

  Linux-x86_64 Error: 13: Permission denied

  Enter user-name:

  robin@SZDB:~> ps -ef | grep pmon |grep SYBO2SZ

  oracle 2350 1 0 Oct25 ? 00:00:00 ora_pmon_SYBO2SZ

  robin@SZDB:~> export ORACLE_SID=SYBO2SZ

  robin@SZDB:~> sqlplus / as sysdba

  SQL*Plus: Release 10.2.0.3.0 - Production on Thu Nov 22 17:34:52 2012

  Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

  Connected to an idle instance.

  idle> exit

  Disconnected

  robin@SZDB:~> oerr ora 27123

  27123, 00000, "unable to attach to shared memory segment"

  // *Cause: shmat() call failed

  // *Action: check permissions on segment, contact Oracle support

  #查看$ORACLE_HOME/bin/oracle的权限,此处为751

  robin@SZDB:~> cd $ORACLE_HOME/bin

  robin@SZDB:/users/oracle/OraHome10g/bin> ls -hltr oracle

  -rwxr-x--x 1 oracle oinstall 99M 2011-05-13 14:26 oracle

  #使用oracle 用户登录

  robin@SZDB:~> su - oracle

  Password:

  oracle@SZDB:~> cd $ORACLE_HOME/bin

  #修改$ORACLE_HOME/bin/oracle下的权限

  oracle@SZDB:~/OraHome10g/bin> chmod 6751 oracle #这个地方是关键,修改这个权限以便其他用户能够从同一主机访问oracle 环境

  oracle@SZDB:~/OraHome10g/bin> ls -hltr oracle

  -rwsr-s--x 1 oracle oinstall 99M 2011-05-13 14:26 oracle

  #Author : Robinson

  #修改数据库所在文件夹的权限以便新用户robin有权限操作该路径下的所有文件

  oracle@SZDB:~/OraHome10g/bin> chmod -R 775 /u02/database

  oracle@SZDB:~/OraHome10g/bin> su - robin

  Password:

  robin@SZDB:~> sql

  SQL*Plus: Release 10.2.0.3.0 - Production on Thu Nov 22 17:42:50 2012

  Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

  Error accessing PRODUCT_USER_PROFILE

  Warning: Product user profile information not loaded!

  You may need to run PUPBLD.SQL as SYSTEM

  Connected to:

  Oracle Database 10g Release 10.2.0.3.0 - 64bit Production

  goex_admin@CNMMBO>