You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-20 01:42:27 +03:00
299 lines
12 KiB
Bash
Executable File
299 lines
12 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# $Id: post-install 3705 2013-08-07 19:47:20Z dhill $
|
|
#
|
|
# Post-install steps for columnstore install
|
|
|
|
running_systemd() {
|
|
if [ "$(ps --no-headers -o comm 1)" = "systemd" ]; then
|
|
echo 0
|
|
else
|
|
echo 1
|
|
fi
|
|
}
|
|
|
|
find_env_var() {
|
|
env_var_name=$1
|
|
pid=$$
|
|
while [ -z "$ENV_VAR" -a $pid != 1 ]; do
|
|
ppid=$(ps -oppid -p$pid|tail -1|awk '{print $1}')
|
|
env=$(strings /proc/$ppid/environ)
|
|
ENV_VAR=$(echo "$env"|awk -F= "\$1 == \"$env_var_name\" { print \$2; }")
|
|
pid=$ppid
|
|
done
|
|
echo $ENV_VAR
|
|
}
|
|
|
|
checkForError() {
|
|
# check for password error
|
|
grep "ERROR 1045" ${tmpDir}/mysql_install.log > ${tmpDir}/error.check
|
|
if [ `cat ${tmpDir}/error.check | wc -c` -ne 0 ]; then
|
|
echo "MySQL Password file missing or incorrect, check .my.cnf file"
|
|
rm -f ${tmpDir}/error.check
|
|
exit 2;
|
|
fi
|
|
|
|
rm -f ${tmpDir}/error.check
|
|
|
|
#---------------------------------------------------------------------------
|
|
# See if engine columnstore exist
|
|
#---------------------------------------------------------------------------
|
|
echo "checking for engine columnstore..."
|
|
su -s /bin/sh -c 'mysql --execute="show engines"' mysql 2> ${tmpDir}/post-mysql-install.log | grep -i columnstore
|
|
|
|
#
|
|
# Add compressiontype column to SYSCOLUMN if applicable
|
|
#
|
|
if [ $? -ne 0 ]; then
|
|
echo "columnstore doesn't exist"
|
|
exit 1
|
|
fi
|
|
|
|
echo "columnstore exist"
|
|
|
|
return 0;
|
|
}
|
|
|
|
rpmmode=install
|
|
user=`whoami 2>/dev/null`
|
|
|
|
quiet=0
|
|
|
|
stop_mysqld=0
|
|
if [ -z "$(pgrep -x mysqld)" ];then
|
|
|
|
# Startup mysqld
|
|
systemctl cat mariadb.service > /dev/null 2>&1
|
|
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
|
systemctl start mariadb.service
|
|
else
|
|
/usr/bin/mysqld_safe &
|
|
fi
|
|
stop_mysqld=1
|
|
fi
|
|
sleep 2
|
|
|
|
if [ -f @ENGINE_SYSCONFDIR@/columnstore/storagemanager.cnf.rpmsave ]; then
|
|
/bin/cp -f @ENGINE_SYSCONFDIR@/columnstore/storagemanager.cnf @ENGINE_SYSCONFDIR@/columnstore/storagemanager.cnf.new
|
|
/bin/cp -f @ENGINE_SYSCONFDIR@/columnstore/storagemanager.cnf.rpmsave @ENGINE_SYSCONFDIR@/columnstore/storagemanager.cnf
|
|
fi
|
|
|
|
touch /dev/shm/columnstore-test && rm /dev/shm/columnstore-test
|
|
if [ $? -ne 0 ] ; then
|
|
echo "User $user will need R/W access to /dev/shm."
|
|
exit 1
|
|
fi
|
|
|
|
|
|
profileFile="/etc/profile.d/columnstoreAlias.sh"
|
|
/bin/cp -f @ENGINE_SUPPORTDIR@/columnstoreAlias /etc/profile.d/columnstoreAlias.sh
|
|
chmod 644 /etc/profile.d/columnstoreAlias.sh >/dev/null 2>&1
|
|
|
|
test -d /var/log/mariadb/columnstore || mkdir -p /var/log/mariadb/columnstore >/dev/null 2>&1
|
|
test -d /var/log/mariadb/columnstore/archive || mkdir /var/log/mariadb/columnstore/archive >/dev/null 2>&1
|
|
test -d /var/log/mariadb/columnstore/corefiles || mkdir /var/log/mariadb/columnstore/corefiles >/dev/null 2>&1
|
|
test -d /var/log/mariadb/columnstore/trace || mkdir /var/log/mariadb/columnstore/trace >/dev/null 2>&1
|
|
test -h /var/log/mariadb/columnstore/data && rm -f /var/log/mariadb/columnstore/data
|
|
chmod 755 /var/log/mariadb/columnstore/corefiles > /dev/null 2>&1
|
|
|
|
# make sure trace dir is world-writable and sticky
|
|
test -d /var/lib/columnstore/data || mkdir -p /var/lib/columnstore/data
|
|
test -d /var/lib/columnstore/data1/systemFiles/dbrm || mkdir -p /var/lib/columnstore/data1/systemFiles/dbrm
|
|
test -d /var/lib/columnstore/local || mkdir -p /var/lib/columnstore/local
|
|
test -d /var/lib/columnstore/data1/systemFiles/dataTransaction || rmdir /var/lib/columnstore/data1/systemFiles/dataTransaction >/dev/null 2>&1
|
|
test -d /var/lib/columnstore/data1/systemFiles/dataTransaction/archive || rmdir /var/lib/columnstore/data1/systemFiles/dataTransaction/archive >/dev/null 2>&1
|
|
chmod 1755 /var/lib/columnstore/data1 >/dev/null 2>&1
|
|
chmod -R 1755 /var/lib/columnstore/data1/systemFiles >/dev/null 2>&1
|
|
chmod 1755 @ENGINE_SYSCONFDIR@/columnstore > /dev/null 2>&1
|
|
|
|
#create the bulk-load dirs
|
|
mkdir -p /var/lib/columnstore/data/bulk/data/import >/dev/null 2>&1
|
|
mkdir -p /var/lib/columnstore/data/bulk/log >/dev/null 2>&1
|
|
mkdir -p /var/lib/columnstore/data/bulk/job >/dev/null 2>&1
|
|
mkdir -p /var/lib/columnstore/data/bulk/rollback >/dev/null 2>&1
|
|
mkdir -p /var/lib/columnstore/data/bulk/tmpjob >/dev/null 2>&1
|
|
rm -f /var/lib/columnstore/data/bulk/tmpjob/* >/dev/null 2>&1
|
|
|
|
#get columnstore temp file directory name
|
|
tmpDir=/tmp/columnstore_tmp_files
|
|
mkdir $tmpDir >/dev/null 2>&1
|
|
chmod 664 $tmpDir
|
|
|
|
#create mount directories
|
|
mkdir /mnt/tmp > /dev/null 2>&1
|
|
|
|
if [ $user = "root" ]; then
|
|
#setup the columnstore service script
|
|
rm -f /etc/init.d/columnstore >/dev/null 2>&1
|
|
rm -f /etc/default/columnstore
|
|
|
|
systemctl=`which systemctl 2>/dev/null`
|
|
if [ -n "$systemctl" ]; then
|
|
cp @ENGINE_SUPPORTDIR@/mariadb-columnstore.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mariadb-columnstore.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-controllernode.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-controllernode.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-ddlproc.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-ddlproc.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-dmlproc.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-dmlproc.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-exemgr.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-exemgr.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-primproc.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-primproc.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-workernode.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-workernode.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-writeengineserver.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-writeengineserver.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-loadbrm.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-loadbrm.service /lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-storagemanager.service /usr/lib/systemd/system/. >/dev/null 2>&1
|
|
cp @ENGINE_SUPPORTDIR@/mcs-storagemanager.service /lib/systemd/system/. >/dev/null 2>&1
|
|
|
|
|
|
systemctl enable mariadb-columnstore >/dev/null 2>&1
|
|
systemctl enable mcs-controllernode > /dev/null 2>&1
|
|
systemctl enable mcs-ddlproc > /dev/null 2>&1
|
|
systemctl enable mcs-dmlproc > /dev/null 2>&1
|
|
systemctl enable mcs-exemgr > /dev/null 2>&1
|
|
systemctl enable mcs-primproc > /dev/null 2>&1
|
|
systemctl enable mcs-workernode > /dev/null 2>&1
|
|
systemctl enable mcs-writeengineserver > /dev/null 2>&1
|
|
systemctl enable mcs-loadbrm > /dev/null 2>&1
|
|
systemctl enable mcs-storagemanager > /dev/null 2>&1
|
|
else
|
|
chkconfig=`which chkconfig 2>/dev/null`
|
|
if [ -n "$chkconfig" ]; then
|
|
|
|
cp @ENGINE_SBINDIR@/columnstore /etc/init.d/. >/dev/null 2>&1
|
|
chkconfig --add columnstore > /dev/null 2>&1
|
|
chkconfig columnstore on > /dev/null 2>&1
|
|
else
|
|
cp @ENGINE_SBINDIR@/columnstore /etc/init.d/. >/dev/null 2>&1
|
|
updaterc=`which update-rc.d 2>/dev/null`
|
|
if [ -n "$updaterc" ]; then
|
|
|
|
update-rc.d columnstore defaults 99 > /dev/null 2>&1
|
|
else
|
|
echo ""
|
|
echo "Package 'systemctl', 'chkconfig' or 'update-rc.d' not installed, contact your sysadmin if you want to setup to autostart for columnstore"
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ $user = "root" ]; then
|
|
columnstoreSyslogSetup.sh install > $tmpDir/syslog_install.log 2>&1
|
|
|
|
#check if MariaDB Columnstore system logging was setup
|
|
cat $tmpDir/syslog_install.log | grep 'No System Logging' >/dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
cat $tmpDir/syslog_install.log
|
|
fi
|
|
else
|
|
chown $user:$user @ENGINE_SYSCONFDIR@/columnstore/Columnstore.xml
|
|
|
|
cat <<EOD
|
|
|
|
NOTE: For non-root install, you will need to run the following commands as root user to
|
|
setup the MariaDB ColumnStore System Logging
|
|
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
|
|
columnstoreSyslogSetup.sh --user=$user install
|
|
|
|
|
|
EOD
|
|
fi
|
|
|
|
#determine lock file directory
|
|
|
|
# Lock directory for root user
|
|
lockdir='/var/lock/subsys'
|
|
|
|
mcsSetConfig -d Installation LockFileDirectory $lockdir
|
|
|
|
mkdir $lockdir >/dev/null 2>&1
|
|
|
|
rm -f $lockdir/columnstore
|
|
|
|
# This was the last place of postConfigure. RIP
|
|
|
|
/usr/sbin/install_mcs_mysql.sh --tmpdir=$tmpDir
|
|
|
|
# Restart MDB to enable plugin
|
|
systemctl cat mariadb.service > /dev/null 2>&1
|
|
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
|
systemctl restart mariadb.service > /dev/null 2>&1
|
|
else
|
|
pkill mysqld > /dev/null 2>&1
|
|
/usr/bin/mysqld_safe &
|
|
fi
|
|
|
|
checkForError
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing"
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing"
|
|
fi
|
|
|
|
if [ -z "$MCS_USE_S3_STORAGE" ]; then
|
|
MCS_USE_S3_STORAGE="$(find_env_var "MCS_USE_S3_STORAGE")"
|
|
MCS_S3_BUCKET="$(find_env_var "MCS_S3_BUCKET")"
|
|
MCS_S3_ENDPOINT="$(find_env_var "MCS_S3_ENDPOINT")"
|
|
MCS_S3_ACCESS_KEY_ID="$(find_env_var "MCS_S3_ACCESS_KEY_ID")"
|
|
MCS_S3_SECRET_ACCESS_KEY="$(find_env_var "MCS_S3_SECRET_ACCESS_KEY")"
|
|
MCS_S3_REGION="$(find_env_var "MCS_S3_REGION")"
|
|
fi
|
|
|
|
if [ ! -z "$MCS_USE_S3_STORAGE" ] && [ $MCS_USE_S3_STORAGE -eq 1 ]; then
|
|
if [ -z "$MCS_S3_BUCKET" ]; then
|
|
echo "Environmental variable \$MCS_USE_S3_STORAGE is set but there is no \$MCS_S3_BUCKET."
|
|
fi
|
|
if [ -z "$MCS_S3_ENDPOINT" ]; then
|
|
echo "Environmental variable \$MCS_USE_S3_STORAGE is set but there is no \$MCS_S3_ENDPOINT."
|
|
fi
|
|
if [ -z "$MCS_S3_ACCESS_KEY_ID" ]; then
|
|
echo "Environmental variable \$MCS_USE_S3_STORAGE is set but there is no \$MCS_S3_ACCESS_KEY_ID."
|
|
fi
|
|
if [ -z "$MCS_S3_SECRET_ACCESS_KEY" ]; then
|
|
echo "Environmental variable \$MCS_USE_S3_STORAGE is set but there is no \$MCS_S3_SECRET_ACCESS_KEY."
|
|
fi
|
|
if [ -z "$MCS_S3_BUCKET" ] || [ -z "$MCS_S3_ENDPOINT" ] || [ -z "$MCS_S3_ACCESS_KEY_ID" ] || [ -z "$MCS_S3_SECRET_ACCESS_KEY" ]; then
|
|
echo "Using local storage."
|
|
else
|
|
mcsSetConfig -d Installation DBRootStorageType "storagemanager"
|
|
mcsSetConfig -d StorageManager Enabled "Y"
|
|
mcsSetConfig -d SystemConfig DataFilePlugin "libcloudio.so"
|
|
sed -i "s|service =.*|service = S3|" /etc/columnstore/storagemanager.cnf
|
|
if [ ! -z "$MCS_S3_REGION" ]; then
|
|
sed -i "s|region =.*|region = $MCS_S3_REGION|" /etc/columnstore/storagemanager.cnf
|
|
fi
|
|
sed -i "s|bucket =.*|bucket = $MCS_S3_BUCKET|" /etc/columnstore/storagemanager.cnf
|
|
sed -i "s|# endpoint =.*|endpoint = $MCS_S3_ENDPOINT|" /etc/columnstore/storagemanager.cnf
|
|
sed -i "s|# aws_access_key_id =.*|aws_access_key_id = $MCS_S3_ACCESS_KEY_ID|" /etc/columnstore/storagemanager.cnf
|
|
sed -i "s|# aws_secret_access_key =.*|aws_secret_access_key = $MCS_S3_SECRET_ACCESS_KEY|" /etc/columnstore/storagemanager.cnf
|
|
fi
|
|
fi
|
|
|
|
systemctl cat mariadb-columnstore.service > /dev/null 2>&1
|
|
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
|
systemctl start mariadb-columnstore
|
|
sleep 1
|
|
dbbuilder 7 > $tmpDir/dbbuilder.log 2>&1
|
|
fi
|
|
|
|
if [ $stop_mysqld -eq 1 ];then
|
|
# Make sure we stop mariadb since it wasn't running prior to columnstore installation
|
|
systemctl cat mariadb.service > /dev/null 2>&1
|
|
if [ $? -eq 0 ] && [ $(running_systemd) -eq 0 ]; then
|
|
systemctl stop mariadb.service > /dev/null 2>&1
|
|
else
|
|
pkill mysqld > /dev/null 2>&1
|
|
fi
|
|
fi
|
|
|
|
sleep 2
|
|
exit 0
|