前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >添加非oracle用户到dba, oinstall组

添加非oracle用户到dba, oinstall组

作者头像
Leshami
发布2018-08-14 10:43:47
1.5K0
发布2018-08-14 10:43:47
举报
文章被收录于专栏:乐沙弥的世界乐沙弥的世界

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

代码语言:javascript
复制
#查看当前的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
#Blog : http://blog.csdn.net/robinson_0612

#修改数据库所在文件夹的权限以便新用户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> 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2012年11月28日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档