您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“python連接clickhouse端口報錯怎么解決”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠?qū)W有所成!
<!-- It is the name that will be shown in the clickhouse-client. By default, anything with "production" will be highlighted in red in query prompt. --> <!--display_name>production</display_name--> <!-- Port for HTTP API. See also 'https_port' for secure connections. This interface is also used by ODBC and JDBC drivers (DataGrip, Dbeaver, ...) and by most of web interfaces (embedded UI, Grafana, Redash, ...). --> <http_port>8123</http_port> <!-- Port for interaction by native protocol with: - clickhouse-client and other native ClickHouse tools (clickhouse-benchmark, clickhouse-copier); - clickhouse-server with other clickhouse-servers for distributed query processing; - ClickHouse drivers and applications supporting native protocol (this protocol is also informally called as "the TCP protocol"); See also 'tcp_port_secure' for secure connections. --> <tcp_port>9000</tcp_port>
注意到可以使用兩個端口,8123 和 9000 分別接收 http 協(xié)議和tcp協(xié)議。
如果用jdbc連接,端口為 8123
如果用driver連接,端口為 9000
from clickhouse_driver import Client client = Client(host=host, port=port, user=user, password=password, database='default') client = get_client() client.execute("show tables;") print(client.execute("select * from test_arr")) client.disconnect()
此時如果用8123端口則會得到如下報錯:
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102. Unexpected packet from server 192.168.137.101:8123 (expected Hello or Exception, got Unknown packet)
clickhouse_driver.errors.UnexpectedPacketFromServerError: Code: 102
今天用python寫個etl從mysql向clickhouse同步數(shù)據(jù), 數(shù)據(jù)量不到1千萬,導(dǎo)了一會報上面的第錯誤。然后在網(wǎng)上查了一下:找到文檔寫得很清楚:
Welcome to clickhouse-driver — clickhouse-driver 0.2.4 documentation
原來clickhouse提供兩個端口:8123和9000
用native protocal需要使用9000端口,然后修改端口后成功。
“python連接clickhouse端口報錯怎么解決”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。