拉取镜像
最新镜像不加版本号即可
docker pull clickhouse/clickhouse-server:latest
宿主机创建目录
mkdir -p /usr/local/docker/clickhouse/conf /usr/local/docker/clickhouse/data /usr/lcoal/docker/clickhouse/log
启动临时容器获取配置文件
docker run --rm -d --name=temp-clickhouse-server clickhouse/clickhouse-server:latest
复制配置文件到宿主机
docker cp temp-clickhouse-server:/etc/clickhouse-server/users.xml /usr/local/docker/clickhouse/conf/users.xml docker cp temp-clickhouse-server:/etc/clickhouse-server/config.xml /usr/local/docker/clickhouse/conf/config.xml
启动clickhouse
docker run -d --name=clickhouse-server \ -p 8123:8123 \ --volume=/usr/local/docker/clickhouse/conf/config.xml:/etc/clickhouse-server/config.xml \ --volume=/usr/local/docker/clickhouse/conf/users.xml:/etc/clickhouse-server/users.xml \ --volume=/usr/local/docker/clickhouse/data:/var/lib/clickhouse/ \ clickhouse/clickhouse-server:latest
修改用户名密码 test/123456
<users> <test> <password_double_sha1_hex>5d12e69be56929e66554d5f6a6628715e929d9fd</password_double_sha1_hex> <networks incl="networks" replace="replace"> <ip>::/0</ip> </networks> <profile>default</profile> <quota>default</quota> </test> </users>
备注:快速测试默认账户为default 密码为空
生成密码算法:SHA256和SHA1算法秘钥
SHA1 PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | openssl dgst -sha1 -binary | openssl dgst -sha1 PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' //两种加密在linux macos系统终端执行就好,第一行是你的密码(连接服务器使用),第二行是加密算法值 也就是需要配置的值。当然,这两种算法配置的xml节点不一样: SHA1 password_double_sha1_hex SHA256 password_sha256_hex
登录clickhouse
clickhouse-client -h ip地址 -d default -m -u default --password 123456
开放外网访问,vim config.xml 找到 listen_host 标签,修改为以下
<listen_host>0.0.0.0</listen_host>
在default库下新建表
create table t_user ( userId Int32, appId String, version String, regTime Date ) engine = MergeTree PARTITION BY toYYYYMM(regTime) ORDER BY userId SETTINGS index_granularity = 1;
标签:xml,部署,server,usr,docker,local,clickhouse From: https://www.cnblogs.com/cgy-home/p/18122426