flink-cdc icon indicating copy to clipboard operation
flink-cdc copied to clipboard

oracle jdbc url 连接不一致导致连接出错

Open GalaxyCenter opened this issue 5 years ago • 9 comments

Describe the bug A clear and concise description of what the bug is.

Environment :

  • Flink version : 1.13.2
  • Flink CDC version: 2.1
  • Database and version: oracle 12c

To Reproduce Steps to reproduce the behavior:

  1. Thes test data :
  2. The test code :
  3. The error :

Additional Description com.ververica.cdc.connectors.oracle.OracleValidator.openConnection 这函数返回的是SID的jdbc url return DriverManager.getConnection( "jdbc:oracle:thin:@" + hostname + ":" + port + ":" + dbname, userName, userpwd);

============================================== io.debezium.connector.oracle.OracleConnection.connectionString 这个函数返回的是 jdbc:oracle:thin:@192.168.0.171:32769/ORCLCDB 服务名方式的jdbc url

=============================== 我的测试ORACLE数据库 服务名ORCLCDB.localhost SID:ORCLCDB

复现: 当我传入 'database-name' = 'ORCLCDB', Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:284) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:340) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1596) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:588) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]
at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_261]
at java.sql.DriverManager.getConnection(DriverManager.java:208) ~[?:1.8.0_261]
at io.debezium.jdbc.JdbcConnection.lambda$patternBasedFactory$0(JdbcConnection.java:179) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.jdbc.JdbcConnection$ConnectionFactoryDecorator.connect(JdbcConnection.java:116) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:872) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.jdbc.JdbcConnection.connection(JdbcConnection.java:867) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.jdbc.JdbcConnection.queryAndMap(JdbcConnection.java:638) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.jdbc.JdbcConnection.queryAndMap(JdbcConnection.java:512) ~[flink-sql-connector-mongodb-cdc-2.1.0.jar:2.1.0]
at io.debezium.connector.oracle.OracleConnection.resolveOracleDatabaseVersion(OracleConnection.java:128) ~[flink-sql-connector-oracle-cdc-2.1.0.jar:2.1.0]

===================================================

而当我传入 'database-name' = 'ORCLCDB.localdomain', ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:854)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.ververica.cdc.connectors.oracle.OracleValidator.openConnection(OracleValidator.java:72)
at com.ververica.cdc.connectors.oracle.OracleValidator.validate(OracleValidator.java:47)
... 12 more

GalaxyCenter avatar Nov 18 '21 11:11 GalaxyCenter

Hi @kuibobo , Firstly you have to make sure that Oracle can be successfully connected using SID. Then, to deal with ORA-12514, you can add the following configurations in listener.ora: SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = ora11g) (ORACLE_HOME = /data/oracle/product/11.2.0/dbhome_1) ) ) Replace SID_NAME and ORACLE_HOME with the correct ones in your environment. And restart the listener.

paul8263 avatar Nov 23 '21 02:11 paul8263

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

rekichan avatar Dec 02 '21 03:12 rekichan

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

Hello@rekichan ,Recently i missed the same errors when i use flink-sql to submit the job.

Have you ever encountered this problem?and how to solve the this problem?

My Flink-sql is :

CREATE TABLE source_ORDERS(ORDER_ID INT,ORDER_DATE TIMESTAMP(0),CUSTOMER_NAME STRING,PRICE DECIMAL(10, 5),PRODUCT_ID INT,ORDER_STATUS BOOLEAN) WITH (
        'connector' = 'oracle-cdc',
        'hostname' = '192.168.110.220',
        'port' = '1521',
        'username' = 'flinkuser',
        'password' = 'flinkpw',
        'database-name' = 'ORCL',
        'schema-name' = 'flinkuser',  
        'table-name' = 'ORDERS',
   
        'debezium.log.mining.strategy' = 'online_catalog',
        'debezium.log.mining.continuous.mine' = 'true'
);

