更新时间:2024-11-29 GMT+08:00

CDL常用业务API

CDL 的业务可以通过Rest API的形式来实现的。具体常用API功能实现方法请参见表1

安全集群默认使用https协议,端口为21495;非安全集群默认使用http协议,端口为21490。

在安全集群中,CDL提供了配置可以同时支持https和http的访问,用户可通过登录FusionInsight Manager,选择“集群 > 待操作集群的名称 > 服务 > CDL > 配置 ”,搜索参数“ http.and.https”并修改此配置项,然后重启服务使配置生效。

表1 API列表

功能

方法

API

入参

健康检查

GET

/api/v1/cdl/health

无参

创建Link

POST

/api/v1/cdl/link

不同Link有不同的入参,具体入参参考接口入参

验证Link

POST

/api/v1/cdl/link?validate=true

同创建Link入参

查看Link

GET

/api/v1/cdl/link

无参

删除Link

DELETE

/api/v1/cdl/link/{link_name}

link_name为具体的link名

更新Link

PUT

/api/v1/cdl/link/{link_name}

link_name为具体的link名,body入参为创建Link时的入参

创建Job

POST

/api/v1/cdl/job

不同Job有不同的入参,具体入参参考接口入参

提交Job

PUT

/api/v1/cdl/job/{job_name}/start

job_name为实际的job名

查看Job

GET

/api/v1/cdl/job

无参, 查询所有job

停止Job

PUT

/api/v1/cdl/job/{job_name}/submissions/{submission_id}/stop

job_name为实际job名, submission_id是提交任务的编号,通过查询job状态接口获取

删除Job

DELETE

/api/v1/cdl/job/{job_name}

job_name为实际job名

查询Job状态

GET

/api/v1/cdl/submissions?jobName={job_name}

job_name为实际job名

