赞
踩
目录
在这里就不太赘述。官网下载安装包,然后放到一个文件夹中,执行以下命令即可:
rpm -ivh ./*.rpm
安装途中会让你为默认用户指定密码,输入密码或者直接回车键不设置密码。
安装完成后可以直接
clickhouse start
来启动
vim /etc/hosts
- 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
-
- 192.168.10.11 ck-01
- 192.168.10.12 ck-02
- 192.168.10.13 ck-03
修改本机hostname,
- vim /etc/sysconfig/network
-
- HOSTNAME=ck-01
hostnamectl set-hostname ck-01
tar -xzvf apache-zookeeper-3.5.9-bin.tar.gz -C /opt/
解压路径可以自己指定。
进入zookeeper的conf目录下, 将其中的zoo_sample.cfg 文件改名或者复制一份命名为zoo.cfg
并对 zoo.cfg进行配置
- cd /opt/apache-zookeeper-3.5.9-bin/conf/
- cp zoo_sample.cfg zoo.cfg
- vim zoo.cfg
配置文件修改为如下:
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/data/zookeeper/ dataLogDir=/data/log/zookeeper/ # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 server.1=ck-01:2888:3888 server.2=ck-02:2888:3888 server.3=ck-03:2888:3888
其中dataDir是数据存储路径,dataLogDir是日志路径,这个自己指定即可
在设定的dataDir的目录下,创建myid文件并写入1,其他机器分别写入2,3
- cd /data/zookeeper/
- vim myid
- echo 1 > myid
然后进入bin目录下执行启动脚本启动zookeeper
- cd /opt/apache-zookeeper-3.5.9-bin/bin/
- # 启动
- ./zkServer.sh start
- # 查看状态
- ./zkServer.sh status
出现下面这种则表示成功启动成功
\
可以将zookeper的启动加入到环境变量中,避免每次都要进入bin目录才能启动,
- vim /etc/profile
-
- export ZOOKEEPER_HOME=/opt/apache-zookeeper-3.5.9-bin
- export PATH=$PATH:$ZOOKEEPER_HOME/bin
首先在/etc 下创建metrika.xml文件,并输入
-
- <!--集群分片副本相关配置 1分片3副本 -->
- <yandex>
- <clickhouse_remote_servers>
- <!--集群名称 -->
- <clickhouse_1shards_3replicas>
-
- <!-- 第1个分片 -->
- <shard>
- <!-- 是否写入多副本 -->
- <!-- <internal_replication>false</internal_replication> -->
- <!-- 1分片的1副本 -->
- <replica>
- <host>ck-01</host>
- <port>9000</port>
- </replica>
- <!-- 1分片的2副本 -->
- <replica>
- <host>ck-02</host>
- <port>9000</port>
- </replica>
- <!-- 1分片的3副本 -->
- <replica>
- <host>ck-03</host>
- <port>9000</port>
- </replica>
- </shard>
- </clickhouse_1shards_3replicas>
- </clickhouse_remote_servers>
-
-
- <!--zookeeper相关配置-->
-
- <zookeeper-servers>
- <node index="1">
- <host>ck-01</host>
- <port>2181</port>
- </node>
- <node index="2">
- <host>ck-02</host>
- <port>2181</port>
- </node>
- <node index="3">
- <host>ck-03</host>
- <port>2181</port>
- </node>
- </zookeeper-servers>
-
- <!--压缩策略-->
-
- <clickhouse_compression>
- <case>
- <min_part_size>10000000000</min_part_size>
- <min_part_size_ratio>0.01</min_part_size_ratio>
- <method>lz4</method>
- </case>
- </clickhouse_compression>
-
- <!-- 本机绑定地址 -->
-
- <networks>
- <ip>::/0</ip>
- </networks>
-
-
- <macros>
- <shard_name>01</shard_name>
- <replica_name>ck-01</replica_name>
- </macros>
-
-
- </yandex>

<macros>标签下的要根据所配置的机器进行配置,其他两台应该
- <macros>
- <shard_name>02</shard_name>
- <replica_name>ck-02</replica_name>
- </macros>
-
- <macros>
- <shard_name>03</shard_name>
- <replica_name>ck-03</replica_name>
- </macros>
需要注意的是,这个配置文件需要赋予clickhouse权限
chown -R clickhouse:clickhouse /etc/metrika.xml
clickhouse的默认配置文件为/etc/clickhouse-server/config.xml
vim /etc/clickhouse-server/config.xml
- <!--对外开放-->
- <listen_host>::</listen_host>
-
- <!--修改数据路径-->
-
- <path>/data/clickhouse/</path>
-
- <!-- Configuration of clusters that could be used in Distributed tables.
- https://clickhouse.tech/docs/en/operations/table_engines/distributed/
- -->
-
- <zookeeper incl="zookeeper-servers" optional="true" />
- <include_from>/etc/metrika.xml</include_from>
- <macros incl="macros" optional="true" />
-
- <remote_servers incl="clickhouse_remote_servers">

一共需要修改三项,分别是:
1)<listen_hosts> 这个是为了能让外部机器访问
2)<path> 这个是配置数据存储路径,也可以不修改,但是如果修改了路径,则一定要将这个路径的权限改为clickhouse,不然无法启动clickhosue
3)添加上面的配置,使得集群配置生效,如果不配置,则无法启动集群
完成配置后,重新启动clickhouse
clickhouse restart
然后随便一台机器执行
clickhouse-client
然后执行以下语句
select * from system.clusters;
则能看到所配置的集群,集群名称应该为:clickhouse_1shards_3replicas 这个根据自己配置的集群名称不同有所不同
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。