kettle 9.3 设置任务日志到数据库 share.xml kettle.properties

单独设置

全局设置

  • 设置 .kettle/shared.xml
<?xml version="1.0" encoding="UTF-8"?>
<sharedobjects>
    <connection>
        <name>qdsjzx_data2</name>
        <server>10.132.81.198</server>
        <type>MYSQL</type>
        <access>Native</access>
        <database>qdsjzx_data2</database>
        <port>3310</port>
        <username>dep</username>
        <password>Encrypted 2befccab847d39797bf1dac249d96aaca</password>
        <servername/>
        <data_tablespace/>
        <index_tablespace/>
        <attributes>
            <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.characterEncoding</code><attribute>utf8</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.serverTimezone</code><attribute>Asia/Shanghai</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.useSSL</code><attribute>false</attribute></attribute>
            <attribute><code>PORT_NUMBER</code><attribute>3310</attribute></attribute>
            <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
            <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
        </attributes>
    </connection>

    <connection>
        <name>sjzb_data</name>
        <server>10.132.81.198</server>
        <type>MYSQL</type>
        <access>Native</access>
        <database>sjzb_data</database>
        <port>3307</port>
        <username>dep</username>
        <password>Encrypted 2be98cbad1a8a8681b80daa729d96aaca</password>
        <servername/>
        <data_tablespace/>
        <index_tablespace/>
        <attributes>
            <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.characterEncoding</code><attribute>utf8</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.serverTimezone</code><attribute>Asia/Shanghai</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MySQL.useSSL</code><attribute>false</attribute></attribute>
            <attribute><code>PORT_NUMBER</code><attribute>3307</attribute></attribute>
            <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
            <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
        </attributes>
    </connection>

    <connection>
        <name>localhost</name>
        <server>localhost</server>
        <type>MYSQL</type>
        <access>Native</access>
        <database>test</database>
        <port>3306</port>
        <username>root</username>
        <password>Encrypted 2be98afc86aa7f2e4cb79ce10cc9da0ce</password>
        <servername/>
        <data_tablespace/>
        <index_tablespace/>
        <attributes>
            <attribute><code>EXTRA_OPTION_MYSQL.defaultFetchSize</code><attribute>500</attribute></attribute>
            <attribute><code>EXTRA_OPTION_MYSQL.useCursorFetch</code><attribute>true</attribute></attribute>
            <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
            <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
            <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
            <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
            <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>Y</attribute></attribute>
            <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
            <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
            <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
            <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
            <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
        </attributes>
    </connection>

</sharedobjects>

  • 也可以右键共享自动保存shared.xml
  • 设置 .kettle/kettle.properties (localhost是链接名字)
KETTLE_TRANS_LOG_DB=localhost
KETTLE_TRANS_LOG_TABLE=r_log_trans

KETTLE_STEP_LOG_DB=localhost
KETTLE_STEP_LOG_TABLE=r_log_trans_step

KETTLE_TRANS_PERFORMANCE_LOG_DB=localhost
KETTLE_TRANS_PERFORMANCE_LOG_TABLE=r_log_trans_step

KETTLE_CHANNEL_LOG_DB=localhost
KETTLE_CHANNEL_LOG_TABLE=r_log_channel

KETTLE_METRICS_LOG_DB=localhost
KETTLE_METRICS_LOG_TABLE=r_log_trans_metrics

设置 java 代码

transMeta.addDatabase(getDatabaseMeta(config));

        TransLogTable origTransLogTable = transMeta.getTransLogTable();
        origTransLogTable.setConnectionName(config.getName());
        origTransLogTable.setTableName("r_log_trans");
        origTransLogTable.setLogFieldUsed(true);
        transMeta.setTransLogTable(origTransLogTable);

        StepLogTable origStepLogTable = transMeta.getStepLogTable();
        origStepLogTable.setConnectionName(config.getName());
        origStepLogTable.setTableName("r_log_trans_step");
        transMeta.setStepLogTable(origStepLogTable);

        PerformanceLogTable origPerformanceLogTable = transMeta.getPerformanceLogTable();
        origPerformanceLogTable.setConnectionName(config.getName());
        origPerformanceLogTable.setTableName("r_log_trans_running");
        transMeta.setPerformanceLogTable(origPerformanceLogTable);

        ChannelLogTable origChannelLogTable = transMeta.getChannelLogTable();
        origChannelLogTable.setConnectionName(config.getName());
        origChannelLogTable.setTableName("r_log_channel");
        transMeta.setChannelLogTable(origChannelLogTable);

        MetricsLogTable origMetricsLogTable = transMeta.getMetricsLogTable();
        origMetricsLogTable.setConnectionName(config.getName());
        origMetricsLogTable.setTableName("r_log_trans_metrics");
        transMeta.setMetricsLogTable(origMetricsLogTable);
posted @ 2023-06-25 17:58  vx_guanchaoguo0  阅读(384)  评论(0编辑  收藏  举报