ClickHouse/tests/config/install.sh

96 lines
4.9 KiB
Bash
Raw Normal View History

2020-09-24 08:35:16 +00:00
#!/bin/bash
# script allows to install configs for clickhouse server and clients required
# for testing (stateless and stateful tests)
set -x -e
DEST_SERVER_PATH="${1:-/etc/clickhouse-server}"
DEST_CLIENT_PATH="${2:-/etc/clickhouse-client}"
SRC_PATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
2020-09-24 10:22:00 +00:00
echo "Going to install test configs from $SRC_PATH into $DEST_SERVER_PATH"
2020-09-24 08:35:16 +00:00
mkdir -p $DEST_SERVER_PATH/config.d/
mkdir -p $DEST_SERVER_PATH/users.d/
mkdir -p $DEST_CLIENT_PATH
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/config.d/zookeeper.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/listen.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/part_log.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/text_log.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/metric_log.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/custom_settings_prefixes.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/macros.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/disks.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/secure_ports.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/clusters.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/graphite.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/database_atomic.xml $DEST_SERVER_PATH/config.d/
2020-10-06 07:13:55 +00:00
ln -sf $SRC_PATH/config.d/max_concurrent_queries.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/test_cluster_with_incorrect_pw.xml $DEST_SERVER_PATH/config.d/
2021-03-29 08:24:56 +00:00
ln -sf $SRC_PATH/config.d/keeper_port.xml $DEST_SERVER_PATH/config.d/
ln -sf $SRC_PATH/config.d/logging_no_rotate.xml $DEST_SERVER_PATH/config.d/
2020-12-07 20:36:47 +00:00
ln -sf $SRC_PATH/config.d/tcp_with_proxy.xml $DEST_SERVER_PATH/config.d/
2020-12-03 21:11:38 +00:00
ln -sf $SRC_PATH/config.d/top_level_domains_lists.xml $DEST_SERVER_PATH/config.d/
2020-12-08 20:58:27 +00:00
ln -sf $SRC_PATH/config.d/top_level_domains_path.xml $DEST_SERVER_PATH/config.d/
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/users.d/log_queries.xml $DEST_SERVER_PATH/users.d/
ln -sf $SRC_PATH/users.d/readonly.xml $DEST_SERVER_PATH/users.d/
ln -sf $SRC_PATH/users.d/access_management.xml $DEST_SERVER_PATH/users.d/
2020-10-13 14:29:24 +00:00
ln -sf $SRC_PATH/users.d/database_atomic_drop_detach_sync.xml $DEST_SERVER_PATH/users.d/
ln -sf $SRC_PATH/users.d/opentelemetry.xml $DEST_SERVER_PATH/users.d/
ln -sf $SRC_PATH/users.d/remote_queries.xml $DEST_SERVER_PATH/users.d/
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/ints_dictionary.xml $DEST_SERVER_PATH/
ln -sf $SRC_PATH/strings_dictionary.xml $DEST_SERVER_PATH/
ln -sf $SRC_PATH/decimals_dictionary.xml $DEST_SERVER_PATH/
ln -sf $SRC_PATH/executable_dictionary.xml $DEST_SERVER_PATH/
2021-03-01 13:57:47 +00:00
ln -sf $SRC_PATH/executable_pool_dictionary.xml $DEST_SERVER_PATH/
2020-09-29 18:55:06 +00:00
2020-12-08 20:58:27 +00:00
ln -sf $SRC_PATH/top_level_domains $DEST_SERVER_PATH/
2020-12-03 21:11:38 +00:00
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/server.key $DEST_SERVER_PATH/
ln -sf $SRC_PATH/server.crt $DEST_SERVER_PATH/
ln -sf $SRC_PATH/dhparam.pem $DEST_SERVER_PATH/
2020-09-24 08:35:16 +00:00
# Retain any pre-existing config and allow ClickHouse to load it if required
2020-09-29 18:55:06 +00:00
ln -sf --backup=simple --suffix=_original.xml \
2020-09-24 10:22:00 +00:00
$SRC_PATH/config.d/query_masking_rules.xml $DEST_SERVER_PATH/config.d/
2020-09-24 08:35:16 +00:00
if [[ -n "$USE_POLYMORPHIC_PARTS" ]] && [[ "$USE_POLYMORPHIC_PARTS" -eq 1 ]]; then
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/config.d/polymorphic_parts.xml $DEST_SERVER_PATH/config.d/
2020-09-24 08:35:16 +00:00
fi
if [[ -n "$USE_DATABASE_ORDINARY" ]] && [[ "$USE_DATABASE_ORDINARY" -eq 1 ]]; then
2020-09-29 18:55:06 +00:00
ln -sf $SRC_PATH/users.d/database_ordinary.xml $DEST_SERVER_PATH/users.d/
2020-09-24 08:35:16 +00:00
fi
2021-02-15 10:26:34 +00:00
if [[ -n "$USE_DATABASE_REPLICATED" ]] && [[ "$USE_DATABASE_REPLICATED" -eq 1 ]]; then
ln -sf $SRC_PATH/users.d/database_replicated.xml $DEST_SERVER_PATH/users.d/
ln -sf $SRC_PATH/config.d/database_replicated.xml $DEST_SERVER_PATH/config.d/
rm /etc/clickhouse-server/config.d/zookeeper.xml
2021-03-29 20:04:50 +00:00
rm /etc/clickhouse-server/config.d/keeper_port.xml
2021-03-13 10:22:48 +00:00
# There is a bug in config reloading, so we cannot override macros using --macros.replica r2
# And we have to copy configs...
mkdir -p /etc/clickhouse-server1
mkdir -p /etc/clickhouse-server2
2021-03-18 12:49:31 +00:00
chown clickhouse /etc/clickhouse-server1
2021-03-13 10:22:48 +00:00
chown clickhouse /etc/clickhouse-server2
2021-03-18 12:49:31 +00:00
chgrp clickhouse /etc/clickhouse-server1
2021-03-13 10:22:48 +00:00
chgrp clickhouse /etc/clickhouse-server2
2021-03-18 12:49:31 +00:00
sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server1
2021-03-13 10:22:48 +00:00
sudo -u clickhouse cp -r /etc/clickhouse-server/* /etc/clickhouse-server2
2021-03-18 12:49:31 +00:00
rm /etc/clickhouse-server1/config.d/macros.xml
2021-03-13 10:22:48 +00:00
rm /etc/clickhouse-server2/config.d/macros.xml
2021-03-18 12:49:31 +00:00
sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|<replica>r1</replica>|<replica>r2</replica>|" > /etc/clickhouse-server1/config.d/macros.xml
sudo -u clickhouse cat /etc/clickhouse-server/config.d/macros.xml | sed "s|<shard>s1</shard>|<shard>s2</shard>|" > /etc/clickhouse-server2/config.d/macros.xml
2021-03-13 10:22:48 +00:00
sudo mkdir -p /var/lib/clickhouse1
sudo mkdir -p /var/lib/clickhouse2
2021-03-18 12:49:31 +00:00
sudo chown clickhouse /var/lib/clickhouse1
2021-03-13 10:22:48 +00:00
sudo chown clickhouse /var/lib/clickhouse2
2021-03-18 12:49:31 +00:00
sudo chgrp clickhouse /var/lib/clickhouse1
2021-03-13 10:22:48 +00:00
sudo chgrp clickhouse /var/lib/clickhouse2
2021-02-15 10:26:34 +00:00
fi
2020-09-24 08:35:16 +00:00
ln -sf $SRC_PATH/client_config.xml $DEST_CLIENT_PATH/config.xml