ORACLE wallet配置/管理/使用

    昨天在公司配置數據庫時,向wallet中增長了一個新的數據庫,現實無需輸入用戶名與密碼來登錄數據庫,增長完成後,致使整個監控系統都是報用戶名與密碼的錯誤,沒法登錄來數據庫。可是ORACLE用戶是能正常登錄數據庫,不須要輸入密碼。其實緣由很簡單,由於咱們的監控系統是nagios,而wallet相關的文件的默認權限是600,除ORACLE外其它的用戶都是不能夠讀寫的,正常狀況下咱們是改爲了777的權限,讓其它的用戶也能使用錢包這個功能,當是我對wallet進行新增長一個數據庫時,wallet會本身把cwallet.sso與ewallet.p12文件的權限本身改爲600。這就致使了今天個人悲劇。ios

    下面是wallet的配置/管理/維護/現象的模擬sql

1.建立wallet數據庫

  
  
  
  
  1. [oracle@test db_1]$ mkdir wallet 
  2. [oracle@test db_1]$ pwd 
  3. /u01/app/oracle/product/11.2.0/db_1 
  4. [oracle@test db_1]$ mkstore -wrl /u01/app/oracle/product/11.2.0/db_1/wallet -create 
  5. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  6. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  7. #這裏輸入wallet的密碼,對密碼是有限制條件的 
  8. 1.密碼長度要是8位以上。 
  9. 2.密碼最大長度沒有限制。 
  10. 3.密碼要有字符與數據。 
  11. Enter password:              
  12.  
  13. Enter password again:              

2.配置wallet到sqlnet.ora中oracle

  
  
  
  
  1. [oracle@test db_1]$ cat $ORACLE_HOME/network/admin/sqlnet.ora 
  2. NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT) 
  3. #DIRECTORY這裏就是指定wallet所在的目錄
  4. WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/product/11.2.0/db_1/wallet))) 
  5. SQLNET.WALLET_OVERRIDE=TRUE 
