clickhouse
This commit is contained in:
parent
3f092a5ba5
commit
81b3f74c4d
@ -20,32 +20,12 @@ $STD apt-get install -y \
|
|||||||
ca-certificates
|
ca-certificates
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
CLICKHOUSE_DB="rybbit_db" CLICKHOUSE_USER="rybbit" setup_clickhouse
|
||||||
PG_VERSION=17 setup_postgresql
|
PG_VERSION=17 setup_postgresql
|
||||||
NODE_VERSION="20" NODE_MODULE="next" setup_nodejs
|
NODE_VERSION="20" NODE_MODULE="next" setup_nodejs
|
||||||
|
|
||||||
msg_info "Setup Clickhouse Repository"
|
|
||||||
curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' | sudo gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list
|
|
||||||
$STD apt-get update
|
|
||||||
$STD apt-get install -y clickhouse-server clickhouse-client
|
|
||||||
$STD systemctl enable --now clickhouse-server
|
|
||||||
sleep 3
|
|
||||||
msg_ok "Set up Clickhouse Repository"
|
|
||||||
|
|
||||||
msg_info "Setting up Clickhouse Database"
|
|
||||||
CLICKHOUSE_DB="${CLICKHOUSE_DB:-rybbit_db}"
|
|
||||||
CLICKHOUSE_USER="${CLICKHOUSE_USER:-rybbit}"
|
|
||||||
CLICKHOUSE_PASS="${CLICKHOUSE_PASS:-$(openssl rand -base64 18 | cut -c1-13)}"
|
|
||||||
CLICKHOUSE_HOST="localhost"
|
|
||||||
|
|
||||||
clickhouse client --query "CREATE DATABASE IF NOT EXISTS $CLICKHOUSE_DB"
|
|
||||||
clickhouse client --query="CREATE USER IF NOT EXISTS $CLICKHOUSE_USER IDENTIFIED WITH plaintext_password BY '$CLICKHOUSE_PASS'"
|
|
||||||
clickhouse client --query="GRANT ALL ON $CLICKHOUSE_DB.* TO $CLICKHOUSE_USER"
|
|
||||||
#sed -i 's|<default_profile>default</default_profile>|<default_profile>read_only</default_profile>|' /etc/clickhouse-server/users.xml
|
#sed -i 's|<default_profile>default</default_profile>|<default_profile>read_only</default_profile>|' /etc/clickhouse-server/users.xml
|
||||||
#sed -i 's|<default_password></default_password>|<default_password>DISABLED</default_password>|' /etc/clickhouse-server/users.xml
|
#sed -i 's|<default_password></default_password>|<default_password>DISABLED</default_password>|' /etc/clickhouse-server/users.xml
|
||||||
$STD systemctl restart clickhouse-server
|
|
||||||
msg_ok "Set up Clickhouse Database"
|
|
||||||
|
|
||||||
msg_info "Setting up PostgreSQL Database"
|
msg_info "Setting up PostgreSQL Database"
|
||||||
DB_NAME=rybbit_db
|
DB_NAME=rybbit_db
|
||||||
|
@ -1867,3 +1867,59 @@ function setup_ffmpeg() {
|
|||||||
ensure_usr_local_bin_persist
|
ensure_usr_local_bin_persist
|
||||||
msg_ok "Setup FFmpeg $FINAL_VERSION"
|
msg_ok "Setup FFmpeg $FINAL_VERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Installs ClickHouse server and client, sets up DB/user with credentials.
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# - Adds official ClickHouse APT repo with GPG key
|
||||||
|
# - Installs clickhouse-server and clickhouse-client
|
||||||
|
# - Creates database and user (credentials optionally overrideable via env)
|
||||||
|
#
|
||||||
|
# Variables:
|
||||||
|
# CLICKHOUSE_DB - Database name (default: analytics)
|
||||||
|
# CLICKHOUSE_USER - Username (default: analytics_user)
|
||||||
|
# CLICKHOUSE_PASS - Password (default: auto-generated)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function setup_clickhouse() {
|
||||||
|
local CLICKHOUSE_DB="${CLICKHOUSE_DB:-analytics}"
|
||||||
|
local CLICKHOUSE_USER="${CLICKHOUSE_USER:-analytics_user}"
|
||||||
|
local CLICKHOUSE_PASS="${CLICKHOUSE_PASS:-$(openssl rand -base64 18 | cut -c1-13)}"
|
||||||
|
local GPG_URL="https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key"
|
||||||
|
local GPG_KEY_PATH="/usr/share/keyrings/clickhouse-keyring.gpg"
|
||||||
|
local ARCH
|
||||||
|
ARCH=$(dpkg --print-architecture)
|
||||||
|
|
||||||
|
msg_info "Adding ClickHouse repository"
|
||||||
|
if ! getent ahosts packages.clickhouse.com >/dev/null; then
|
||||||
|
msg_error "DNS resolution failed – possibly blocked (AdGuard, Pi-hole)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! curl -fsSL --connect-timeout 10 --retry 3 "$GPG_URL" | gpg --dearmor -o "$GPG_KEY_PATH"; then
|
||||||
|
msg_error "Failed to fetch ClickHouse GPG key"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "deb [signed-by=$GPG_KEY_PATH arch=$ARCH] https://packages.clickhouse.com/deb stable main" >/etc/apt/sources.list.d/clickhouse.list
|
||||||
|
$STD apt-get update
|
||||||
|
|
||||||
|
msg_info "Installing ClickHouse"
|
||||||
|
$STD apt-get install -y clickhouse-server clickhouse-client
|
||||||
|
$STD systemctl enable --now clickhouse-server
|
||||||
|
sleep 3
|
||||||
|
msg_ok "Installed ClickHouse"
|
||||||
|
|
||||||
|
msg_info "Creating ClickHouse DB '$CLICKHOUSE_DB' and user '$CLICKHOUSE_USER'"
|
||||||
|
clickhouse client --query "CREATE DATABASE IF NOT EXISTS $CLICKHOUSE_DB"
|
||||||
|
clickhouse client --query "CREATE USER IF NOT EXISTS $CLICKHOUSE_USER IDENTIFIED WITH plaintext_password BY '$CLICKHOUSE_PASS'"
|
||||||
|
clickhouse client --query "GRANT ALL ON $CLICKHOUSE_DB.* TO $CLICKHOUSE_USER"
|
||||||
|
msg_ok "Created DB and user"
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "ClickHouse DB: $CLICKHOUSE_DB"
|
||||||
|
echo "ClickHouse User: $CLICKHOUSE_USER"
|
||||||
|
echo "ClickHouse Pass: $CLICKHOUSE_PASS"
|
||||||
|
} >>~/clickhouse.creds
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user