yum install -y yum-utils
yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
yum install -y clickhouse-server clickhouse-client
clickhouse-server start
至此安装成功。
# 查看启动状态
clickhouse-server status
# 启动
clickhouse-server start
# 停止
clickhouse-server stop
# 重启
clickhouse-server restart
相关配置修改如下:
1、由于默认只能本地访问,所有需要修改配置,将config.xml中的 **<listen_host>::</listen_host>**注释去掉
vim /etc/clickhouse-server/config.xml
# 如果支持IPV6
<listen_host>::</listen_host>
# 如果支持IPV4
<listen_host>0.0.0.0</listen_host>
# 默认数据文件路径:<path>/var/lib/clickhouse/</path>
# 默认日志文件路径:<log>/usr/logs/clickhouse-server/clickhouse-server.log</log>
2、设置密码,这里使用sha256加密密文进行配置,以下命令可以获得明文密码的密文。
echo -n 明文密码 | openssl dgst -sha256
修改users.xml中的配置。
vim /etc/clickhouse-server/users.xml
# 添加如下配置,注意替换自己的密文
<password_sha256_hex>4092f076859881b4939b61b968e234f8474c0f09347770829de2ba6b98a140ba</password_sha256_hex>
注:关于密码配置users.xml文件中给了详细的说明
<users>
<!-- If user name was not specified, 'default' user is used. -->
<default>
<!-- Password could be specified in plaintext or in SHA256 (in hex format).
If you want to specify password in plaintext (not recommended), place it in 'password' element.
Example: <password>qwerty</password>.
Password could be empty.
If you want to specify SHA256, place it in 'password_sha256_hex' element.
Example: <password_sha256_hex>65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5</password_sha256_hex>
Restrictions of SHA256: impossibility to connect to ClickHouse using MySQL JS client (as of July 2019).
If you want to specify double SHA1, place it in 'password_double_sha1_hex' element.
Example: <password_double_sha1_hex>e395796d6546b1b65db9d665cd43f0e858dd4303</password_double_sha1_hex>
How to generate decent password:
Execute: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
In first line will be password and in second - corresponding SHA256.
How to generate double SHA1:
Execute: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-'
In first line will be password and in second - corresponding double SHA1.
-->
<!-- 这个配置属于明文密码 -->
<password>123456</password>
</default>
</users>
配置完成之后重启clickhouse即可!
3、客户端验证
clickhouse-client --password ******