You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-30 19:23:07 +03:00
Make mysqld work without systemd
ColumnStore should now start/stop mysqld where the systemd service is not available.
This commit is contained in:
@ -25,7 +25,14 @@ done
|
||||
|
||||
#stop services
|
||||
columnstore stop > /dev/null 2>&1
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
|
||||
cloud=`mcsGetConfig Installation Cloud`
|
||||
if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then
|
||||
|
@ -90,7 +90,13 @@ stop() {
|
||||
RETVAL=$?
|
||||
rm -f $lockdir/columnstore
|
||||
fuser -k 8604/tcp > /dev/null 2>&1
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
pkill ProcMon
|
||||
pkill ProcMgr
|
||||
return $RETVAL
|
||||
|
@ -11,7 +11,13 @@ checkForError() {
|
||||
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
|
||||
systemctl stop mysqld.service
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
sleep 2
|
||||
exit 2;
|
||||
fi
|
||||
@ -54,10 +60,22 @@ for arg in "$@"; do
|
||||
done
|
||||
|
||||
# Restart in the same way that mysqld will be started normally.
|
||||
systemctl stop mariadb.service >/dev/null 2>&1
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
sleep 2
|
||||
export MYSQL_OPTS="--skip-grant-tables"
|
||||
systemctl start mariadb.service
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl start mariadb.service
|
||||
else
|
||||
/usr/bin/mysqld_safe --skip-grant-tables &
|
||||
fi
|
||||
unset MYSQL_OPTS
|
||||
|
||||
sleep 5
|
||||
@ -67,12 +85,24 @@ install_mcs_mysql.sh --tmpdir=$tmpdir
|
||||
checkForError
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing"
|
||||
systemctl stop mariadb.service
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
sleep 2
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
systemctl stop mariadb.service
|
||||
# Test we are using systemd
|
||||
systemctl cat mariadb.service > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
systemctl stop mariadb.service > /dev/null 2>&1
|
||||
else
|
||||
pkill mysqld
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
|
@ -7796,16 +7796,26 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
|
||||
|
||||
string pidtmp = tmpdir + "/mysql.pid";
|
||||
|
||||
int no_systemd = system("systemctl cat mariadb.server > /dev/null 2>&1");
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MYSQL_START:
|
||||
{
|
||||
if (no_systemd)
|
||||
{
|
||||
system("/usr/bin/mysqld_safe &");
|
||||
}
|
||||
command = "start";
|
||||
break;
|
||||
}
|
||||
|
||||
case MYSQL_STOP:
|
||||
{
|
||||
if (no_systemd)
|
||||
{
|
||||
system("pkill mysqld");
|
||||
}
|
||||
command = "stop";
|
||||
|
||||
//set process status
|
||||
@ -7821,18 +7831,31 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
|
||||
|
||||
case MYSQL_RESTART:
|
||||
{
|
||||
if (no_systemd)
|
||||
{
|
||||
system("pkill mysqld");
|
||||
system("/usr/bin/mysqld_safe &");
|
||||
}
|
||||
command = "restart";
|
||||
break;
|
||||
}
|
||||
|
||||
case MYSQL_RELOAD:
|
||||
{
|
||||
if (no_systemd)
|
||||
{
|
||||
system("pkill -HUP mysqld");
|
||||
}
|
||||
command = "reload";
|
||||
break;
|
||||
}
|
||||
|
||||
case MYSQL_FORCE_RELOAD:
|
||||
{
|
||||
if (no_systemd)
|
||||
{
|
||||
system("pkill -HUP mysqld");
|
||||
}
|
||||
command = "force-reload";
|
||||
break;
|
||||
}
|
||||
@ -7851,20 +7874,37 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
|
||||
}
|
||||
|
||||
//RUN COMMAND
|
||||
if (!no_systemd)
|
||||
{
|
||||
string cmd = mysqlscript + " " + command + " mariadb.service > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
|
||||
system(cmd.c_str());
|
||||
}
|
||||
|
||||
if (action == MYSQL_START || action == MYSQL_RESTART)
|
||||
{
|
||||
pid_t pid = 0;
|
||||
// Loop check because we mysqld may not start immediately
|
||||
for (int i=0; i < 10; i++)
|
||||
{
|
||||
//get pid
|
||||
char buf[512];
|
||||
FILE *cmd_pipe = popen("pidof -s mysqld", "r");
|
||||
|
||||
fgets(buf, 512, cmd_pipe);
|
||||
pid_t pid = strtoul(buf, NULL, 10);
|
||||
pid = strtoul(buf, NULL, 10);
|
||||
|
||||
pclose( cmd_pipe );
|
||||
|
||||
if (pid)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
sleep(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pid)
|
||||
{
|
||||
// mysql not started
|
||||
|
@ -1514,8 +1514,17 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
|
||||
system(cmd.c_str());
|
||||
cmd = "post-mysql-install >> " + tmpLogDir + "/rpminstall";
|
||||
system(cmd.c_str());
|
||||
int ret = system("systemctl cat mariadb.service > /dev/null 2>&1");
|
||||
if (!ret)
|
||||
{
|
||||
cmd = "systemctl start mariadb.service > " + tmpLogDir + "/mysqldstart";
|
||||
system(cmd.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = "/usr/bin/mysqld_safe & > " + tmpLogDir + "/mysqldstart";
|
||||
system(cmd.c_str());
|
||||
}
|
||||
|
||||
string tmpFile = tmpLogDir + "/mysqldstart";
|
||||
ifstream file (tmpFile.c_str());
|
||||
|
Reference in New Issue
Block a user