ClickHouse外部字典表配置

yum install -y unixODBC.x86_64

yum install -y postgresql-odbc.x86_64

vim /etc/odbc.ini

[pg]
Description = Test to pg
Driver = PostgreSQL #与/etc/odbcinst.ini 中一致
Database = postgres
Servername = 192.168.9.139
UserName = admin
Password = admin
Port = 5432
ReadOnly = 0

vim /etc/clickhouse-server/test_dictionary.xml

<dictionaries>
    <dictionary>
        <name>test</name>
        <source>
        <odbc>
                <connection_string>DSN=pg;UID=;PWD=;HOST=;PORT=5432;DATABASE=</connection_string>
                <table>product</table>
            </odbc>
        </source>
        <lifetime>
            <min>300</min>
            <max>360</max>
        </lifetime>
        <layout>
            <hashed/>
        </layout>
        <structure>
            <id>
                <name>id</name>
            </id>
            <attribute>
                <name>del_flag</name>
                <type>UInt64</type>
                <null_value>0</null_value>
            </attribute>
        </structure>
    </dictionary>
</dictionaries>
yum install -y unixODBC.x86_64 yum install -y postgresql-odbc.x86_64 vim /etc/odbc.ini [pg] Description = Test to pg Driver = PostgreSQL #与/etc/odbcinst.ini 中一致 Database = postgres Servername = 192.168.9.139 UserName = admin Password = admin Port = 5432 ReadOnly = 0 vim /etc/clickhouse-server/test_dictionary.xml test DSN=pg;UID=;PWD=;HOST=;PORT=5432;DATABASE= product
300 360 id del_flag UInt64 0
经验分享 程序员 微信小程序 职场和发展