sudo service clickhouse-server start clickhouse-client # or "clickhouse-client --password" if you've set up a password.
填写default user的初始密码,回车可以看到如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Enter password for default user: Password for default user is saved in file /etc/clickhouse-server/users.d/default-password.xml. Setting capabilities for clickhouse binary. This is optional. Cannot set 'net_admin' or 'ipc_lock' or 'sys_nice' or 'net_bind_service' capability for clickhouse binary. This is optional. Taskstats accounting will be disabled. To enable taskstats accounting you may add the required capability later manually. chown -R clickhouse:clickhouse '/etc/clickhouse-server'
lintong@master:~$ sudo clickhouse start chown -R clickhouse: '/var/run/clickhouse-server/' Will run sudo --preserve-env -u 'clickhouse' /usr/bin/clickhouse-server --config-file /etc/clickhouse-server/config.xml --pid-file /var/run/clickhouse-server/clickhouse-server.pid --daemon Waiting for server to start Waiting for server to start Server started
连接clickhouse
1 2 3 4 5 6 7
lintong@master:~$ clickhouse-client ClickHouse client version 23.10.3.5 (official build). Connecting to localhost:9000 as user default. Password for user (default): Connecting to localhost:9000 as user default. Connected to ClickHouse server version 23.10.3 revision 54466.
client使用的9000端口
访问的话可以看到如下说明,如果想要使用http连接的话,需要使用8123端口
1 2 3
Port 9000 is for clickhouse-client program You must use port 8123 for HTTP.
INSERT INTO helloworld.my_first_table (user_id, message, timestamp, metric) VALUES (101, 'Hello, ClickHouse!', now(), -1.0 ), (102, 'Insert a lot of rows per batch', yesterday(), 1.41421 ), (102, 'Sort your data based on your commonly-used queries', today(), 2.718 ), (101, 'Granules are the smallest chunks of data read', now() + 5, 3.14159 )