1
0
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:
Andrew Hutchings
2020-02-04 14:16:49 +00:00
parent 6cf6519019
commit 7df731a3a6
5 changed files with 109 additions and 17 deletions

View File

@ -25,7 +25,14 @@ done
#stop services #stop services
columnstore stop > /dev/null 2>&1 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` cloud=`mcsGetConfig Installation Cloud`
if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then if [ $cloud = "amazon-ec2" ] || [ $cloud = "amazon-vpc" ]; then

View File

@ -90,7 +90,13 @@ stop() {
RETVAL=$? RETVAL=$?
rm -f $lockdir/columnstore rm -f $lockdir/columnstore
fuser -k 8604/tcp > /dev/null 2>&1 fuser -k 8604/tcp > /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
pkill ProcMon pkill ProcMon
pkill ProcMgr pkill ProcMgr
return $RETVAL return $RETVAL

View File

@ -11,7 +11,13 @@ checkForError() {
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "MySQL Password file missing or incorrect, check .my.cnf file" echo "MySQL Password file missing or incorrect, check .my.cnf file"
rm -f ${tmpdir}/error.check 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 sleep 2
exit 2; exit 2;
fi fi
@ -54,10 +60,22 @@ for arg in "$@"; do
done done
# Restart in the same way that mysqld will be started normally. # 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 sleep 2
export MYSQL_OPTS="--skip-grant-tables" 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 unset MYSQL_OPTS
sleep 5 sleep 5
@ -67,12 +85,24 @@ install_mcs_mysql.sh --tmpdir=$tmpdir
checkForError checkForError
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR: Invalid password in .my.cnf, or Columnstore plugin install missing" 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 sleep 2
exit 2; exit 2;
fi 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 exit 0

View File

@ -7796,16 +7796,26 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
string pidtmp = tmpdir + "/mysql.pid"; string pidtmp = tmpdir + "/mysql.pid";
int no_systemd = system("systemctl cat mariadb.server > /dev/null 2>&1");
switch (action) switch (action)
{ {
case MYSQL_START: case MYSQL_START:
{ {
if (no_systemd)
{
system("/usr/bin/mysqld_safe &");
}
command = "start"; command = "start";
break; break;
} }
case MYSQL_STOP: case MYSQL_STOP:
{ {
if (no_systemd)
{
system("pkill mysqld");
}
command = "stop"; command = "stop";
//set process status //set process status
@ -7821,18 +7831,31 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
case MYSQL_RESTART: case MYSQL_RESTART:
{ {
if (no_systemd)
{
system("pkill mysqld");
system("/usr/bin/mysqld_safe &");
}
command = "restart"; command = "restart";
break; break;
} }
case MYSQL_RELOAD: case MYSQL_RELOAD:
{ {
if (no_systemd)
{
system("pkill -HUP mysqld");
}
command = "reload"; command = "reload";
break; break;
} }
case MYSQL_FORCE_RELOAD: case MYSQL_FORCE_RELOAD:
{ {
if (no_systemd)
{
system("pkill -HUP mysqld");
}
command = "force-reload"; command = "force-reload";
break; break;
} }
@ -7851,19 +7874,36 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
} }
//RUN COMMAND //RUN COMMAND
string cmd = mysqlscript + " " + command + " mariadb.service > " + tmpdir + "/actionMysqlCalpont.log 2>&1"; if (!no_systemd)
system(cmd.c_str()); {
string cmd = mysqlscript + " " + command + " mariadb.service > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
system(cmd.c_str());
}
if (action == MYSQL_START || action == MYSQL_RESTART) if (action == MYSQL_START || action == MYSQL_RESTART)
{ {
//get pid pid_t pid = 0;
char buf[512]; // Loop check because we mysqld may not start immediately
FILE *cmd_pipe = popen("pidof -s mysqld", "r"); 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); fgets(buf, 512, cmd_pipe);
pid_t pid = strtoul(buf, NULL, 10); pid = strtoul(buf, NULL, 10);
pclose( cmd_pipe ); pclose( cmd_pipe );
if (pid)
{
break;
}
else
{
sleep(2);
}
}
if (!pid) if (!pid)
{ {

View File

@ -1514,8 +1514,17 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
system(cmd.c_str()); system(cmd.c_str());
cmd = "post-mysql-install >> " + tmpLogDir + "/rpminstall"; cmd = "post-mysql-install >> " + tmpLogDir + "/rpminstall";
system(cmd.c_str()); system(cmd.c_str());
cmd = "systemctl start mariadb.service > " + tmpLogDir + "/mysqldstart"; int ret = system("systemctl cat mariadb.service > /dev/null 2>&1");
system(cmd.c_str()); 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"; string tmpFile = tmpLogDir + "/mysqldstart";
ifstream file (tmpFile.c_str()); ifstream file (tmpFile.c_str());