设为首页 收藏本站
查看: 641|回复: 0

[经验分享] ORACLE wallet配置/管理/使用

[复制链接]

尚未签到

发表于 2018-9-21 13:37:39 | 显示全部楼层 |阅读模式
  昨天在公司配置数据库时,向wallet中增加了一个新的数据库,现实无需输入用户名与密码来登陆数据库,增加完成后,导致整个监控系统都是报用户名与密码的错误,无法登陆来数据库。但是ORACLE用户是能正常登陆数据库,不需要输入密码。其实原因很简单,因为我们的监控系统是nagios,而wallet相关的文件的默认权限是600,除ORACLE外其它的用户都是不可以读写的,正常情况下我们是改成了777的权限,让其它的用户也能使用钱包这个功能,当是我对wallet进行新增加一个数据库时,wallet会自己把cwallet.sso与ewallet.p12文件的权限自己改成600。这就导致了今天我的悲剧。
  下面是wallet的配置/管理/维护/现象的模拟
  1.创建wallet
  


  • [oracle@test db_1]$ mkdir wallet
  • [oracle@test db_1]$ pwd
  • /u01/app/oracle/product/11.2.0/db_1
  • [oracle@test db_1]$ mkstore -wrl /u01/app/oracle/product/11.2.0/db_1/wallet -create
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  • #这里输入wallet的密码,对密码是有限制条件的
  • 1.密码长度要是8位以上。
  • 2.密码最大长度没有限制。
  • 3.密码要有字符与数据。
  • Enter password:

  • Enter password again:
  

  2.配置wallet到sqlnet.ora中
  


  • [oracle@test db_1]$ cat $ORACLE_HOME/network/admin/sqlnet.ora
  • NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
  • #DIRECTORY这里就是指定wallet所在的目录
  • WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/product/11.2.0/db_1/wallet)))
  • SQLNET.WALLET_OVERRIDE=TRUE
  

