clickhouse部署记录手札 – 记忆角落

clickhouse部署记录手札

/ 0评 / 0

12实例*15node多实例集群部署方案

资源

ip host
10.209.18.201 pod3-mmp1-a-13
10.209.18.202 pod3-mmp1-a-14
10.209.18.205 pod3-mmp1-a-18
10.209.18.208 pod3-mmp1-a-39
10.209.18.21 pod3-mmp1-e-26
10.209.18.212 pod3-mmp1-a-32
10.209.18.219 pod3-mmp1-a-21
10.209.18.22 pod3-mmp1-e-6
10.209.18.23 pod3-mmp1-d-4
10.209.18.24 pod3-mmp1-e-17
10.209.18.25 pod3-mmp1-d-12
10.209.18.26 pod3-mmp1-e-7
10.209.18.27 pod3-mmp1-d-28
10.209.18.28 pod3-mmp1-d-29
10.209.18.29 pod3-mmp1-e-22

依赖

zk三台:

 

安装包

# rpm包 https://github.com/ClickHouse/ClickHouse/
chmod 755 /data0/software/clickhouse/*

clickhouse-client-21.1.2.15-2.noarch.rpm
clickhouse-server-21.1.2.15-2.noarch.rpm
clickhouse-common-static-21.1.2.15-2.x86_64.rpm
clickhouse-common-static-dbg-21.1.2.15-2.x86_64.rpm

yum -y install expect
yum install -y perl perl-devel autoconf libaio

# 安装包路径
/data0/software/clickhouse/
# 数据路径
/data0/clickhouse_data
# 配置文件路径
/data0/software/clickhouse/config
# 日志路径
/data0/clickhouse_data/logs/

 

安装


rpm -ivh /data0/software/clickhouse/clickhouse-common-static-21.1.2.15-2.x86_64.rpm
rpm -ivh /data0/software/clickhouse/clickhouse-common-static-dbg-21.1.2.15-2.x86_64.rpm
rpm -ivh /data0/software/clickhouse/clickhouse-server-21.1.2.15-2.noarch.rpm
rpm -ivh /data0/software/clickhouse/clickhouse-client-21.1.2.15-2.noarch.rpm


# 配置文件
/data0/software/clickhouse/config/config_node0.xml~config_node11.xml
/data0/software/clickhouse/config/metrika_node0.xml~metrika_node11.xml
/data0/software/clickhouse/config/user.xml

 

配置

# config.xml 端口改动
# 9000 tcp
netstat -ntlp|grep 9001
netstat -ntlp|grep 9002
netstat -ntlp|grep 9003
netstat -ntlp|grep 9004
netstat -ntlp|grep 9005
netstat -ntlp|grep 9006
netstat -ntlp|grep 9007
netstat -ntlp|grep 9008
netstat -ntlp|grep 9009
netstat -ntlp|grep 9010
netstat -ntlp|grep 9011
netstat -ntlp|grep 9012

# 9004 interserver_http
netstat -ntlp|grep 9021
netstat -ntlp|grep 9022
netstat -ntlp|grep 9023
netstat -ntlp|grep 9024
netstat -ntlp|grep 9025
netstat -ntlp|grep 9026
netstat -ntlp|grep 9027
netstat -ntlp|grep 9028
netstat -ntlp|grep 9029
netstat -ntlp|grep 9030
netstat -ntlp|grep 9031
netstat -ntlp|grep 9032


# 8123 http
netstat -ntlp|grep 8121
netstat -ntlp|grep 8122
netstat -ntlp|grep 8123
netstat -ntlp|grep 8124
netstat -ntlp|grep 8125
netstat -ntlp|grep 8126
netstat -ntlp|grep 8127
netstat -ntlp|grep 8128
netstat -ntlp|grep 8129
netstat -ntlp|grep 8130
netstat -ntlp|grep 8131
netstat -ntlp|grep 8132

# 9363 prometheus
netstat -ntlp|grep 9361
netstat -ntlp|grep 9362
netstat -ntlp|grep 9363
netstat -ntlp|grep 9364
netstat -ntlp|grep 9365
netstat -ntlp|grep 9366
netstat -ntlp|grep 9367
netstat -ntlp|grep 9368
netstat -ntlp|grep 9369
netstat -ntlp|grep 9370
netstat -ntlp|grep 9371
# 所有节点执行 创建数据目录 配置文件目录 所有的配置文件和日志在一个目录 
mkdir -p /data0/clickhouse_data
mkdir -p /data1/clickhouse_data
mkdir -p /data2/clickhouse_data
mkdir -p /data3/clickhouse_data
mkdir -p /data4/clickhouse_data
mkdir -p /data5/clickhouse_data
mkdir -p /data6/clickhouse_data
mkdir -p /data7/clickhouse_data
mkdir -p /data8/clickhouse_data
mkdir -p /data9/clickhouse_data
mkdir -p /data10/clickhouse_data
mkdir -p /data11/clickhouse_data

mkdir -p /data0/software/clickhouse/config

cp /etc/clickhouse-server/users.xml /data0/software/clickhouse/config/

 

# 复制改名配置文件
cp /etc/clickhouse-server/config.xml /data0/software/clickhouse/config/
cp config.xml config_node0.xml

# 修改node0【修改不做记录,详见下个代码块配置文件】  并复制其他实例的配置文件
cp config_node0.xml config_node1.xml
cp config_node0.xml config_node2.xml
cp config_node0.xml config_node3.xml
cp config_node0.xml config_node4.xml
cp config_node0.xml config_node5.xml
cp config_node0.xml config_node6.xml
cp config_node0.xml config_node7.xml
cp config_node0.xml config_node8.xml
cp config_node0.xml config_node9.xml
cp config_node0.xml config_node10.xml
cp config_node0.xml config_node11.xml

# 更改路径
sed -i "s:/data0/clickhouse_data:/data1/clickhouse_data:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:/data0/clickhouse_data:/data2/clickhouse_data:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:/data0/clickhouse_data:/data3/clickhouse_data:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:/data0/clickhouse_data:/data4/clickhouse_data:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:/data0/clickhouse_data:/data5/clickhouse_data:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:/data0/clickhouse_data:/data6/clickhouse_data:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:/data0/clickhouse_data:/data7/clickhouse_data:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:/data0/clickhouse_data:/data8/clickhouse_data:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:/data0/clickhouse_data:/data9/clickhouse_data:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:/data0/clickhouse_data:/data10/clickhouse_data:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:/data0/clickhouse_data:/data11/clickhouse_data:g" /data0/software/clickhouse/config/config_node11.xml

# 更改端口
sed -i "s:8121:8122:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:8121:8123:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:8121:8124:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:8121:8125:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:8121:8126:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:8121:8127:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:8121:8128:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:8121:8129:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:8121:8130:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:8121:8131:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:8121:8132:g" /data0/software/clickhouse/config/config_node11.xml

sed -i "s:9001:9002:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:9001:9003:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:9001:9004:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:9001:9005:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:9001:9006:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:9001:9007:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:9001:9008:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:9001:9009:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:9001:9010:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:9001:9011:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:9001:9012:g" /data0/software/clickhouse/config/config_node11.xml

sed -i "s:9021:9022:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:9021:9023:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:9021:9024:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:9021:9025:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:9021:9026:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:9021:9027:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:9021:9028:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:9021:9029:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:9021:9030:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:9021:9031:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:9021:9032:g" /data0/software/clickhouse/config/config_node11.xml

sed -i "s:node0:node1:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:node0:node2:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:node0:node3:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:node0:node4:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:node0:node5:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:node0:node6:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:node0:node7:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:node0:node8:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:node0:node9:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:node0:node10:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:node0:node11:g" /data0/software/clickhouse/config/config_node11.xml

sed -i "s:9361:9362:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:9361:9363:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:9361:9364:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:9361:9365:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:9361:9366:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:9361:9367:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:9361:9368:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:9361:9369:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:9361:9370:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:9361:9371:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:9361:9372:g" /data0/software/clickhouse/config/config_node11.xml
<!-- config_node0.xml -->
<?xml version="1.0"?>
<yandex>
    <!--日志-->
    <logger>
        <level>trace</level>
        <log>/data0/clickhouse_data/logs/clickhouse-node0.log</log>
        <errorlog>/data0/clickhouse_data/logs/clickhouse-data0.err.log</errorlog>
        <size>1000M</size>
        <count>10</count>
    </logger>
    <!--本地节点信息-->
    <http_port>8121</http_port>
    <tcp_port>9001</tcp_port>
    <interserver_http_port>9021</interserver_http_port>
    <interserver_http_host>pod3-mmp1-a-13</interserver_http_host>
    <!--本机域名或IP-->
    <!--本地配置-->
    <listen_host>0.0.0.0</listen_host>
    <max_connections>2048</max_connections>
    <!-- <receive_timeout>800</receive_timeout>
             <send_timeout>800</send_timeout> -->
    <keep_alive_timeout>3</keep_alive_timeout>

<!--     <grpc>
                 <enable_ssl>false</enable_ssl>
        <ssl_cert_file>/path/to/ssl_cert_file</ssl_cert_file>
        <ssl_key_file>/path/to/ssl_key_file</ssl_key_file>
        <ssl_require_client_auth>false</ssl_require_client_auth>
        <ssl_ca_cert_file>/path/to/ssl_ca_cert_file</ssl_ca_cert_file>
        <compression>deflate</compression>
        <compression_level>medium</compression_level>
        <max_send_message_size>-1</max_send_message_size>
        <max_receive_message_size>-1</max_receive_message_size>
        <verbose_logs>false</verbose_logs>
    </grpc> -->


    <openSSL>
        <server> 
            <certificateFile>/data0/clickhouse_data/server.crt</certificateFile>
            <privateKeyFile>/data0/clickhouse_data/server.key</privateKeyFile>
            <dhParamsFile>/data0/clickhouse_data/dhparam.pem</dhParamsFile>
            <verificationMode>none</verificationMode>
            <loadDefaultCAFile>true</loadDefaultCAFile>
            <cacheSessions>true</cacheSessions>
            <disableProtocols>sslv2,sslv3</disableProtocols>
            <preferServerCiphers>true</preferServerCiphers>
        </server>

        <client> 
            <loadDefaultCAFile>true</loadDefaultCAFile>
            <cacheSessions>true</cacheSessions>
            <disableProtocols>sslv2,sslv3</disableProtocols>
            <preferServerCiphers>true</preferServerCiphers>
            <invalidCertificateHandler>
                <name>RejectCertificateHandler</name>
            </invalidCertificateHandler>
        </client>
    </openSSL>

    <max_concurrent_queries>100</max_concurrent_queries>
    <max_server_memory_usage>0</max_server_memory_usage>
    <max_thread_pool_size>10000</max_thread_pool_size>
    <max_server_memory_usage_to_ram_ratio>0.9</max_server_memory_usage_to_ram_ratio>
    <total_memory_profiler_step>4194304</total_memory_profiler_step>
    <total_memory_tracker_sample_probability>0</total_memory_tracker_sample_probability>
    <uncompressed_cache_size>8589934592</uncompressed_cache_size>
    <mark_cache_size>5368709120</mark_cache_size>
    <path>/data0/clickhouse_data/</path>
    <tmp_path>/data0/clickhouse_data/tmp/</tmp_path>

    <!-- <users_config>/data/clickhouse/node1/users.xml</users_config> -->
    <user_files_path>/data0/clickhouse_data/user_files/</user_files_path>
    <ldap_servers>
    </ldap_servers>
    <user_directories>
        <users_xml>
            <path>users.xml</path>
        </users_xml>
        <local_directory>
            <path>/data0/clickhouse_data/access/</path>
        </local_directory>
    </user_directories>

    <default_profile>default</default_profile>
    <default_database>default</default_database>
    <!-- Perform mlockall after startup to lower first queries latency
                   and to prevent clickhouse executable from being paged out under high IO load.
         Enabling this option is recommended but will lead to increased startup time for up to a few seconds.
    -->
    <mlock_executable>true</mlock_executable>
    <remap_executable>false</remap_executable>

    <!--集群相关配置 对应metrika文件的标签名-->
    <remote_servers incl="clickhouse_remote_servers" />
    <zookeeper incl="zookeeper-servers" optional="true" />
    <macros incl="macros" optional="true" />
    <include_from>/data0/software/clickhouse/config/metrika_node0.xml</include_from>

    <builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval>
    <max_session_timeout>3600</max_session_timeout>
    <default_session_timeout>300</default_session_timeout>

    <query_log>
        <database>system</database>
        <table>query_log</table>
        <partition_by>toMonday(event_date)</partition_by>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </query_log>

    <trace_log>
        <database>system</database>
        <table>trace_log</table>

        <partition_by>toYYYYMM(event_date)</partition_by>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </trace_log>

    <query_thread_log>
        <database>system</database>
        <table>query_thread_log</table>
        <partition_by>toMonday(event_date)</partition_by>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </query_thread_log>

    <metric_log>
        <database>system</database>
        <table>metric_log</table>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
        <collect_interval_milliseconds>1000</collect_interval_milliseconds>
    </metric_log>

    <asynchronous_metric_log>
        <database>system</database>
        <table>asynchronous_metric_log</table>
        <flush_interval_milliseconds>60000</flush_interval_milliseconds>
    </asynchronous_metric_log>

    <opentelemetry_span_log>
        <engine>
            engine MergeTree
            partition by toYYYYMM(finish_date)
            order by (finish_date, finish_time_us, trace_id)
        </engine>
        <database>system</database>
        <table>opentelemetry_span_log</table>
        <flush_interval_milliseconds>7500</flush_interval_milliseconds>
    </opentelemetry_span_log>


    <crash_log>
        <database>system</database>
        <table>crash_log</table>

        <partition_by />
        <flush_interval_milliseconds>1000</flush_interval_milliseconds>
    </crash_log>

    <dictionaries_config>*_dictionary.xml</dictionaries_config>

    <distributed_ddl>
        <!-- Path in ZooKeeper to queue with DDL queries -->
        <path>/clickhouse/task_queue/ddl</path>
    </distributed_ddl>

    <graphite_rollup_example>
        <pattern>
            <regexp>click_cost</regexp>
            <function>any</function>
            <retention>
                <age>0</age>
                <precision>3600</precision>
            </retention>
            <retention>
                <age>86400</age>
                <precision>60</precision>
            </retention>
        </pattern>
        <default>
            <function>max</function>
            <retention>
                <age>0</age>
                <precision>60</precision>
            </retention>
            <retention>
                <age>3600</age>
                <precision>300</precision>
            </retention>
            <retention>
                <age>86400</age>
                <precision>3600</precision>
            </retention>
        </default>
    </graphite_rollup_example>

    <format_schema_path>/data0/clickhouse_data/format_schemas/</format_schema_path>

    <query_masking_rules>
        <rule>
            <name>hide encrypt/decrypt arguments</name>
            <regexp>((?:aes_)?(?:encrypt|decrypt)(?:_mysql)?)\s*\(\s*(?:'(?:\\'|.)+'|.*?)\s*\)</regexp>
            <replace>\1(???)</replace>
        </rule>
    </query_masking_rules>

    <!-- <merge_tree>
                 <parts_to_delay_insert>300</parts_to_delay_insert>
        <parts_to_throw_insert>600</parts_to_throw_insert>
        <max_delay_to_insert>2</max_delay_to_insert>
    </merge_tree> -->

    <merge_tree>
        <max_suspicious_broken_parts>5</max_suspicious_broken_parts>
    </merge_tree>
    <!-- 不限制drop表 -->
    <max_table_size_to_drop>0</max_table_size_to_drop>
    <max_partition_size_to_drop>0</max_partition_size_to_drop>

    <send_crash_reports>
        <enabled>false</enabled>
        <anonymize>false</anonymize>
        <endpoint>https://6f33034cfe684dd7a3ab9875e57b1c8d@o388870.ingest.sentry.io/5226277</endpoint>
    </send_crash_reports>

    <prometheus>
        <endpoint>/metrics</endpoint>
        <port>9361</port>
        <metrics>true</metrics>
        <events>true</events>
        <asynchronous_metrics>true</asynchronous_metrics>
        <status_info>true</status_info>
    </prometheus>

    <timezone>Asia/Shanghai</timezone>
</yandex>

 

# 由于sed -i 修改了日志目录,重新把日志目录改回来
sed -i "s:/data1/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node1.xml
sed -i "s:/data2/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node2.xml
sed -i "s:/data3/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node3.xml
sed -i "s:/data4/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node4.xml
sed -i "s:/data5/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node5.xml
sed -i "s:/data6/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node6.xml
sed -i "s:/data7/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node7.xml
sed -i "s:/data8/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node8.xml
sed -i "s:/data9/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node9.xml
sed -i "s:/data10/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node10.xml
sed -i "s:/data11/clickhouse_data/logs:/data0/clickhouse_data/logs:g" /data0/software/clickhouse/config/config_node11.xml

 

# 配置文件改完后 scp到其他节点 由于met文件是本地改好上传的,此处将config文件放入config-dir 然后scp

# WY#cluster@2021
scp -rp config-dir root@pod3-mmp1-a-14:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-a-18:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-a-39:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-e-26:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-a-32:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-a-21:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-e-6:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-d-4:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-e-17:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-d-12:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-e-7:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-d-28:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-d-29:/data0/software/clickhouse/config/
scp -rp config-dir root@pod3-mmp1-e-22:/data0/software/clickhouse/config/


# 给每个节点更改host
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-a-14:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-a-18:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-a-39:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-e-26:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-a-32:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-a-21:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-e-6:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-d-4:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-e-17:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-d-12:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-e-7:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-d-28:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-d-29:g" /data0/software/clickhouse/config/config-dir/*
sed -i "s:pod3-mmp1-a-13:pod3-mmp1-e-22:g" /data0/software/clickhouse/config/config-dir/*

 

 

# 操作所有窗口
# 编辑启动脚本
vim /data0/software/clickhouse/start.sh

nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node0.xml --pid-file=/data0/software/clickhouse/config/config_node0.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node1.xml --pid-file=/data0/software/clickhouse/config/config_node1.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node2.xml --pid-file=/data0/software/clickhouse/config/config_node2.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node3.xml --pid-file=/data0/software/clickhouse/config/config_node3.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node4.xml --pid-file=/data0/software/clickhouse/config/config_node4.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node5.xml --pid-file=/data0/software/clickhouse/config/config_node5.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node6.xml --pid-file=/data0/software/clickhouse/config/config_node6.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node7.xml --pid-file=/data0/software/clickhouse/config/config_node7.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node8.xml --pid-file=/data0/software/clickhouse/config/config_node8.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node9.xml --pid-file=/data0/software/clickhouse/config/config_node9.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node10.xml --pid-file=/data0/software/clickhouse/config/config_node10.pid &
nohup /usr/bin/clickhouse-server -C=/data0/software/clickhouse/config/config_node11.xml --pid-file=/data0/software/clickhouse/config/config_node11.pid &

# 保存退出
chmod +x /data0/software/clickhouse/start.sh

# 启动
/data0/software/clickhouse/start.sh

# 检查 应当有看门狗和程序server俩服务 加上ps供25个
ps -ef|grep click
ps -ef|grep click|wc -l


# 验证客户端
clickhouse-client --host pod3-mmp1-a-13 --port 9001
select * from system.clusters;

# 创建集群表要指定集群名 集群名为metr*文件中的标签名ch_cluster_all
create database jikewang on cluster perftest_3shards_1replicas;
CREATE TABLE log_test ON CLUSTER perftest_3shards_1replicas
(
    `ts` DateTime,
    `uid` String,
    `biz` String
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/log_test', '{replica}')
PARTITION BY toYYYYMMDD(ts)
ORDER BY ts;

 

参考文档:

ClickHouse最佳实战之Clickhouse服务配置文件config.xml详解

ClickHouse集群多实例部署

ClickHouse 多实例环境安装

发表评论

您的电子邮箱地址不会被公开。