如何在docker compose文件中为db2数据库连接配置kafka connect w/“securitymechanism=9,encryptionalgorithm=2”?

pkwftd7m  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(225)

问题:
如何在docker compose文件中为db2数据库连接配置“securitymechanism=9,encryptionalgorithm=2”?
注意:当运行本地kafka安装(kafka 2.13-2.6.0)以连接到网络上的db2数据库时,我只需修改bin/connect-standalone.sh文件,方法是修改现有的“extra\u args=”行,如下所示:

(...)
EXTRA_ARGS=${EXTRA_ARGS-'-name connectStandalone -Ddb2.jcc.securityMechanism=9 -Ddb2.jcc.encryptionAlgorithm=2'}
(...)

效果不错。
然而,当我尝试将同样的想法用于集装箱化的kafka/broker“服务”(docker compose.yml)时,
通过装载一个带有修改过的“connect standalone”文件内容的卷(替换容器中的“/usr/bin/connect standalone”文件),它无法工作。
我确实验证了容器的文件已更改。
…尝试使用kafka jdbc源连接器连接到数据库时收到此异常:

Caused by: com.ibm.db2.jcc.am.SqlInvalidAuthorizationSpecException: [jcc][t4][201][11237][4.25.13] Connection authorization failure occurred.  
Reason: Security mechanism not supported. ERRORCODE=-4214, SQLSTATE=28000

那么,我又该如何在docker-compose.yml中配置securitymechanism/encryptionalgorithm设置呢?
谢谢你的帮助
-塞恩
这是一个docker-compose.yml-你可以看到我在代理(kafka)服务和kafka connect服务中都尝试了用修改过的“connect standalone”文件装载卷。。。两者都没有达到预期的效果

version: '3.8'
services:
    zookeeper:
        image: confluentinc/cp-zookeeper:6.0.0
        container_name: zookeeper       
        ports:
            - "2181:2181"       
        environment:
            ZOOKEEPER_CLIENT_PORT: 2181
            ZOOKEEPER_TICK_TIME: 2000

    kafka:
        image: confluentinc/cp-enterprise-kafka:6.0.0
        container_name: kafka
        depends_on:
            - zookeeper
        ports:
            - "9092:9092"
        environment:
            KAFKA_BROKER_ID: 1
            KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
            KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
            KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
            KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://kafka:9092
            KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
            KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
            KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
            KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 100
            CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: kafka:29092
            CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
            CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
            CONFLUENT_METRICS_ENABLE: 'true'
            CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'
            JVM_OPTS: "-Ddb2.jcc.securityMechanism=9 -Ddb2.jcc.encryptionAlgorithm=2"            
        volumes:       
            - ./connect-standalone:/usr/bin/connect-standalone                           

    schema-registry:
        image: confluentinc/cp-schema-registry:6.0.0
        container_name: schema-registry
        hostname: schema-registry
        depends_on:
            - zookeeper
            - kafka
        ports:
            - "8081:8081"
        environment:
            SCHEMA_REGISTRY_HOST_NAME: schema-registry
            SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
            SCHEMA_REGISTRY_LISTENERS: http://schema-registry:8081

    kafka-connect:
        image: confluentinc/cp-kafka-connect:6.0.0
        container_name: kafka-connect       
        hostname: kafka-connect
        depends_on:
            - kafka
            - schema-registry
        ports:
            - "8083:8083"
        environment:
            CONNECT_BOOTSTRAP_SERVERS: "kafka:29092"
            CONNECT_REST_ADVERTISED_HOST_NAME: "kafka-connect"
            CONNECT_REST_PORT: 8083
            CONNECT_GROUP_ID: kafka-connect
            CONNECT_CONFIG_STORAGE_TOPIC: kafka-connect-configs
            CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
            CONNECT_OFFSET_FLUSH_INTERVAL_MS: 10000
            CONNECT_OFFSET_STORAGE_TOPIC: kafka-connect-offsets
            CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
            CONNECT_STATUS_STORAGE_TOPIC: kafka-connect-status
            CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
            CONNECT_KEY_CONVERTER: org.apache.kafka.connect.storage.StringConverter
            CONNECT_VALUE_CONVERTER: io.confluent.connect.avro.AvroConverter
            CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
            CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
            CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
            CONNECT_ZOOKEEPER_CONNECT: 'zookeeper:2181'
            CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components"
            CONNECT_LOG4J_LOGGERS: org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR
            JVM_OPTS: "-Ddb2.jcc.securityMechanism=9 -Ddb2.jcc.encryptionAlgorithm=2"
        volumes:
            - ./kafka-connect-jdbc-10.0.1.jar:/usr/share/java/kafka-connect-jdbc/kafka-connect-jdbc-10.0.1.jar    
            - ./db2jcc-db2jcc4.jar:/usr/share/java/kafka-connect-jdbc/db2jcc-db2jcc4.jar  
            - ./connect-standalone:/usr/bin/connect-standalone

fwiw,连接器看起来像这样。。。

curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d '{
        "name": "CONNECTOR01",
        "config": {
        "connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector",
        "connection.url":"jdbc:db2://THEDBURL:50000/XXXXX",
        "connection.user":"myuserid",
        "connection.password":"mypassword",
        "poll.interval.ms":"15000",
        "table.whitelist":"YYYYY.TABLEA",
        "topic.prefix":"tbl-",
        "mode":"timestamp",
        "timestamp.initial":"-1",
        "timestamp.column.name":"TIME_UPD",
        "poll.interval.ms":"15000"
        }
    }'
bq8i3lrv

bq8i3lrv1#

尝试使用 KAFKA_OPTS 而不是 JVM_OPTS

相关问题