安装clickhouse与使用
docker pull yandex/clickhouse-server
如果pull出现 docker pull yandex/clickhouse-server
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout请换源。另一种方式是用dig命令然后配置hosts。这个方式有可能dig出来的ip都不好使。
如果出现错误:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
则:这是忘记启动docker这个服务了。
service docker start
su root # 先切换到root用户, 再执行以下命令
systemctl enable docker # 开机自动启动docker
systemctl start docker # 启动docker
systemctl restart docker # 重启dokcer
docker run -d --name ck-server --ulimit nofile=262144:262144 -p 8123:8123 -p 9000:9000 -p 9009:9009 yandex/clickhouse-server
docker exec -it ck-server /bin/bash
clickhouse-client #进入数据库
建库、建表、建测试数据(均为本地测试)
go操作
govendor fetch github.com/ClickHouse/clickhouse-go
govendor fetch github.com/jmoiron/sqlx
项目的vendor 目录用的govendor 来管理的
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly解决:git config http.postBuffer 524288000
代码(参考 clickhouse-go 的示例代码)
其他的操作api,在sqlx.go文件中找。readme中有示例。
界面展示
列表展示
参考资料:
*《大数据实时分析领域黑马开源ClickHouse》https://time.geekbang.org/column/article/40817