3.查看wallet的命令幫忙
wallet這個很好,由於直接用help就能夠看到命令的幫忙了,不須要咱們再去記複雜的參數,只用記住mkstore這個命令來管理wallet就能夠了。
  
  
  
  
  1. [oracle@test db_1]$ mkstore -help 
  2. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  3. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  4.  
  5. mkstore [-wrl wrl] [-create] [-createSSO] [-createLSSO] [-createALO] [-delete
  6. [-deleteSSO] [-list] [-createEntry alias secret] [-viewEntry alias] 
  7. [-modifyEntry alias secret] [-deleteEntry alias] 
  8. [-createCredential connect_string username password] [-listCredential] 
  9. [-modifyCredential connect_string username password] [-deleteCredential connect_string] [-help] [-nologo] 

4.增長數據庫到wallet中去,並測試是否成功app

  
  
  
  
  1. 3.1#增長net service爲htz scott爲用戶 oracle爲用戶的密碼。 
  2. #建議密碼用''引發來,由於在生產環境中的密碼基本上都是特殊字符的。 
  3. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createCredential htz scott 'oracle' 
  4. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  5. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  6.  
  7. Enter wallet password:              
  8.  
  9. Create credential oracle.security.client.connect_string1 
  10. 3.2 #查看是否增長成功。 
  11. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -listCredential  
  12. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  13. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  14.  
  15. Enter wallet password:              
  16.  
  17. List credential (index: connect_string username) 
  18. 1: htz scott 
  19. 3.3 測試是否能夠實現無須要輸入用戶與密碼登錄 
  20. [oracle@test db_1]$ sqlplus /@htz 
  21.  
  22. SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:19:15 2012 
  23.  
  24. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  25.  
  26.  
  27. Connected to
  28. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  29. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  30. #顯示的是scott,成功了。 
  31. SQL> show user
  32. USER is "SCOTT" 
  33. SQL> exit 
  34. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  35. With the Partitioning, OLAP, Data Mining and Real Application Testing options 

5.查看entryide

  
  
  
  
  1. #這裏看到咱們增長一個數據進來就會增長3個entries。 
  2. #分別是一個鏈接符,一個用戶名,一個密碼。 
  3. #當咱們增長了不少數據庫與用戶進來後,數據庫與用戶還有密碼他們是怎麼關聯的呢?其實他們就是經過後面的這個數字來關鍵的。 
  4. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -list 
  5. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  6. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  7.  
  8. Enter wallet password:              
  9.  
  10. Oracle Secret Store entries:  
  11. oracle.security.client.connect_string1 
  12. oracle.security.client.password1 
  13. oracle.security.client.username1 

6.建立默認用戶與密碼測試

這樣能夠實現,登錄因此的數據庫均可以使用默認的用戶與密碼spa

  
  
  
  
  1. 6.1 #建立默認的用戶。 
  2. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createEntry  oracle.security.client.default_username scott 
  3. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  4. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  5.  
  6. Enter wallet password:              
  7. 6.2 #建立默認用戶的密碼。 
  8. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -createEntry  oracle.security.client.default_password oracle 
  9. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  10. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  11.  
  12. Enter wallet password:              
  13. 6.3 #查看是否建立成功 
  14. [oracle@test db_1]$ mkstore -wrl  /u01/app/oracle/product/11.2.0/db_1/wallet -list 
  15. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  16. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  17.  
  18. Enter wallet password:              
  19.  
  20. Oracle Secret Store entries:  
  21. oracle.security.client.connect_string1 
  22. oracle.security.client.default_password 
  23. oracle.security.client.default_username 
  24. oracle.security.client.password1 
  25. oracle.security.client.username1 

7.當默認用戶與手動增長的數據庫信息到wallet中時,那一個生效呢?ci

下面咱們測試一下,當wallet裏面建立了默認的用戶與密碼時,手動再增長一個增長的信息到wallet時,究竟是默認用戶仍是手動增長的生效呢?實際上是手動增長的生效。string

  
  
  
  
  1. 7.1 #因爲默認用戶增長的SCOTT普通用戶,因此這裏咱們增長sys這個用戶來作測試,net service名是htzb 
  2. [oracle@test db_1]$ mkstore -wrl $ORACLE_HOME/wallet -createCredential htzb sys 'oracle' 
  3. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  4. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  5.  
  6. Enter wallet password:              
  7.  
  8. Create credential oracle.security.client.connect_string1 
  9. 7.2 #登錄測試。 
  10. 這裏沒有增長as sysdba就是爲了能區別普通用戶與sys用戶登錄的區別。若是是sys用戶生效,就會報沒有增長as sysdba登錄,若是是scott這個默認用戶生效,就會登錄成功。 
  11. [oracle@test db_1]$ sqlplus /@htzb 
  12.  
  13. SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:07 2012 
  14.  
  15. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  16. #這裏報錯,說明手動增長的SYS用戶的生效。默認用戶沒有生效 
  17. ERROR: 
  18. ORA-28009: connection as SYS should be as SYSDBA or SYSOPER 
  19.  
  20.  
  21. Enter user-name:   
  22. 7.3 #這裏咱們再登錄htz,登錄成功。說明咱們默認用戶在其它的net service是生效的。 
  23. [oracle@test db_1]$ sqlplus /@htz 
  24.  
  25. SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:23 2012 
  26.  
  27. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  28.  
  29.  
  30. Connected to
  31. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  32. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  33.  
  34. SQL> exit 
  35. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  36. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  37.  
  38. 7.4 #以sys as sysdba登錄成功 
  39. [oracle@test db_1]$ sqlplus /@htzb as sysdba 
  40.  
  41. SQL*Plus: Release 11.2.0.2.0 Production on Sat Sep 8 09:33:30 2012 
  42.  
  43. Copyright (c) 1982, 2010, Oracle.  All rights reserved. 
  44.  
  45.  
  46. Connected to
  47. Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 
  48. With the Partitioning, OLAP, Data Mining and Real Application Testing options 
  49.  
  50. SQL> show user 
  51. USER is "SYS" 

8.下面測試的是經過mkstore修改wallet中的內容後,致使wallet相關的文件,權限自動改爲600.

  
  
  
  
  1. 8.1 #把wallet的文件權限改爲777 
  2. [oracle@test db_1]$ chmod 777 $ORACLE_HOME/wallet/* 
  3. [oracle@test db_1]$ ls -l $ORACLE_HOME/wallet 
  4. total 16 
  5. -rwxrwxrwx 1 oracle oinstall 4565 Sep  8 09:38 cwallet.sso 
  6. -rwxrwxrwx 1 oracle oinstall 4488 Sep  8 09:38 ewallet.p12 
  7. 8.2 #手動在wallet中增長一個net service的配置信息 
  8. [oracle@test db_1]$ mkstore -wrl $ORACLE_HOME/wallet -deleteCredential htz  
  9. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  10. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  11.  
  12. Enter wallet password:              
  13.  
  14. Delete credential  
  15. Delete 2 
  16. 8.3 #再次查看權限時發現權限已經本身改爲了600了 
  17. [oracle@test db_1]$ ls -l $ORACLE_HOME/wallet 
  18. total 16 
  19. -rw------- 1 oracle oinstall 4205 Sep  8 09:39 cwallet.sso 
  20. -rw------- 1 oracle oinstall 4128 Sep  8 09:39 ewallet.p12 

9. 當用戶的密碼發生變化的時候須要修改wallet中的密碼

  
  
  
  
  1. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -modifyCredential htz scott 'oracleoracle'
  2. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  3. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  4.  
  5. Enter wallet password:              
  6.  
  7. Modify credential  
  8. Modify 1 

10.查看wallet中有那些認證的信息

  
  
  
  
  1. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -listCredential  
  2. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  3. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  4.  
  5. Enter wallet password:              
  6.  
  7. List credential (index: connect_string username) 
  8. 1: htz scott 

11 從wallet刪除一個net service的配置信息

  
  
  
  
  1. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -deleteCredential  htz 
  2. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  3. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  4.  
  5. Enter wallet password:              
  6.  
  7. Delete credential  
  8. Delete 1 

12.修改默認的用戶名

修改默認的用戶名的密碼的方法也同樣。

  
  
  
  
  1. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -viewEntry oracle.security.client.default_username 
  2. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  3. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  4.  
  5. Enter wallet password:              
  6.  
  7. oracle.security.client.default_username = scott 
  8. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -modifyEntry oracle.security.client.default_username 
  9. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  10. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  11.  
  12. Your secret/Password is missing in the command line  
  13. Enter your secret/Password:          
  14.  
  15. Re-enter your secret/Password:          
  16.  
  17. Enter wallet password:              
  18.  
  19. [oracle@test ~]$ mkstore -wrl $ORACLE_HOME/wallet -viewEntry oracle.security.client.default_username 
  20. Oracle Secret Store Tool : Version 11.2.0.2.0 - Production 
  21. Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 
  22.  
  23. Enter wallet password:              
  24.  
  25. oracle.security.client.default_username = oracle 

13 刪除默認的用戶名

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

咱們通常的維護就這麼多。

相關文章
相關標籤/搜索