如何configurationOracle客户端通过LDAP / OID自动查找连接string?

我希望使用LDAP连接到Oracle数据库以进行连接string查找。 已经设置LDAP / OID,并手动使用从LDAP检索的连接string工作。 但是,从oracle客户端( sqlplus )自动LDAP查找连接string不会! 根据谷歌,文件sqlnet.oraldap.ora需要设置通知oracle客户端,我们希望使用LDAP查找。 这是完成的,并且值是正确的,据我所知:

 export ORACLE_HOME=/etc/oracle 

$ ORACLE_HOME /networking/pipe理/ SQLNET.ORA

 NAMES.DIRECTORY_PATH = (LDAP) 

$ ORACLE_HOME / LDAP /pipe理/ ldap.ora

 DIRECTORY_SERVERS = (<host>:<port>) DEFAULT_ADMIN_CONTEXT = "cn=OracleContext,dc=example,dc=com" DIRECTORY_SERVER_TYPE = OID 

但是,当我尝试连接时,我仍然遇到

 $ sqlplus64 'user/password@identifier' ERROR ORA-12154: TNS:could not resolve the connect identifier specified 

此外,通过对sqlplus客户端进行分类,可以看到两个文件( sqlnet.oraldap.ora )至less都被打开了:

 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libsqlplus.so", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libclntsh.so.12.1", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libclntshcore.so.12.1", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libnnz12.so", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libnsl.so.1", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libons.so", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libaio.so.1", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libsqlplusic.so", O_RDONLY|O_CLOEXEC) = 3 open("/usr/lib/oracle/12.1/client64/lib/libociei.so", O_RDONLY|O_CLOEXEC) = 3 open("/etc/oracle/network/admin/oraaccess.xml", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/oracle/network/admin/oraaccess.xml", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/oracle/network/admin/sqlnet.ora", O_RDONLY) = 3 open("/etc/orabasetab", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/oracle/install/orabasetab", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 3 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libnss_nis.so.2", O_RDONLY|O_CLOEXEC) = 3 open("/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3 open("/proc/self/fd/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4 open("/etc/oracle/network/admin/sqlnet.ora", O_RDONLY) = 4 open("/usr/lib64/libnuma.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib64/libnuma.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/proc/sys/kernel/shmmax", O_RDONLY) = 4 open("/proc/meminfo", O_RDONLY) = 4 open("/proc/sys/kernel/shmmax", O_RDONLY) = 4 open("/usr/lib64/libnuma.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/usr/lib64/libnuma.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory) open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 4 open("/etc/hostid", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 4 open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 4 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 4 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4 open("/etc/oracle/ldap/admin/fips.ora", O_RDONLY) = -1 ENOENT (No such file or directory) open("/dev/urandom", O_RDONLY) = 4 open("/dev/urandom", O_RDONLY) = 5 open("entropy", O_RDONLY) = -1 ENOENT (No such file or directory) open("/etc/oracle/ldap/admin/ldap.ora", O_RDONLY) = 6 open("/etc/oracle/ldap/admin/ldap.ora", O_RDONLY) = 6 open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 6 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 6 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 6 open("/lib/x86_64-linux-gnu/libnss_mdns4_minimal.so.2", O_RDONLY|O_CLOEXEC) = 6 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 6 open("/lib/x86_64-linux-gnu/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 6 open("/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 6 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 6 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 6 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 6 open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 6 strace: Process 30041 detached 

请让我知道我错过了什么? 我是一个Oracle新手,所以菜鸟的build议可能会有所帮助!

客户端是安装了oracle即时客户端的ubuntu 16.04服务器:

 oracle-instantclient12.1-devel: 12.1.0.1.0-2 oracle-instantclient12.1-basic: 12.1.0.1.0-2 oracle-instantclient12.1-sqlplus: 12.1.0.1.0-2 oracle-instantclient12.1-odbc: 12.1.0.1.0-2 

您还需要设置TNS_ADMINvariables来指向您的文件所在的文件夹。

例如:

 export TNS_ADMIN=$ORACLE_HOME/ldap/admin 

(它可能指向其他地方默认情况下,或取决于你的环境variables,也许在一个空文件的地方)。 另外,请检查您的文件权限,您的客户端需要能够读取这些文件(644)。

而且还需要确保为数据库使用正确的SID。 你有你的sqlnet.ora文件中的NAMES.DEFAULT_DOMAINvariables设置? 尝试在您的命令中将.world添加到您的SID中,例如:

 sqlplus login/[email protected] 

和/或在你的sqlnet.ora中添加这一行:

 NAMES.DEFAULT_DOMAIN = WORLD 

另外,你还需要检查一下其他的东西,你的数据库是否在OID中正确注册? (通常使用dbca完成)

另一件事:当你浏览OID时,你在“cn = OracleContext,dc = example,dc = com”下看到了什么? 你应该有一个数据库sid( cn = DB_SID,cn = OracleContext,dc = example,dc = com )的条目。 在这个条目中(如果存在的话),你应该有一个包含你的数据库信息(主机,端口和SID,实际上是真正的tns)的“orclnetdescstring”,这个信息是正确的吗? 你的问题可能来自那里 (你尝试联系的数据库条目中的错误描述string,或数据库未正确注册在OID中)..

有许多其他的检查,你需要做的,让我知道如果上述解决你的问题,ty