3.查看wallet的命令帮忙
wallet这个很好,因为直接用help就可以看到命令的帮忙了,不需要我们再去记复杂的参数,只用记住mkstore这个命令来管理wallet就可以了。  


  • [oracle@test db_1]$ mkstore -help
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • mkstore [-wrl wrl] [-create] [-createSSO] [-createLSSO] [-createALO] [-delete]
  • [-deleteSSO] [-list] [-createEntry alias secret] [-viewEntry alias]
  • [-modifyEntry alias secret] [-deleteEntry alias]
  • [-createCredential connect_string username password] [-listCredential]
  • [-modifyCredential connect_string username password] [-deleteCredential connect_string] [-help] [-nologo]
  

  4.增加数据库到wallet中去,并测试是否成功
  


  • 3.1#增加net service为htz scott为用户 oracle为用户的密码。
  • #建议密码用''引起来,因为在生产环境中的密码基本上都是特殊字符的。
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createCredential htz scott 'oracle'
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Create credential oracle.security.client.connect_string1
  • 3.2 #查看是否增加成功。
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -listCredential
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • List credential (index: connect_string username)
  • 1: htz scott
  • 3.3 测试是否可以实现无需要输入用户与密码登陆
  • [oracle@test db_1]$ sqlplus /@htz

  • SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:19:15 2012

  • Copyright (c) 1982, 2010, Oracle.  All rights reserved.


  • Connected to:
  • Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  • With the Partitioning, OLAP, Data Mining and Real Application Testing options
  • #显示的是scott,成功了。
  • SQL> show user;
  • USER is "SCOTT"
  • SQL> exit
  • Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  • With the Partitioning, OLAP, Data Mining and Real Application Testing options
  

  5.查看entry
  


  • #这里看到我们增加一个数据进来就会增加3个entries。
  • #分别是一个连接符,一个用户名,一个密码。
  • #当我们增加了很多数据库与用户进来后,数据库与用户还有密码他们是怎么关联的呢?其实他们就是通过后面的这个数字来关键的。
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -list
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Oracle Secret Store entries:
  • oracle.security.client.connect_string1
  • oracle.security.client.password1
  • oracle.security.client.username1
  

  6.创建默认用户与密码
  这样可以实现,登陆所以的数据库都可以使用默认的用户与密码
  


  • 6.1 #创建默认的用户。
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createEntry  oracle.security.client.default_username scott
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:
  • 6.2 #创建默认用户的密码。
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createEntry  oracle.security.client.default_password oracle
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:
  • 6.3 #查看是否创建成功
  • [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -list
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Oracle Secret Store entries:
  • oracle.security.client.connect_string1
  • oracle.security.client.default_password
  • oracle.security.client.default_username
  • oracle.security.client.password1
  • oracle.security.client.username1
  

  7.当默认用户与手动增加的数据库信息到wallet中时,那一个生效呢?
  下面我们测试一下,当wallet里面创建了默认的用户与密码时,手动再增加一个增加的信息到wallet时,到底是默认用户还是手动增加的生效呢?其实是手动增加的生效。
  


  • 7.1 #由于默认用户增加的SCOTT普通用户,所以这里我们增加sys这个用户来做测试,net service名是htzb
  • [oracle@test db_1]$ mkstore -wrl $ORACLE_HOME/wallet -createCredential htzb sys 'oracle'
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Create credential oracle.security.client.connect_string1
  • 7.2 #登陆测试。
  • 这里没有增加as sysdba就是为了能区别普通用户与sys用户登陆的区别。如果是sys用户生效,就会报没有增加as sysdba登陆,如果是scott这个默认用户生效,就会登陆成功。
  • [oracle@test db_1]$ sqlplus /@htzb

  • SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:07 2012

  • Copyright (c) 1982, 2010, Oracle.  All rights reserved.
  • #这里报错,说明手动增加的SYS用户的生效。默认用户没有生效
  • ERROR:
  • ORA-28009: connection as SYS should be as SYSDBA or SYSOPER


  • Enter user-name:
  • 7.3 #这里我们再登陆htz,登陆成功。说明我们默认用户在其它的net service是生效的。
  • [oracle@test db_1]$ sqlplus /@htz

  • SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:23 2012

  • Copyright (c) 1982, 2010, Oracle.  All rights reserved.


  • Connected to:
  • Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  • With the Partitioning, OLAP, Data Mining and Real Application Testing options

  • SQL> exit
  • Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  • With the Partitioning, OLAP, Data Mining and Real Application Testing options

  • 7.4 #以sys as sysdba登陆成功
  • [oracle@test db_1]$ sqlplus /@htzb as sysdba

  • SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:30 2012

  • Copyright (c) 1982, 2010, Oracle.  All rights reserved.


  • Connected to:
  • Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
  • With the Partitioning, OLAP, Data Mining and Real Application Testing options

  • SQL> show user
  • USER is "SYS"
  

  8.下面测试的是通过mkstore修改wallet中的内容后,导致wallet相关的文件,权限自动改成600.
  


  • 8.1 #把wallet的文件权限改成777
  • [oracle@test db_1]$ chmod 777 $ORACLE_HOME/wallet/*
  • [oracle@test db_1]$ ls -l $ORACLE_HOME/wallet
  • total 16
  • -rwxrwxrwx 1 oracle oinstall 4565 Sep  8 09:38 cwallet.sso
  • -rwxrwxrwx 1 oracle oinstall 4488 Sep  8 09:38 ewallet.p12
  • 8.2 #手动在wallet中增加一个net service的配置信息
  • [oracle@test db_1]$ mkstore -wrl $ORACLE_HOME/wallet -deleteCredential htz
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Delete credential
  • Delete 2
  • 8.3 #再次查看权限时发现权限已经自己改成了600了
  • [oracle@test db_1]$ ls -l $ORACLE_HOME/wallet
  • total 16
  • -rw------- 1 oracle oinstall 4205 Sep  8 09:39 cwallet.sso
  • -rw------- 1 oracle oinstall 4128 Sep  8 09:39 ewallet.p12
  

  9. 当用户的密码发生变化的时候需要修改wallet中的密码
  


  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -modifyCredential htz scott 'oracleoracle';
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Modify credential
  • Modify 1
  

  10.查看wallet中有那些认证的信息
  


  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -listCredential
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • List credential (index: connect_string username)
  • 1: htz scott
  

  11 从wallet删除一个net service的配置信息
  


  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -deleteCredential  htz
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • Delete credential
  • Delete 1
  

  12.修改默认的用户名
  修改默认的用户名的密码的方法也一样。
  


  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -viewEntry oracle.security.client.default_username
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • oracle.security.client.default_username = scott
  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -modifyEntry oracle.security.client.default_username
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Your secret/Password is missing in the command line
  • Enter your secret/Password:

  • Re-enter your secret/Password:

  • Enter wallet password:

  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -viewEntry oracle.security.client.default_username
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:

  • oracle.security.client.default_username = oracle
  

  13 删除默认的用户名
  


  • [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -deleteEntry oracle.security.client.default_username
  • Oracle Secret Store Tool : Version 11.2.0.2.0 - Production
  • Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  • Enter wallet password:
  

  我们一般的维护就这么多。



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-599473-1-1.html 上篇帖子: ORACLE云计算一瞥 下篇帖子: oracle sqlldr总结
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表