CREATE TABLE sink_ORDERS_kafka_101(ORDER_ID INT,ORDER_DATE TIMESTAMP(0),CUSTOMER_NAME STRING,PRICE DECIMAL(10, 5),PRODUCT_ID INT,ORDER_STATUS BOOLEAN) WITH (
        'connector' = 'kafka',
        'topic' = 'sink_ORDERS_kafka_101_topic',
        'properties.bootstrap.servers' = '192.168.122.139:9092',
        'format' = 'debezium-json'
        );

INSERT INTO sink_ORDERS_kafka_101 SELECT * FROM source_ORDERS;

In Flink web , i got this error:

org.apache.flink.table.api.TableException: Unexpected error while connecting to Oracle and validating

  at com.ververica.cdc.connectors.oracle.OracleValidator.validate(OracleValidator.java:60)

  at com.ververica.cdc.debezium.DebeziumSourceFunction.open(DebeziumSourceFunction.java:215)

  at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:34)

  at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:102)

  at org.apache.flink.streaming.runtime.tasks.OperatorChain.initializeStateAndOpenOperators(OperatorChain.java:442)

  at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:585)

  at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$SynchronizedStreamTaskActionExecutor.call(StreamTaskActionExecutor.java:100)

  at org.apache.flink.streaming.runtime.tasks.StreamTask.executeRestore(StreamTask.java:565)

  at org.apache.flink.streaming.runtime.tasks.StreamTask.runWithCleanUpOnFail(StreamTask.java:650)

  at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:540)

  at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:759)

  at org.apache.flink.runtime.taskmanager.Task.run(Task.java:566)

  at java.lang.Thread.run(Thread.java:748)

Caused by: java.sql.SQLException: Listener refused the connection with the following error:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

 

  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:854)

  at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)

  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:57)

  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:747)

  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:562)

  at java.sql.DriverManager.getConnection(DriverManager.java:664)

  at java.sql.DriverManager.getConnection(DriverManager.java:247)

  at com.ververica.cdc.connectors.oracle.OracleValidator.openConnection(OracleValidator.java:72)

  at com.ververica.cdc.connectors.oracle.OracleValidator.validate(OracleValidator.java:47)

  ... 12 more

Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

 

  at oracle.net.ns.NSProtocolNIO.negotiateConnection(NSProtocolNIO.java:284)

  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:340)

  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1596)

  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:588)

  ... 20 more

My oracle is Oracle 12C RAC

If you can answer questions in your busy schedule, I will be very grateful.

sty945 avatar Dec 22 '21 16:12 sty945

Could you use English for better communication? feel free to reopen once updated the description.

leonardBang avatar Mar 14 '22 08:03 leonardBang

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

非常感谢,根据您的建议,解决了servicename连接RAC的问题

290352095 avatar May 20 '22 01:05 290352095

在用flink-cdc得时候,这个问题该茹姐解决呢? how to solve the problem when use the flink-cdc?

taotao8810 avatar Jul 21 '22 02:07 taotao8810

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

非常感谢,根据您的建议,解决了servicename连接RAC的问题

请问一下这个怎么解决呢,没看懂。。。

tianboluo avatar Aug 12 '22 08:08 tianboluo

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

你好,请问一下怎么解决呢?为什么我这里还是报错? image

xpdgit123 avatar Aug 22 '22 07:08 xpdgit123

Hello @kuibobo. Recently I also met for this problem.You can try to add the debeziumProperties(properties) with the properties that include properties.put("database.url", "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=YES)(FAILOVER=YES)(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=servicename)))"); and config the OracleSource.builder object whose database property is set by your database name OracleSource.builder.database(sid)

你好,请问一下怎么解决呢?为什么我这里还是报错? image

大佬,解决了吗,我也遇到这个问题不知道怎么解决

chenfan331 avatar Sep 17 '22 15:09 chenfan331