配置oracle数据库钱包(免密登入)

  • 1.创建存放凭证的目录

    mkdir -p /oracle/app/oracle/wallets

  • 2.创建空的凭证文件

    #以下2种方式二选一 #创建有密码保护的凭证文件 mkstore -wrl /oracle/app/oracle/wallets -create #创建无免密保护的凭证文件,也会清空原有的凭证 mkstore -wrl /oracle/app/oracle/wallets -createALO

  • 3.创建凭证

    #有2种方式创建:1、直接使用连接串创建,2、可以通过tnsnames.ora别名创建 #3.1 方式1_直接使用连接串创建 #3.1.1 直接通过连接串配置,不需要输入密码创建(生产环境不建议把密码显示出来) mkstore -wrl /oracle/app/oracle/wallets -createCredential "192.168.24.7:1521/prod:dedicated" "testuser" "testuser_password" #3.1.2 直接通过连接串配置,不需要输入密码创建 mkstore -wrl /oracle/app/oracle/wallets -createCredential "192.168.24.7:1521/prod:dedicated" "testuser" #3.2 方式2_通过tnsnames.ora别名创建 #3.2.1 配置tnsnames.ora文件 prod_db= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.24.7)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =prod) ) ) #3.2.2测试tnsnames别名,正常后创建 tnsping prod_db #3.2.3创建凭证 #3.2.3.1 通过别名创建,不需要输入密码创建 mkstore -wrl /oracle/app/oracle/wallets -createCredential prod_db "testuser" "testuser_password" #3.2.3.2 通过别名创建,需要输入密码创建 mkstore -wrl /oracle/app/oracle/wallets -createCredential prod_db "testuser"

  • 4.检查创建的凭证

    mkstore -wrl /oracle/app/oracle/wallets -listCredential

  • 5.删除凭证

    #5.1删除通过连接串创建的凭证 mkstore -wrl /oracle/app/oracle/wallets -deleteCredential "192.168.24.7:1521/prod:dedicated" #删除通过tnsnames.ora别名创建的凭证 mkstore -wrl /oracle/app/oracle/wallets -deleteCredential prod_db

  • 6.测试凭证

    #6.1 配置sqlnet.ora ,指定凭证文件 WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/oracle/app/oracle/wallets))) SQLNET.WALLET_OVERRIDE = TRUE SSL_CLIENT_AUTHENTICATION = FALSE SSL_VERSION = 0 #6.2 测试通过连接串创建的凭证 sqlplus /@192.168.24.7:1521/prod:dedicated #6.3 测试通过连接串创建的凭证 sqlplus /@prod_db

  • 7.通过测试,可以正常免密登入数据库了

    [oracle@testdb ~]$ sqlplus /@prod_db SQL*Plus: Release 11.2.0.4.0 Production on Wed May 22 10:27:13 2024 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>