接口入参

  • Kafka Link的入参:
    { 
    "name": "kafka_link", 
    "description":"test kafka link", 
    "link-type":"kafka", 
    "enabled":"true", 
    "link-config-values":  { 
    "inputs": [
            { "name": "bootstrap.servers", "value": "10.244.229.232:21007,10.244.229.252:21007" },
            { "name": "sasl.kerberos.service.name", "value": "kafka" },
            { "name": "security.protocol","value": "SASL_PLAINTEXT" }//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ] 
        }
    }
  • MySQL Link的入参:
    { 
    "name": "MySQL_link", //link名,全局唯一,不能重复
    "description":"MySQL connection", //link描述
    "link-type":"mysql", //link的类型
    "enabled":"true",
    "link-config-values":  { 
    "inputs": [
            { "name": "host", "value": "10.244.224.65" }, //数据库安装节点的ip
            { "name": "port", "value": "3306" },//数据库监测的端口
            { "name": "database.name", "value": "demo" }, //连接的数据库名
            { "name": "user", "value": "mysql" }, //用户
            { "name": "password","value": "xxx" } ,//密码
            {"name":"schema", "value":"demo"}//同数据库名
            ] 
        }
    }
  • PostgreSQL Link的入参:
    { 
     "name": "Perf_PGSQL_link", 
     "description":"Perf PGSQL connection", 
     "link-type":"pgsql", 
     "enabled":"true",
     "link-config-values":  { 
     "inputs": [
        { "name": "host", "value": "10.244.224.65" },
        { "name": "port", "value": "5432" },
    
    
        {"name" : "db.name.alias", "value" : "demo"},//数据库名
        { "name": "user", "value": "postgres" }, 
        { "name": "password","value": "xxx" }
        ] 
       }
    }
  • Oracle Link的入参:
    { 
     "name": "Kris_Oracle_DB", 
     "description":"Description", 
     "link-type":"oracle", 
     "enabled":"true",
     "link-config-values":  { 
     "inputs": [
        { "name": "host", "value": "10.244.224.65" },
        { "name": "port", "value": "1521" },
        { "name": "sid", "value": "orcl" }, 
        { "name": "user", "value": "demo" }, 
        { "name": "password","value": "xxx" } 
        ] 
       }
    }
  • HDFS Link的入参:
    { 
     "name": "Kris_HDFS_Link", 
     "description":"test HDFS connection", 
     "link-type":"hdfs", 
     "enabled":"true",
     "link-config-values":  { 
     "inputs": [
    
        { "name": "auth.keytabFile", "value": "/opt/key/user.keytab" },//安全模式参数,非安全模式集群不需要此参数
        { "name": "user", "value": "cdc_test" }, //安全模式参数,非安全模式集群不需要此参数
        { "name": "clusterType", "value": "mrshdfs" }, 
        { "name": "auth.principal","value": "cdc_test@HADOOP.COM" },//安全模式参数,非安全模式集群不需要此参数
        { "name": "hadoop.rpc.protection","value": "privacy" },//安全模式参数,非安全模式集群不需要此参数
        { "name": "auth.type","value": "kerberos" } //安全模式为kerberos,非安全模式为simple
        ] 
       }
    }
  • OBS Link的入参:
    { 
     "name": "Kris_OBS_Link", 
     "description":"test OBS connection", 
     "link-type":"obs", 
     "enabled":"true",
     "link-config-values":  { 
     "inputs": [
        { "name": "endpoint", "value": "https://obs.cn-north-5.myhuaweicloud.com:443" },
        { "name": "bucket", "value": "cdc-mrs" },
        { "name": "ak", "value": "QKGD1H9TLL2VI2SVH5KN" }, 
        { "name": "sk", "value": "ULKazzduVlUlElUAU9U3TeGtW8e8DnuphGJDxhbm" } 
        ] 
       }
    }
  • MySQL Job的config参数:
    "from-config-values": { 
            "inputs": [
                {"name" : "connector.class", "value" : "com.huawei.cdc.connect.mysql.MysqlSourceConnector"},
                {"name" : "schema", "value" : "kris"},
                {"name" : "db.name.alias", "value" : "kris"},
                {"name" : "whitelist", "value" : "TESTMYSQL.*"},
                {"name" : "tables", "value" : "TESTMYSQL.*"},
                {"name" : "tasks.max", "value" : "10"},
                {"name" : "mode", "value" : "insert,update,delete"},
                {"name" : "parse.dml.data", "value" : "true"},
                {"name" : "schema.auto.creation", "value" : "false"},
                {"name" : "errors.tolerance", "value" : "all"},
      	    {"name" : "producer.override.security.protocol", "value" : "SASL_PLAINTEXT"},//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
    	    {"name" : "consumer.override.security.protocol", "value" : "SASL_PLAINTEXT"}//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ]
        }
  • Oracle Job的config参数:
    "from-config-values": { 
            "inputs": [
                {"name" : "connector.class", "value" : "com.huawei.cdc.connect.oracle.OracleSourceConnector"},
                {"name" : "schema", "value" : "DEMO"},
                {"name" : "start.scn", "value" : "27749085"},
                {"name" : "whitelist", "value" : "TESTDATA.*"},
                {"name" : "tables", "value" : "TESTDATA.*"},
                {"name" : "tasks.max", "value" : "1"},
                {"name" : "poll.size", "value" : "1"},
                {"name" : "db.name.alias", "value" : "orcl"},
                {"name" : "mode", "value" : "insert,update,delete"},
                {"name" : "db.fetch.size", "value" : "1"},
                {"name" : "parse.dml.data", "value" : "true"},
                {"name" : "reset.offset", "value" : "false"},
                {"name" : "multitenant", "value" : "false"},
                {"name" : "schema.auto.creation", "value" : "false"},
                {"name" : "connector.client.config.override.policy", "value" : "All"},
                {"name" : "producer.override.security.protocol", "value" : "SASL_PLAINTEXT"}//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ]
        }
  • PostgreSQL Job的config参数:
    "from-config-values": { 
            "inputs": [
                {"name" : "connector.class", "value" : "com.huawei.cdc.connect.pgsql.PgsqlSourceConnector"},
                {"name" : "schema", "value" : "public"},//对应数据库的schema名
                {"name" : "whitelist", "value" : "station311"},
                {"name" : "tables", "value" : "station311"},
                {"name" : "tasks.max", "value" : "30"},
                {"name" : "snapshot.mode", "value" : "never"},
                {"name" : "slot.name", "value" : "performance"},
    
                {"name" : "mode", "value" : "insert,update,delete"},
                {"name" : "schema.auto.creation", "value" : "false"},
                {"name" : "binary.handling.mode", "value":"base64"},
                {"name" : "connector.client.config.override.policy", "value" : "All"},
                {"name" : "producer.override.security.protocol", "value" : "SASL_PLAINTEXT"}//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ]
        }
  • HDFS的Job config参数:
    "to-config-values": {
            "inputs": [
                {"name" : "connector.class", "value" : "com.huawei.cdc.connect.hdfs.HdfsConnector"},
                {"name" : "tasks.max", "value" : "30"},
                {"name" : "topics", "value" : "perf_test_mysql_avro"},
                {"name" : "path", "value" : "/data/"},
    	    {"name" : "errors.tolerance", "value" : "all"},
    	    {"name" : "interval", "value" : "60"},
                {"name" : "tables", "value": "*"},
                {"name" : "mode", "value" : "insert,update,delete"},
                {"name" : "interval", "value" : "1"},	
                {"name" : "cache.size", "value" : "10000"},
                {"name" : "producer.override.security.protocol", "value" : "SASL_PLAINTEXT"},//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
                {"name" : "consumer.override.security.protocol", "value" : "SASL_PLAINTEXT"}//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ]
        }
  • OBS的Job config参数:
    "to-config-values": {
            "inputs": [
                {"name" : "connector.class", "value" : "com.huawei.cdc.connect.obs.ObsConnector"},
                {"name" : "tasks.max", "value" : "1"},
                {"name" : "topics", "value" : "kris_pg_obs"},
                {"name" : "obs.bucket", "value" : "cdc-mrs"},
                {"name" : "path", "value" : "/data/"},
    	    {"name" : "errors.tolerance", "value" : "all"},
    	    {"name" : "interval", "value" : "60"},
                {"name" : "tables", "value": "*"},
                {"name" : "mode", "value" : "insert,update,delete"},
                {"name" : "interval", "value" : "1"},
                {"name" : "consumer.override.security.protocol", "value" : "SASL_PLAINTEXT"}//安全模式为SASL_PLAINTEXT,普通模式为PLAINTEXT
            ]
        }