clickhouse配置与启动

原创
01/19 12:24
阅读数 2.4K

配置两台服务 8123 8124

8123 配置

启动脚本 startClickhouse.sh

clickhouse=clickhouse1
httpPort=8123
tcpPort=9000
syncPort=9009
homePath=/home/liuax01/clickhouse
configPath=$homePath/$httpPort/config.xml
userPath=$homePath/$httpPort/users.xml
storePath=/data/clickhouse/$httpPort/some_clickhouse_database
logPath=/data/logs/clickhouse/$httpPort
hasClickhouse=`sudo docker ps -a|grep $clickhouse | wc -l`
if [ $hasClickhouse -gt 0 ]; then
   sudo docker start $clickhouse
   echo "start $clickhouse pid=$$"
else

sudo docker run -d --name $clickhouse --ulimit nofile=262144:262144 \
-p $httpPort:8123 -p $tcpPort:9000 -p $syncPort:9009 \
-v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone \
--volume=$storePath:/var/lib/clickhouse \
-v $userPath:/etc/clickhouse-server/users.xml \
-v $configPath:/etc/clickhouse-server/config.xml \
-v $logPath:/var/log/clickhouse-server yandex/clickhouse-server
  echo "run $clickhouse"
fi

启动客户端 clickhouseClient.sh

udo docker stop cc1
sudo docker run -it --rm --name cc1  --link clickhouse1:clickhouse-server \
yandex/clickhouse-client --password A123456a --host clickhouse-server

config.xml 关键配置

   <http_port>8123</http_port>
   <tcp_port>9000</tcp_port>
   <interserver_http_port>9009</interserver_http_port>
 <interserver_http_host>10.0.xxx.xxx</interserver_http_host>
 <listen_host>0.0.0.0</listen_host>
 <max_connections>4096</max_connections>
    <keep_alive_timeout>3</keep_alive_timeout>

    <!-- Maximum number of concurrent queries. -->
    <max_concurrent_queries>100</max_concurrent_queries>
    <timezone>Asia/Shanghai</timezone>

 <remote_servers>
        <bscheck>
           <shard>
           <weight>1</weight>
           <internal_replication>true</internal_replication>
           <replica>
                  <host>10.0.xxx.xxx</host>
                  <port>9000</port>
                  <password>A123456a</password>
                  </replica>
           </shard>
           <shard>
             <weight>1</weight>
            <internal_replication>true</internal_replication>
             <replica>
               <host>10.0.xxx.xxxx</host>
               <port>9001</port>
               <password>A123456a</password>
             </replica>
           </shard>
        </bscheck>
  </remote_servers>

  <zookeeper>
       <node index="1">
         <host>10.0.73.20</host>
         <port>2181</port>
       </node>
   </zookeeper>

<macros>
     <layer>lbrz</layer>
     <shard>lbrz</shard>
     <replica>8123</replica>
   </macros>

users.xml 关键配置

 <default>
            <!-- Maximum memory usage for processing single query, in bytes. -->
            <max_memory_usage>1073741824</max_memory_usage>
           <max_memory_usage_for_all_queries>3221225427</max_memory_usage_for_all_queries>
           <max_query_size>524286</max_query_size>

            <!-- Use cache of uncompressed blocks of data. Meaningful only for processing many of very short queries. -->
            <use_uncompressed_cache>0</use_uncompressed_cache>

            <!-- How to choose between replicas during distributed query processing.
                 random - choose random replica from set of replicas with minimum number of errors
                 nearest_hostname - from set of replicas with minimum number of errors, choose replica
                  with minimum number of different symbols between replica's hostname and local hostname
                  (Hamming distance).
                 in_order - first live replica is chosen in specified order.
            -->
            <load_balancing>random</load_balancing>
        </default>

8124配置

启动脚本 startClickhouse.sh

clickhouse=clickhouse2
httpPort=8124
tcpPort=9001
syncPort=9010
homePath=/home/liuax01/clickhouse
configPath=$homePath/$httpPort/config.xml
userPath=$homePath/$httpPort/users.xml
storePath=/data/clickhouse/$httpPort/some_clickhouse_database
logPath=/data/logs/clickhouse/$httpPort
hasClickhouse=`sudo docker ps -a|grep $clickhouse | wc -l`
if [ $hasClickhouse -gt 0 ]; then
   sudo docker start $clickhouse
   echo "start $clickhouse pid=$$"
else

sudo docker run -d --name $clickhouse --ulimit nofile=262144:262144 \
-p $httpPort:8123 -p $tcpPort:9000 -p $syncPort:9009 \
-v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone \
--volume=$storePath:/var/lib/clickhouse \
-v $userPath:/etc/clickhouse-server/users.xml \
-v $configPath:/etc/clickhouse-server/config.xml \
-v $logPath:/var/log/clickhouse-server yandex/clickhouse-server
  echo "run $clickhouse"
fi

启动客户端 clickhouseClient.sh

sudo docker stop cc2
sudo docker run -it --rm --name cc2  --link clickhouse2:clickhouse-server yandex/clickhouse-client --password A123456a --host clickhouse-server
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部