rpm包安装clickhouse指定版本
1.取消打开文件数限制 用ulimit -n 或者ulimit -a查看设置结果 若太小则增加(方法百度哦)
2.clickhouse yum安装
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://packages.clickhouse.com/rpm/clickhouse.repo
sudo yum install -y clickhouse-server-22.3.2.2-2 clickhouse-client-22.3.2.2-2
3.修改clickhouse配置文件
sed -i 's#<password></password>#<password>hun*******</password>#' \
/etc/clickhouse-server/users.xml
<interserver_http_host incl="interserver_http_host"></interserver_http_host>
sed -i 's#<http_port>8123</http_port>#<http_port>8125</http_port>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<tcp_port>9000</tcp_port>#<tcp_port>9002</tcp_port>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<interserver_http_port>9009</interserver_http_port>#<interserver_http_port>9010</interserver_http_port>#' \
/etc/clickhouse-server/config.xml
sudo sed -i 's#<!-- <listen_host>::</listen_host> -->#<listen_host>0.0.0.0</listen_host>#' \
/etc/clickhouse-server/config.xml
mkdir -p /data/udata/clickhouse-rpm/data /data/udata/clickhouse-rpm/log
chmod -R 777 /data/udata/clickhouse-rpm/
sed -i 's#<path>/var/lib/clickhouse/</path>#<path>/data/udata/clickhouse-rpm/data/</path>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<level>trace</level>#<level>information</level>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<log>/var/log/clickhouse-server/clickhouse-server.log</log>#<log>/data/udata/clickhouse-rpm/log/clickhouse-server.log</log>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>#<errorlog>/data/udata/clickhouse-rpm/log/clickhouse-server.err.log</errorlog>#' \
/etc/clickhouse-server/config.xml
sed -i 's#<remote_servers>#<remote_servers incl="remote_servers">#' \
/etc/clickhouse-server/config.xml
<include_from>/etc/clickhouse-server/metrika.xml</include_from>
<zookeeper incl="zookeeper">
</zookeeper>
<macros incl="macros">
</macros>
4.上传metrika.xml配置文件 内容如下,根据实际情况修改
(1) 以下配置为1分片2副本
(2) 2台机器记得修改,分别为:
<macros>
<shard>shard_01</shard>
<replica>replica_01</replica>
</macros>
<macros>
<shard>shard_01</shard>
<replica>replica_02</replica>
</macros>
(3) 2台机器的interserver_http_host分别与remote_servers/udata_clickhouse_cluster/shard/replica/下的host对应
<yandex>
<interserver_http_host>10.20.64.68</interserver_http_host>
<remote_servers>
<udata_clickhouse_cluster>
<shard>
<replica>
<host>10.20.64.68</host>
<port>9002</port>
<user>default</user>
<password>hun******</password>
</replica>
<replica>
<host>10.20.64.224</host>
<port>9000</port>
<user>default</user>
<password>hun******</password>
</replica>
</shard>
</udata_clickhouse_cluster>
</remote_servers>
<zookeeper>
<node index="1">
<host>10.20.64.224</host>
<port>22181</port>
</node>
<!--
<node index="2">
<host>{ip或者host}</host>
<port>2181</port>
</node>
<node index="3">
<host>{ip或者host}</host>
<port>2181</port>
</node>
-->
</zookeeper>
<macros>
<shard>shard_01</shard>
<replica>replica_02</replica>
</macros>
</yandex>
5.启动
service clickhouse-server start
journalctl -u clickhouse-server.service -f
6.其他补充,方便排查错误
vim /usr/lib/systemd/system/clickhouse-server.service
sudo clickhouse-server --config-file=/etc/clickhouse-server/config.xml
|