通过wallet实现数据库的无密码登陆。
数据库版本:12.2.0.1.0
1,配置tnsnames.ora
cdb =
(DESCRIPTION =
(ADDRESS_LIST =(ADDRESS=(PROTOCOL= TCP)(HOST=prod04)(PORT=1521)))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cdb))
)
sbcdb =
(DESCRIPTION =
(ADDRESS_LIST =(ADDRESS=(PROTOCOL = TCP)(HOST=prod05) (PORT=1521)))
(CONNECT_DATA =
(UR=A)
(SERVER = DEDICATED)
(SERVICE_NAME = sbcdb))
)
2,配置sqlnet.ora
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE
3,创建一个钱包来存储认证信息
mkdir -p /u01/app/oracle/wallet/
mkstore -wrl /u01/app/oracle/wallet/ -create
mkstore -wrl /u01/app/oracle/wallet/ -createCredential cdb sys oracle
mkstore -wrl /u01/app/oracle/wallet/ -createCredential sbcdb sys oracle
#mkstore参数说明:
-createCredential connect_string username password
-modifyCredential connect_string username password
参数为"alias(tnsname.ora别名) username password".
#创建步骤,需要输入一个钱包密码:
[oracle@prod04 admin]$ mkdir -p /u01/app/oracle/wallet/
[oracle@prod04 admin]$ mkstore -wrl /u01/app/oracle/wallet/ -create
Oracle Secret Store Tool Release 18.0.0.0.0 - Production
Version 18.1.0.0.0
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
Enter password:
Enter password again:
[oracle@prod04 admin]$ mkstore -wrl /u01/app/oracle/wallet/ -createCredential cdb sys oracle
Oracle Secret Store Tool Release 18.0.0.0.0 - Production
Version 18.1.0.0.0
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:
[oracle@prod04 admin]$ mkstore -wrl /u01/app/oracle/wallet/ -createCredential sbcdb sys oracle
Oracle Secret Store Tool Release 18.0.0.0.0 - Production
Version 18.1.0.0.0
Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:
[oracle@prod04 admin]$
4,测试登陆
测试cdb,sbcdb 是否能登陆成功?
[oracle@prod04 ~]$ sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on Fri Aug 31 12:13:54 2018
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> conn /@cdb as sysdba
Connected.
SQL> conn /@sbcdb as sysdba
Connected.
SQL>