You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
feat(package_manager): improved cs_package_manager functionality for better UX
- add apt support for community and enterprise install - add enterprise_staging install - filter check results down to os/arch - add --token flag for enterprise (#3002)
This commit is contained in:
@ -1,32 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Documentation
|
# Documentation: bash cs_package_manager.sh help
|
||||||
# ./ cs_package_manager.sh help
|
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
enterprise_token=""
|
enterprise_token=""
|
||||||
dev_drone_key=""
|
dev_drone_key=""
|
||||||
|
|
||||||
if [ ! -f /var/lib/columnstore/local/module ]; then pm="pm1"; else pm=$(cat /var/lib/columnstore/local/module); fi;
|
if [ ! -f /var/lib/columnstore/local/module ]; then pm="pm1"; else pm=$(cat /var/lib/columnstore/local/module); fi;
|
||||||
pm_number=$(echo "$pm" | tr -dc '0-9')
|
pm_number=$(echo "$pm" | tr -dc '0-9')
|
||||||
action=$1
|
action=$1
|
||||||
|
|
||||||
print_help_text() {
|
print_help_text() {
|
||||||
echo "Version 1.0
|
echo "Version 1.1
|
||||||
|
|
||||||
Example Remove:
|
Example Remove:
|
||||||
bash cs_package_manager.sh remove
|
bash $0 remove
|
||||||
bash cs_package_manager.sh remove all
|
bash $0 remove all
|
||||||
|
|
||||||
Example Install:
|
Example Install:
|
||||||
bash cs_package_manager.sh install [enterprise|community|dev] [version|branch] [build num]
|
bash $0 install [enterprise|community|dev] [version|branch] [build num] --token xxxxxxx
|
||||||
bash cs_package_manager.sh install enterprise 10.6.12-8
|
bash $0 install enterprise 10.6.12-8 --token xxxxxx
|
||||||
bash cs_package_manager.sh install community 11.1
|
bash $0 install community 11.1
|
||||||
bash cs_package_manager.sh install dev develop cron/8629
|
bash $0 install dev develop cron/8629
|
||||||
bash cs_package_manager.sh install dev develop-23.02 pull_request/7256
|
bash $0 install dev develop-23.02 pull_request/7256
|
||||||
|
|
||||||
Example Check:
|
Example Check:
|
||||||
bash cs_package_manager.sh check community
|
bash $0 check community
|
||||||
bash cs_package_manager.sh check enterprise
|
bash $0 check enterprise
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,10 +90,15 @@ init_cs_down() {
|
|||||||
# Stop columnstore
|
# Stop columnstore
|
||||||
printf "\n[+] Stopping columnstore ... \n";
|
printf "\n[+] Stopping columnstore ... \n";
|
||||||
if command -v mcs &> /dev/null; then
|
if command -v mcs &> /dev/null; then
|
||||||
if ! mcs cluster stop; then
|
if ! mcs_output=$(mcs cluster stop); then
|
||||||
echo "[!] Failed stopping via mcs ... trying cmapi curl"
|
echo "[!] Failed stopping via mcs ... trying cmapi curl"
|
||||||
stop_cs_cmapi_via_curl
|
stop_cs_cmapi_via_curl
|
||||||
fi
|
fi
|
||||||
|
echo $mcs_output;
|
||||||
|
# Handle Errors with exit 0 code
|
||||||
|
if [ ! -z "$(echo $mcs_output | grep "Internal Server Error")" ];then
|
||||||
|
stop_cs_via_systemctl_override
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
stop_cs_cmapi_via_curl
|
stop_cs_cmapi_via_curl
|
||||||
fi
|
fi
|
||||||
@ -140,6 +143,14 @@ do_yum_remove() {
|
|||||||
# remove offical & custom yum repos
|
# remove offical & custom yum repos
|
||||||
print_and_delete "/etc/yum.repos.d/mariadb.repo"
|
print_and_delete "/etc/yum.repos.d/mariadb.repo"
|
||||||
print_and_delete "/etc/yum.repos.d/drone.repo"
|
print_and_delete "/etc/yum.repos.d/drone.repo"
|
||||||
|
|
||||||
|
if [ "$2" == "all" ]; then
|
||||||
|
printf "\n[+] Removing all columnstore files & dirs\n"
|
||||||
|
print_and_delete "/var/lib/mysql/"
|
||||||
|
print_and_delete "/var/lib/columnstore/"
|
||||||
|
print_and_delete "/etc/my.cnf.d/*"
|
||||||
|
print_and_delete "/etc/columnstore/*"
|
||||||
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_apt_remove() {
|
do_apt_remove() {
|
||||||
@ -160,11 +171,11 @@ do_apt_remove() {
|
|||||||
|
|
||||||
printf "[+] Removing packages - $(date) ... \n"
|
printf "[+] Removing packages - $(date) ... \n"
|
||||||
|
|
||||||
if dpkg-query -s mariadb-server &>/dev/null; then
|
if dpkg-query -s mariadb-server &>/dev/null; then
|
||||||
systemctl stop mariadb
|
systemctl stop mariadb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if dpkg-query -s mariadb-columnstore-cmapi &>/dev/null; then
|
if dpkg-query -s mariadb-columnstore-cmapi &>/dev/null; then
|
||||||
systemctl stop mariadb-columnstore-cmapi
|
systemctl stop mariadb-columnstore-cmapi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -175,7 +186,14 @@ do_apt_remove() {
|
|||||||
|
|
||||||
# remove all current MDB packages
|
# remove all current MDB packages
|
||||||
if [ "$(apt list --installed mariadb-* 2>/dev/null | wc -l)" -gt 1 ]; then
|
if [ "$(apt list --installed mariadb-* 2>/dev/null | wc -l)" -gt 1 ]; then
|
||||||
apt remove mariadb-* -y
|
if [ "$2" == "all" ]; then
|
||||||
|
printf "\n[+] Removing all columnstore files & dirs\n"
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt mariadb-plugin-columnstore mariadb-columnstore-cmapi --purge -y
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt remove --purge -y mariadb-*
|
||||||
|
print_and_delete "/var/lib/mysql/*"
|
||||||
|
else
|
||||||
|
apt remove mariadb-* -y
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove offical & custom yum repos
|
# remove offical & custom yum repos
|
||||||
@ -184,36 +202,27 @@ do_apt_remove() {
|
|||||||
print_and_delete "/etc/apt/sources.list.d/mariadb.list"
|
print_and_delete "/etc/apt/sources.list.d/mariadb.list"
|
||||||
print_and_delete "/etc/apt/sources.list.d/drone.list"
|
print_and_delete "/etc/apt/sources.list.d/drone.list"
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_remove() {
|
do_remove() {
|
||||||
|
|
||||||
check_operating_system
|
check_operating_system
|
||||||
check_package_managers
|
check_package_managers
|
||||||
|
|
||||||
case $distro_info in
|
case $distro_info in
|
||||||
centos | rocky )
|
centos | rocky )
|
||||||
do_yum_remove
|
do_yum_remove "$@"
|
||||||
;;
|
;;
|
||||||
# debian )
|
|
||||||
|
ubuntu | debian )
|
||||||
# ;;
|
do_apt_remove "$@"
|
||||||
ubuntu )
|
|
||||||
do_apt_remove
|
|
||||||
;;
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
echo "\nos & version not implemented: $distro_info\n"
|
echo "\nos & version not implemented: $distro_info\n"
|
||||||
exit 2;
|
exit 2;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$2" == "all" ]; then
|
|
||||||
printf "\n[+] Removing all columnstore files & dirs\n"
|
|
||||||
print_and_delete "/var/lib/mysql/"
|
|
||||||
print_and_delete "/var/lib/columnstore/"
|
|
||||||
print_and_delete "/etc/my.cnf.d/*"
|
|
||||||
print_and_delete "/etc/columnstore/*"
|
|
||||||
fi;
|
|
||||||
|
|
||||||
printf "\n[+] Done\n\n"
|
printf "\n[+] Done\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +272,8 @@ check_operating_system() {
|
|||||||
*) # unknown option
|
*) # unknown option
|
||||||
printf "\ncheck_operating_system: unknown os & version: $distro_info\n"
|
printf "\ncheck_operating_system: unknown os & version: $distro_info\n"
|
||||||
exit 2;
|
exit 2;
|
||||||
esac
|
esac
|
||||||
|
distro_short="${distro_info:0:3}${version_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cpu_architecture() {
|
check_cpu_architecture() {
|
||||||
@ -297,7 +307,7 @@ check_no_mdb_installed() {
|
|||||||
rocky )
|
rocky )
|
||||||
packages=$(yum list installed | grep -i mariadb)
|
packages=$(yum list installed | grep -i mariadb)
|
||||||
;;
|
;;
|
||||||
ubuntu )
|
ubuntu | debian )
|
||||||
packages=$(apt list --installed mariadb-* 2>/dev/null | grep -i mariadb);
|
packages=$(apt list --installed mariadb-* 2>/dev/null | grep -i mariadb);
|
||||||
;;
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
@ -340,22 +350,35 @@ do_enterprise_apt_install() {
|
|||||||
|
|
||||||
# Install MariaDB
|
# Install MariaDB
|
||||||
apt-get clean
|
apt-get clean
|
||||||
apt install mariadb-server -y
|
if ! apt install mariadb-server -y --quiet; then
|
||||||
|
printf "\n[!] Failed to install mariadb-server \n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
sleep 2
|
sleep 2
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable mariadb
|
systemctl enable mariadb
|
||||||
systemctl start mariadb
|
systemctl start mariadb
|
||||||
|
|
||||||
# Install Columnstore
|
# Install Columnstore
|
||||||
apt install mariadb-plugin-columnstore mariadb-columnstore-cmapi jq -y
|
if ! apt install mariadb-plugin-columnstore -y --quiet; then
|
||||||
systemctl daemon-reload
|
printf "\n[!] Failed to install columnstore \n\n"
|
||||||
systemctl enable mariadb-columnstore-cmapi
|
exit 1;
|
||||||
systemctl start mariadb-columnstore-cmapi
|
fi
|
||||||
mariadb -e "show status like '%Columnstore%';"
|
|
||||||
sleep 2
|
if ! apt install mariadb-columnstore-cmapi jq -y --quiet; then
|
||||||
|
printf "\n[!] Failed to install cmapi\n\n"
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
|
||||||
|
else
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable mariadb-columnstore-cmapi
|
||||||
|
systemctl start mariadb-columnstore-cmapi
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
add_primary_node_cmapi
|
||||||
|
fi
|
||||||
|
|
||||||
# Startup cmapi - if defined
|
|
||||||
add_primary_node_cmapi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_enterprise_yum_install() {
|
do_enterprise_yum_install() {
|
||||||
@ -368,50 +391,78 @@ do_enterprise_yum_install() {
|
|||||||
systemctl start mariadb
|
systemctl start mariadb
|
||||||
|
|
||||||
# Install Columnstore
|
# Install Columnstore
|
||||||
yum install MariaDB-columnstore-engine MariaDB-columnstore-cmapi -y
|
if ! yum install MariaDB-columnstore-engine -y; then
|
||||||
systemctl enable mariadb-columnstore-cmapi
|
printf "\n[!] Failed to install columnstore\n\n"
|
||||||
systemctl start mariadb-columnstore-cmapi
|
exit 1;
|
||||||
mariadb -e "show status like '%Columnstore%';"
|
fi
|
||||||
sleep 1;
|
|
||||||
|
# Install Cmapi
|
||||||
|
if ! yum install MariaDB-columnstore-cmapi jq -y; then
|
||||||
|
printf "\n[!] Failed to install cmapi\n\n"
|
||||||
|
|
||||||
|
else
|
||||||
|
systemctl enable mariadb-columnstore-cmapi
|
||||||
|
systemctl start mariadb-columnstore-cmapi
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
sleep 1;
|
||||||
|
|
||||||
|
add_primary_node_cmapi
|
||||||
|
fi
|
||||||
|
|
||||||
# Startup cmapi - if defined
|
|
||||||
add_primary_node_cmapi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enterprise_install() {
|
enterprise_install() {
|
||||||
|
|
||||||
version=$3
|
version=$3
|
||||||
|
check_set_es_token "$@"
|
||||||
if [ -z $enterprise_token ]; then
|
if [ -z $enterprise_token ]; then
|
||||||
printf "Enterprise token empty: $enterprise_token\n"
|
printf "\n[!] Enterprise token empty: $enterprise_token\n"
|
||||||
printf "edit $0 to add token\n\n"
|
printf "edit $0 to add token \n"
|
||||||
|
printf "See: https://customers.mariadb.com/downloads/token/ \n\n"
|
||||||
|
|
||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
if [ -z $version ]; then
|
if [ -z $version ]; then
|
||||||
printf "Version empty: $version\n"
|
printf "\n[!] Version empty: $version\n\n"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "Token: $enterprise_token"
|
echo "Token: $enterprise_token"
|
||||||
echo "MariaDB Version: $version"
|
echo "MariaDB Version: $version"
|
||||||
|
|
||||||
# Download Repo setup
|
url="https://dlm.mariadb.com/enterprise-release-helpers/mariadb_es_repo_setup"
|
||||||
|
if $enterprise_staging; then
|
||||||
|
url="https://dlm.mariadb.com/$enterprise_token/enterprise-release-helpers-staging/mariadb_es_repo_setup"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download Repo setup script
|
||||||
rm -rf mariadb_es_repo_setup
|
rm -rf mariadb_es_repo_setup
|
||||||
wget https://dlm.mariadb.com/enterprise-release-helpers/mariadb_es_repo_setup ;chmod +x mariadb_es_repo_setup;
|
wget $url ;chmod +x mariadb_es_repo_setup;
|
||||||
if ! bash mariadb_es_repo_setup --token="$enterprise_token" --apply --mariadb-server-version="$version"; then
|
if ! bash mariadb_es_repo_setup --token="$enterprise_token" --apply --mariadb-server-version="$version"; then
|
||||||
echo "exiting ..."
|
printf "\n[!] Failed to apply mariadb_es_repo_setup...\n\n"
|
||||||
exit 2;
|
exit 2;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
case $distro_info in
|
case $distro_info in
|
||||||
centos | rocky )
|
centos | rocky )
|
||||||
|
|
||||||
|
if $enterprise_staging; then
|
||||||
|
sed -i 's/mariadb-es-main/mariadb-es-staging/g' /etc/yum.repos.d/mariadb.repo
|
||||||
|
sed -i 's/mariadb-enterprise-server/mariadb-enterprise-staging/g' /etc/yum.repos.d/mariadb.repo
|
||||||
|
printf "\n\n[+] Adjusted mariadb.repo to: mariadb-enterprise-staging\n\n"
|
||||||
|
fi;
|
||||||
|
|
||||||
do_enterprise_yum_install "$@"
|
do_enterprise_yum_install "$@"
|
||||||
;;
|
;;
|
||||||
# debian )
|
ubuntu | debian )
|
||||||
|
|
||||||
# ;;
|
if $enterprise_staging; then
|
||||||
ubuntu )
|
sed -i 's/mariadb-enterprise-server/mariadb-enterprise-staging/g' /etc/apt/sources.list.d/mariadb.list
|
||||||
|
apt update
|
||||||
|
printf "\n\n[+] Adjusted mariadb.list to: mariadb-enterprise-staging\n\n"
|
||||||
|
fi;
|
||||||
|
|
||||||
do_enterprise_apt_install "$@"
|
do_enterprise_apt_install "$@"
|
||||||
;;
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
@ -438,19 +489,85 @@ community_install() {
|
|||||||
echo "version bad. exiting ..."
|
echo "version bad. exiting ..."
|
||||||
exit 2;
|
exit 2;
|
||||||
fi;
|
fi;
|
||||||
yum clean all
|
|
||||||
|
case $distro_info in
|
||||||
|
centos | rocky )
|
||||||
|
do_community_yum_install "$@"
|
||||||
|
;;
|
||||||
|
ubuntu | debian )
|
||||||
|
do_community_apt_install "$@"
|
||||||
|
;;
|
||||||
|
*) # unknown option
|
||||||
|
printf "\nos & version not implemented: $distro_info\n"
|
||||||
|
exit 2;
|
||||||
|
esac
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
do_community_yum_install() {
|
||||||
|
|
||||||
# Install MariaDB then Columnstore
|
# Install MariaDB then Columnstore
|
||||||
yum install MariaDB-server -y
|
yum clean all
|
||||||
|
if ! yum install MariaDB-server -y; then
|
||||||
|
printf "\n[!] Failed to install MariaDB-server \n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
sleep 2;
|
sleep 2;
|
||||||
systemctl enable mariadb
|
systemctl enable mariadb
|
||||||
systemctl start mariadb
|
systemctl start mariadb
|
||||||
yum install MariaDB-columnstore-engine MariaDB-columnstore-cmapi -y
|
|
||||||
systemctl enable mariadb-columnstore-cmapi
|
|
||||||
systemctl start mariadb-columnstore-cmapi
|
|
||||||
mariadb -e "show status like '%Columnstore%';"
|
|
||||||
|
|
||||||
add_primary_node_cmapi
|
# Install Columnstore
|
||||||
|
if ! yum install MariaDB-columnstore-engine -y; then
|
||||||
|
printf "\n[!] Failed to install columnstore \n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Cmapi
|
||||||
|
if ! yum install MariaDB-columnstore-cmapi jq -y; then
|
||||||
|
printf "\n[!] Failed to install cmapi\n\n"
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
systemctl enable mariadb-columnstore-cmapi
|
||||||
|
systemctl start mariadb-columnstore-cmapi
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
add_primary_node_cmapi
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
do_community_apt_install() {
|
||||||
|
|
||||||
|
# Install MariaDB
|
||||||
|
apt-get clean
|
||||||
|
if ! apt install mariadb-server -y --quiet; then
|
||||||
|
printf "\n[!] Failed to install mariadb-server \n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable mariadb
|
||||||
|
systemctl start mariadb
|
||||||
|
|
||||||
|
# Install Columnstore
|
||||||
|
if ! apt install mariadb-plugin-columnstore -y --quiet; then
|
||||||
|
printf "\n[!] Failed to install columnstore \n\n"
|
||||||
|
exit 1;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
if ! apt install mariadb-columnstore-cmapi jq -y --quiet ; then
|
||||||
|
printf "\n[!] Failed to install cmapi \n\n"
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
else
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable mariadb-columnstore-cmapi
|
||||||
|
systemctl start mariadb-columnstore-cmapi
|
||||||
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
add_primary_node_cmapi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
get_set_cmapi_key() {
|
get_set_cmapi_key() {
|
||||||
@ -470,7 +587,7 @@ get_set_cmapi_key() {
|
|||||||
else
|
else
|
||||||
api_key=$(openssl rand -hex 32)
|
api_key=$(openssl rand -hex 32)
|
||||||
fi
|
fi
|
||||||
# mcs cluster set api-key --key $primary_ip
|
|
||||||
echo "[+] Setting API Key:"
|
echo "[+] Setting API Key:"
|
||||||
if curl -s https://127.0.0.1:8640/cmapi/0.4.0/cluster/status \
|
if curl -s https://127.0.0.1:8640/cmapi/0.4.0/cluster/status \
|
||||||
--header 'Content-Type:application/json' \
|
--header 'Content-Type:application/json' \
|
||||||
@ -491,7 +608,7 @@ add_node_cmapi_via_curl() {
|
|||||||
if [ -z $api_key ]; then get_set_cmapi_key; fi;
|
if [ -z $api_key ]; then get_set_cmapi_key; fi;
|
||||||
|
|
||||||
# Add Node
|
# Add Node
|
||||||
printf "\n[+] Adding primary node: \n"
|
printf "\n[+] Adding primary node via curl ... \n"
|
||||||
if curl -k -s -X PUT https://127.0.0.1:8640/cmapi/0.4.0/cluster/node \
|
if curl -k -s -X PUT https://127.0.0.1:8640/cmapi/0.4.0/cluster/node \
|
||||||
--header 'Content-Type:application/json' \
|
--header 'Content-Type:application/json' \
|
||||||
--header "x-api-key:$api_key" \
|
--header "x-api-key:$api_key" \
|
||||||
@ -523,15 +640,27 @@ start_cs_cmapi_via_curl() {
|
|||||||
--data '{"timeout":20}'; then
|
--data '{"timeout":20}'; then
|
||||||
echo "[+] Started Columnstore"
|
echo "[+] Started Columnstore"
|
||||||
else
|
else
|
||||||
echo "[!] Failed to start columnstore"
|
echo " - [!] Failed to start columnstore"
|
||||||
echo "Trying via systemctl ..."
|
echo " - Trying via systemctl ..."
|
||||||
start_cs_via_systemctl
|
start_cs_via_systemctl
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_cs_via_systemctl_override() {
|
||||||
|
systemctl stop mariadb-columnstore-cmapi;
|
||||||
|
systemctl stop mcs-ddlproc;
|
||||||
|
systemctl stop mcs-dmlproc;
|
||||||
|
systemctl stop mcs-workernode@1;
|
||||||
|
systemctl stop mcs-workernode@2;
|
||||||
|
systemctl stop mcs-controllernode;
|
||||||
|
systemctl stop mcs-storagemanager;
|
||||||
|
systemctl stop mcs-primproc;
|
||||||
|
systemctl stop mcs-writeengineserver;
|
||||||
|
}
|
||||||
|
|
||||||
stop_cs_via_systemctl() {
|
stop_cs_via_systemctl() {
|
||||||
if systemctl stop mariadb-columnstore ; then
|
if systemctl stop mariadb-columnstore ; then
|
||||||
echo "[+] Stopped Columnstore"
|
echo "[+] Stopped Columnstore via systemctl"
|
||||||
else
|
else
|
||||||
echo "[!!] Failed to stop columnstore"
|
echo "[!!] Failed to stop columnstore"
|
||||||
exit 1;
|
exit 1;
|
||||||
@ -546,10 +675,10 @@ stop_cs_cmapi_via_curl() {
|
|||||||
--header 'Content-Type:application/json' \
|
--header 'Content-Type:application/json' \
|
||||||
--header "x-api-key:$api_key" \
|
--header "x-api-key:$api_key" \
|
||||||
--data '{"timeout":20}'; then
|
--data '{"timeout":20}'; then
|
||||||
echo "[+] Stopped Columnstore"
|
echo "[+] Stopped Columnstore via curl"
|
||||||
else
|
else
|
||||||
echo "[!] Failed to stop columnstore via cmapi"
|
echo " - [!] Failed to stop columnstore via cmapi"
|
||||||
echo "Trying via systemctl ..."
|
echo " - Trying via systemctl ..."
|
||||||
stop_cs_via_systemctl
|
stop_cs_via_systemctl
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
@ -558,7 +687,7 @@ add_primary_node_cmapi() {
|
|||||||
|
|
||||||
primary_ip="127.0.0.1"
|
primary_ip="127.0.0.1"
|
||||||
get_set_cmapi_key
|
get_set_cmapi_key
|
||||||
|
|
||||||
if ! command -v mcs &> /dev/null ; then
|
if ! command -v mcs &> /dev/null ; then
|
||||||
echo "mcs - binary could not be found"
|
echo "mcs - binary could not be found"
|
||||||
add_node_cmapi_via_curl $primary_ip
|
add_node_cmapi_via_curl $primary_ip
|
||||||
@ -568,7 +697,7 @@ add_primary_node_cmapi() {
|
|||||||
else
|
else
|
||||||
if [ "$(mcs cluster status | jq -r '.num_nodes')" == "0" ]; then
|
if [ "$(mcs cluster status | jq -r '.num_nodes')" == "0" ]; then
|
||||||
|
|
||||||
echo "[+] Adding primary node ..."
|
printf "\n[+] Adding primary node ...\n"
|
||||||
if timeout 30s mcs cluster node add --node $primary_ip; then
|
if timeout 30s mcs cluster node add --node $primary_ip; then
|
||||||
echo "[+] Success adding $primary_ip"
|
echo "[+] Success adding $primary_ip"
|
||||||
else
|
else
|
||||||
@ -625,7 +754,7 @@ enabled=1
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
yum install MariaDB-server-*.rpm -y
|
yum install MariaDB-server-*.rpm -y
|
||||||
yum install MariaDB-columnstore-engine MariaDB-columnstore-cmapi -y
|
yum install MariaDB-columnstore-engine MariaDB-columnstore-cmapi jq -y
|
||||||
systemctl start mariadb
|
systemctl start mariadb
|
||||||
systemctl start mariadb-columnstore-cmapi
|
systemctl start mariadb-columnstore-cmapi
|
||||||
mariadb -e "show status like '%Columnstore%';"
|
mariadb -e "show status like '%Columnstore%';"
|
||||||
@ -640,10 +769,15 @@ do_install() {
|
|||||||
check_no_mdb_installed
|
check_no_mdb_installed
|
||||||
|
|
||||||
repo=$2
|
repo=$2
|
||||||
|
enterprise_staging=false
|
||||||
echo "Repository: $repo"
|
echo "Repository: $repo"
|
||||||
case $repo in
|
case $repo in
|
||||||
enterprise )
|
enterprise )
|
||||||
# pull from public enterprise repo
|
# pull from enterprise repo
|
||||||
|
enterprise_install "$@" ;
|
||||||
|
;;
|
||||||
|
enterprise_staging )
|
||||||
|
enterprise_staging=true
|
||||||
enterprise_install "$@" ;
|
enterprise_install "$@" ;
|
||||||
;;
|
;;
|
||||||
community )
|
community )
|
||||||
@ -651,6 +785,7 @@ do_install() {
|
|||||||
community_install "$@" ;
|
community_install "$@" ;
|
||||||
;;
|
;;
|
||||||
dev )
|
dev )
|
||||||
|
# pull from dev repo - requires dev_drone_key
|
||||||
dev_install "$@" ;
|
dev_install "$@" ;
|
||||||
;;
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
@ -658,36 +793,51 @@ do_install() {
|
|||||||
exit 2;
|
exit 2;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "\nDone - $(date)\n"
|
printf "\nDone\n\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_check() {
|
do_check() {
|
||||||
|
|
||||||
check_operating_system
|
check_operating_system
|
||||||
check_cpu_architecture
|
check_cpu_architecture
|
||||||
|
|
||||||
repo=$2
|
repo=$2
|
||||||
|
dbm_tmp_file="mdb-tmp.html"
|
||||||
echo "Repository: $repo"
|
echo "Repository: $repo"
|
||||||
case $repo in
|
case $repo in
|
||||||
enterprise )
|
enterprise )
|
||||||
|
check_set_es_token "$@"
|
||||||
if [ -z $enterprise_token ]; then
|
if [ -z $enterprise_token ]; then
|
||||||
printf "Enterprise token empty: $enterprise_token\n"
|
printf "\n[!] Enterprise token empty: $enterprise_token\n"
|
||||||
printf "edit $0 to add token\n\n"
|
printf "edit $0 to add token \n"
|
||||||
|
printf "See: https://customers.mariadb.com/downloads/token/ \n\n"
|
||||||
|
|
||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
url_base="https://dlm.mariadb.com"
|
url_base="https://dlm.mariadb.com"
|
||||||
url_page="/browse/$enterprise_token/mariadb_enterprise_server/"
|
url_page="/browse/$enterprise_token/mariadb_enterprise_server/"
|
||||||
ignore="/login"
|
ignore="/login"
|
||||||
curl -s "$url_base$url_page" > mdb-tmp.html
|
at_least_one=false
|
||||||
major_version_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep $url_page | grep -v $ignore )
|
curl -s "$url_base$url_page" > $dbm_tmp_file
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
printf "\n[!] Failed to access $url_base$url_page\n\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if grep -q "404 - Page Not Found" $dbm_tmp_file; then
|
||||||
|
printf "\n[!] 404 - Failed to access $url_base$url_page\n"
|
||||||
|
printf "Confirm your ES token works\n"
|
||||||
|
printf "See: https://customers.mariadb.com/downloads/token/ \n\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
major_version_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep $url_page | grep -v $ignore )
|
||||||
#echo $major_version_links
|
#echo $major_version_links
|
||||||
for major_link in ${major_version_links[@]}
|
for major_link in ${major_version_links[@]}
|
||||||
do
|
do
|
||||||
#echo "Major: $major_link"
|
#echo "Major: $major_link"
|
||||||
curl -s "$url_base$major_link" > mdb-tmp.html
|
curl -s "$url_base$major_link" > $dbm_tmp_file
|
||||||
minor_version_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep $url_page | grep -v $ignore )
|
minor_version_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep $url_page | grep -v $ignore )
|
||||||
for minor_link in ${minor_version_links[@]}
|
for minor_link in ${minor_version_links[@]}
|
||||||
do
|
do
|
||||||
if [ "$minor_link" != "$url_page" ]; then
|
if [ "$minor_link" != "$url_page" ]; then
|
||||||
@ -695,12 +845,12 @@ do_check() {
|
|||||||
case $distro_info in
|
case $distro_info in
|
||||||
centos | rocky )
|
centos | rocky )
|
||||||
path="rpm/rhel/$version_id/$architecture/rpms/"
|
path="rpm/rhel/$version_id/$architecture/rpms/"
|
||||||
curl -s "$url_base$minor_link$path" > mdb-tmp.html
|
curl -s "$url_base$minor_link$path" > $dbm_tmp_file
|
||||||
package_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep "$path" | grep "columnstore-engine" | grep -v debug | tail -1 )
|
package_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep "$path" | grep "columnstore-engine" | grep -v debug | tail -1 )
|
||||||
if [ ! -z "$package_links" ]; then
|
if [ ! -z "$package_links" ]; then
|
||||||
#echo "----------"
|
#echo "----------"
|
||||||
#echo "$package_links"
|
#echo "$package_links"
|
||||||
|
at_least_one=true
|
||||||
mariadb_version="${package_links#*mariadb-enterprise-server/}"
|
mariadb_version="${package_links#*mariadb-enterprise-server/}"
|
||||||
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
||||||
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
||||||
@ -711,42 +861,44 @@ do_check() {
|
|||||||
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
ubuntu )
|
ubuntu | debian )
|
||||||
|
|
||||||
path="deb/pool/main/m/"
|
path="deb/pool/main/m/"
|
||||||
curl -s "$url_base$minor_link$path" > mdb-tmp.html
|
curl -s "$url_base$minor_link$path" > $dbm_tmp_file
|
||||||
|
|
||||||
# unqiue - this link/path can change
|
# unqiue - this link/path can change
|
||||||
mariadb_version_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep -v $ignore | grep -v cmapi | grep ^mariadb )
|
mariadb_version_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep -v $ignore | grep -v cmapi | grep ^mariadb )
|
||||||
#echo "$url_base$minor_link$path"
|
#echo "$url_base$minor_link$path"
|
||||||
for mariadb_link in ${mariadb_version_links[@]}
|
for mariadb_link in ${mariadb_version_links[@]}
|
||||||
do
|
do
|
||||||
#echo $mariadb_link
|
#echo $mariadb_link
|
||||||
path="deb/pool/main/m/$mariadb_link"
|
path="deb/pool/main/m/$mariadb_link"
|
||||||
curl -s "$url_base$minor_link$path" > mdb-tmp.html
|
curl -s "$url_base$minor_link$path" > $dbm_tmp_file
|
||||||
package_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep "$path" | grep "columnstore_" | grep -v debug | tail -1 )
|
package_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep "$path" | grep "columnstore_" | grep -v debug | grep $distro_short | tail -1 )
|
||||||
if [ ! -z "$package_links" ]; then
|
if [ ! -z "$package_links" ]; then
|
||||||
# echo "$package_links"
|
# echo "$package_links"
|
||||||
# echo "----------"
|
# echo "----------"
|
||||||
|
at_least_one=true
|
||||||
mariadb_version="${package_links#*mariadb-enterprise-server/}"
|
mariadb_version="${package_links#*mariadb-enterprise-server/}"
|
||||||
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
||||||
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
||||||
columnstore_version="$( echo $columnstore_version | awk -F"columnstore_" '{print $2}' | awk -F"-" '{print $2}' | awk -F"+maria" '{print $1}' )"
|
columnstore_version="$( echo $columnstore_version | awk -F"columnstore_" '{print $2}' | awk -F"-" '{print $2}' | awk -F"+" '{print $1}' )"
|
||||||
# echo "MariaDB: $mariadb_version Columnstore: $columnstore_version"
|
|
||||||
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
||||||
fi;
|
fi;
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
printf "Not implemented for: $distro_info\n"
|
printf "\nNot implemented for: $distro_info\n\n"
|
||||||
exit 2;
|
exit 2;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
fi;
|
fi;
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if ! $at_least_one; then
|
||||||
|
printf "\n[!] No columnstore packages found for: $distro_short $arch \n\n"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
community )
|
community )
|
||||||
|
|
||||||
@ -754,14 +906,15 @@ do_check() {
|
|||||||
url_base="https://dlm.mariadb.com"
|
url_base="https://dlm.mariadb.com"
|
||||||
url_page="/browse/mariadb_server/"
|
url_page="/browse/mariadb_server/"
|
||||||
ignore="/login"
|
ignore="/login"
|
||||||
curl -s "$url_base$url_page" > mdb-tmp.html
|
at_least_one=false
|
||||||
major_version_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep $url_page | grep -v $ignore )
|
curl -s "$url_base$url_page" > $dbm_tmp_file
|
||||||
|
major_version_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep $url_page | grep -v $ignore )
|
||||||
|
|
||||||
for major_link in ${major_version_links[@]}
|
for major_link in ${major_version_links[@]}
|
||||||
do
|
do
|
||||||
#echo "Major: $major_link"
|
#echo "Major: $major_link"
|
||||||
curl -s "$url_base$major_link" > mdb-tmp.html
|
curl -s "$url_base$major_link" > $dbm_tmp_file
|
||||||
minor_version_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep $url_page | grep -v $ignore )
|
minor_version_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep $url_page | grep -v $ignore )
|
||||||
for minor_link in ${minor_version_links[@]}
|
for minor_link in ${minor_version_links[@]}
|
||||||
do
|
do
|
||||||
if [ "$minor_link" != "$url_page" ]; then
|
if [ "$minor_link" != "$url_page" ]; then
|
||||||
@ -769,11 +922,12 @@ do_check() {
|
|||||||
case $distro_info in
|
case $distro_info in
|
||||||
centos | rocky )
|
centos | rocky )
|
||||||
path="yum/centos/$version_id/$architecture/rpms/"
|
path="yum/centos/$version_id/$architecture/rpms/"
|
||||||
curl -s "$url_base$minor_link$path" > mdb-tmp.html
|
curl -s "$url_base$minor_link$path" > $dbm_tmp_file
|
||||||
package_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep "$path" | grep "columnstore-engine" | grep -v debug | tail -1 )
|
package_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep "$path" | grep "columnstore-engine" | grep -v debug | tail -1 )
|
||||||
if [ ! -z "$package_links" ]; then
|
if [ ! -z "$package_links" ]; then
|
||||||
# echo "$package_links"
|
# echo "$package_links"
|
||||||
# echo "----------"
|
# echo "----------"
|
||||||
|
at_least_one=true
|
||||||
mariadb_version="${package_links#*mariadb-}"
|
mariadb_version="${package_links#*mariadb-}"
|
||||||
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
||||||
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
||||||
@ -782,17 +936,18 @@ do_check() {
|
|||||||
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
||||||
fi;
|
fi;
|
||||||
;;
|
;;
|
||||||
ubuntu )
|
ubuntu | debian )
|
||||||
path="repo/$distro_info/pool/main/m/mariadb/"
|
path="repo/$distro_info/pool/main/m/mariadb/"
|
||||||
curl -s "$url_base$minor_link$path" > mdb-tmp.html
|
curl -s "$url_base$minor_link$path" > $dbm_tmp_file
|
||||||
package_links=$(grep -oP 'href="\K[^"]+' mdb-tmp.html | grep "$path" | grep "columnstore_" | grep -v debug | tail -1 )
|
package_links=$(grep -oP 'href="\K[^"]+' $dbm_tmp_file | grep "$path" | grep "columnstore_" | grep -v debug | grep $distro_short | tail -1 )
|
||||||
if [ ! -z "$package_links" ]; then
|
if [ ! -z "$package_links" ]; then
|
||||||
# echo "$package_links"
|
# echo "$package_links"
|
||||||
# echo "----------"
|
# echo "----------"
|
||||||
|
at_least_one=true
|
||||||
mariadb_version="${package_links#*mariadb-}"
|
mariadb_version="${package_links#*mariadb-}"
|
||||||
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
columnstore_version="${mariadb_version#*columnstore-engine-}"
|
||||||
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
mariadb_version="$( echo $mariadb_version | awk -F/ '{print $1}' )"
|
||||||
columnstore_version="$( echo $columnstore_version | awk -F"columnstore_" '{print $2}' | awk -F"-" '{print $2}' | awk -F"+maria" '{print $1}' )"
|
columnstore_version="$( echo $columnstore_version | awk -F"columnstore_" '{print $2}' | awk -F"-" '{print $2}' | awk -F'\+maria' '{print $1}' 2>/dev/null) "
|
||||||
# echo "MariaDB: $mariadb_version Columnstore: $columnstore_version"
|
# echo "MariaDB: $mariadb_version Columnstore: $columnstore_version"
|
||||||
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
printf "%-8s %-12s %-12s %-12s\n" "MariaDB:" "$mariadb_version" "Columnstore:" "$columnstore_version";
|
||||||
fi;
|
fi;
|
||||||
@ -806,6 +961,10 @@ do_check() {
|
|||||||
fi;
|
fi;
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if ! $at_least_one; then
|
||||||
|
printf "\n[!] No columnstore packages found for: $distro_short $arch \n\n"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
dev )
|
dev )
|
||||||
printf "Not implemented for: $repo\n"
|
printf "Not implemented for: $repo\n"
|
||||||
@ -817,6 +976,36 @@ do_check() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global_dependencies() {
|
||||||
|
if ! command -v curl &> /dev/null; then
|
||||||
|
printf "\n[!] curl not found. Please install curl\n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v wget &> /dev/null; then
|
||||||
|
printf "\n[!] wget not found. Please install wget\n\n"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_set_es_token() {
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
parameter="$1"
|
||||||
|
|
||||||
|
case $parameter in
|
||||||
|
--token)
|
||||||
|
enterprise_token="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
*) # unknown option
|
||||||
|
shift # past argument
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
global_dependencies
|
||||||
|
|
||||||
case $action in
|
case $action in
|
||||||
remove )
|
remove )
|
||||||
@ -832,8 +1021,11 @@ case $action in
|
|||||||
print_help_text;
|
print_help_text;
|
||||||
exit 1;
|
exit 1;
|
||||||
;;
|
;;
|
||||||
|
add )
|
||||||
|
add_node_cmapi_via_curl "127.0.0.1"
|
||||||
|
;;
|
||||||
*) # unknown option
|
*) # unknown option
|
||||||
printf "Unknown Action: $1\n"
|
printf "Unknown Action: $1\n"
|
||||||
print_help_text
|
print_help_text
|
||||||
exit 2;
|
exit 2;
|
||||||
esac
|
esac
|
Reference in New Issue
Block a user