Skip to content

Commit

Permalink
update cmservice mapping for centos 7 mariadb in 123.09beta01
Browse files Browse the repository at this point in the history
- cmservice mapps differing service alias names in centos 7 to the correct systemd service name for mariadb mysql server's service name, This update fixes a few bugs
- on centos 7 service mysql status/start/restart/stop maybe not be mapped to systemctl mariadb service but service mariadb status/start/restart/stop is
  • Loading branch information
centminmod committed Sep 5, 2019
1 parent 411ab2d commit 6bc6ba7
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 35 deletions.
7 changes: 4 additions & 3 deletions centmin.sh
Expand Up @@ -27,7 +27,7 @@ DT=$(date +"%d%m%y-%H%M%S")
branchname='123.09beta01'
SCRIPT_MAJORVER='1.2.3'
SCRIPT_MINORVER='09'
SCRIPT_INCREMENTVER='254'
SCRIPT_INCREMENTVER='255'
SCRIPT_VERSIONSHORT="${branchname}"
SCRIPT_VERSION="${SCRIPT_VERSIONSHORT}.b${SCRIPT_INCREMENTVER}"
SCRIPT_DATE='31/10/2019'
Expand Down Expand Up @@ -187,12 +187,13 @@ cmservice() {
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
Expand Down
9 changes: 7 additions & 2 deletions inc/centminfinish.inc
Expand Up @@ -280,8 +280,13 @@ if [[ "$MYSQLSERVICE_DISABLED" = [yY] ]]; then
cmchkconfig mysql off
cecho "--------------------------------------------------------" $boldyellow
cecho "In future to re-enable mysql service type these 2 commands:" $boldyellow
echo "service mysql start"
echo "chkconfig mysql on"
if [[ "$CENTOS_SIX" = '6' ]]; then
echo "service mysql start"
echo "chkconfig mysql on"
else
echo "systemctl start mariadb"
echo "systemctl enable mariadb"
fi
cecho "--------------------------------------------------------" $boldyellow
fi

Expand Down
4 changes: 2 additions & 2 deletions inc/mariadb_install.inc
Expand Up @@ -505,7 +505,7 @@ if [[ "$MDB_INSTALL" = [yY] ]]; then
cecho "* Installing MariaDB " $boldgreen
echo "*************************************************"

cmservice mysqld stop
cmservice mysql stop

${YUMDNFBIN}${CACHESKIP} -y remove mysql mysql-libs

Expand Down Expand Up @@ -538,7 +538,7 @@ fi

perdbiinstall

cmservice mysqld stop
cmservice mysql stop

#yum -y remove mysql mysql-libs

Expand Down
4 changes: 2 additions & 2 deletions inc/mariadb_install102.inc
Expand Up @@ -545,7 +545,7 @@ if [[ "$MDB_INSTALL" = [yY] ]]; then
cecho "* Installing MariaDB " $boldgreen
echo "*************************************************"

cmservice mysqld stop
cmservice mysql stop

${YUMDNFBIN}${CACHESKIP} -y remove mysql mysql-libs

Expand Down Expand Up @@ -578,7 +578,7 @@ fi

perdbiinstall

cmservice mysqld stop
cmservice mysql stop

#yum -y remove mysql mysql-libs

Expand Down
4 changes: 2 additions & 2 deletions inc/mariadb_install103.inc
Expand Up @@ -550,7 +550,7 @@ if [[ "$MDB_INSTALL" = [yY] ]]; then
cecho "* Installing MariaDB " $boldgreen
echo "*************************************************"

cmservice mysqld stop
cmservice mysql stop

${YUMDNFBIN}${CACHESKIP} -y remove mysql mysql-libs

Expand Down Expand Up @@ -583,7 +583,7 @@ fi

perdbiinstall

cmservice mysqld stop
cmservice mysql stop

#yum -y remove mysql mysql-libs

Expand Down
4 changes: 2 additions & 2 deletions inc/mariadb_install104.inc
Expand Up @@ -550,7 +550,7 @@ if [[ "$MDB_INSTALL" = [yY] ]]; then
cecho "* Installing MariaDB " $boldgreen
echo "*************************************************"

cmservice mysqld stop
cmservice mysql stop

${YUMDNFBIN}${CACHESKIP} -y remove mysql mysql-libs

Expand Down Expand Up @@ -583,7 +583,7 @@ fi

perdbiinstall

cmservice mysqld stop
cmservice mysql stop

#yum -y remove mysql mysql-libs

Expand Down
2 changes: 1 addition & 1 deletion inc/mariadb_upgrade101.inc
Expand Up @@ -342,7 +342,7 @@ echo
echo "shut down existing MariaDB server for upgrade.."
mysql -e "set global innodb_buffer_pool_dump_at_shutdown=0;"
sleep 10
service mysql stop
service mysqld stop
echo
# move aside existing ib_logfile* files
cd $MYSQLDATADIR
Expand Down
2 changes: 1 addition & 1 deletion inc/mariadb_upgrade102.inc
Expand Up @@ -392,7 +392,7 @@ echo
echo "shut down existing MariaDB server for upgrade.."
mysql -e "set global innodb_buffer_pool_dump_at_shutdown=0;"
sleep 10
service mysql stop
cmservice mysql stop
echo
# move aside existing ib_logfile* files
cd $MYSQLDATADIR
Expand Down
2 changes: 1 addition & 1 deletion inc/mariadb_upgrade103.inc
Expand Up @@ -391,7 +391,7 @@ echo
echo "shut down existing MariaDB server for upgrade.."
mysql -e "set global innodb_buffer_pool_dump_at_shutdown=0;"
sleep 10
service mysql stop
cmservice mysql stop
echo
# move aside existing ib_logfile* files
cd $MYSQLDATADIR
Expand Down
2 changes: 1 addition & 1 deletion inc/mariadb_upgrade104.inc
Expand Up @@ -394,7 +394,7 @@ echo
echo "shut down existing MariaDB server for upgrade.."
mysql -e "set global innodb_buffer_pool_dump_at_shutdown=0;"
sleep 10
service mysql stop
cmservice mysql stop
echo
# move aside existing ib_logfile* files
cd $MYSQLDATADIR
Expand Down
6 changes: 3 additions & 3 deletions inc/mysql_install.inc
Expand Up @@ -17,8 +17,8 @@ fi
cd $DIR_TMP


cmchkconfig mysqld on
cmservice mysqld start
cmchkconfig mysql on
cmservice mysql start


echo "*************************************************"
Expand All @@ -31,7 +31,7 @@ mysqlproclimit
echo "*************************************************"
cecho "* MySQL installed" $boldgreen
echo "*************************************************"
cmservice mysqld stop
cmservice mysql stop
fi

}
2 changes: 1 addition & 1 deletion inc/undo.inc
Expand Up @@ -14,7 +14,7 @@ chkconfig php-fpm off
}

mariadboff() {
service mysql stop
service mysqld stop
chkconfig mysql off
}

Expand Down
6 changes: 3 additions & 3 deletions inc/zlib.inc
Expand Up @@ -178,8 +178,8 @@ install_cfzlib() {
echo "mysqladmin flush-tables"
mysqladmin flush-tables
sleep 10s
service mysql status;
service mysql restart;
cmservice mysql status;
cmservice mysql restart;
elif [[ "$i" = 'pickup' || "$i" = 'qmgr' ]]; then
service postfix status;
service postfix restart;
Expand Down Expand Up @@ -302,7 +302,7 @@ install_stdzlib() {
echo "mysqladmin flush-tables"
mysqladmin flush-tables
sleep 10s
service mysql status;
service mysqld status;
service mysql restart;
elif [[ "$i" = 'pickup' || "$i" = 'qmgr' ]]; then
service postfix status;
Expand Down
30 changes: 27 additions & 3 deletions tools/cminfo.sh
Expand Up @@ -99,6 +99,30 @@ else
ipv_forceopt='4'
fi

cmservice() {
servicename=$1
action=$2
if [[ "$CENTOS_SEVEN" != '7' ]] && [[ "${servicename}" = 'haveged' || "${servicename}" = 'pure-ftpd' || "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' || "${servicename}" = 'memcached' || "${servicename}" = 'nsd' || "${servicename}" = 'csf' || "${servicename}" = 'lfd' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
fi
fi
fi
}

#####################################################
top_info() {
SYSTYPE=$(virt-what | head -n1)
Expand Down Expand Up @@ -293,7 +317,7 @@ top_info() {
iotop -bton1 -P
echo
# ensure mysql server is running before triggering mysqlreport output
if [[ "$(service mysql status >/dev/null 2>&1; echo $?)" -eq '0' && -f /root/mysqlreport ]]; then
if [[ "$(cmservice mysql status >/dev/null 2>&1; echo $?)" -eq '0' && -f /root/mysqlreport ]]; then
echo "------------------------------------------------------------------"
echo "mysqlreport"
/root/mysqlreport 2>/dev/null
Expand All @@ -304,7 +328,7 @@ top_info() {
# 64bit OS only
yum -q -y install percona-toolkit --enablerepo=percona-release-x86_64
fi
if [[ "$(service mysql status >/dev/null 2>&1; echo $?)" -eq '0' && -f /usr/bin/pt-summary ]]; then
if [[ "$(cmservice mysql status >/dev/null 2>&1; echo $?)" -eq '0' && -f /usr/bin/pt-summary ]]; then
echo "------------------------------------------------------------------"
/usr/bin/pt-summary 2>/dev/null | sed -e 's|Percona Toolkit ||g'
echo
Expand Down Expand Up @@ -590,7 +614,7 @@ for c in $VHOSTSCONF; do
echo "* /usr/local/nginx/conf/conf.d/$c";
done

if [[ -z "$(service mysql status | grep not)" ]]; then
if [[ -z "$(cmservice mysql status | grep not)" ]]; then
echo
echo "------------------------------------------------------------------"
echo " MySQL Databases:"
Expand Down
5 changes: 3 additions & 2 deletions tools/csf-reinstall.sh
Expand Up @@ -227,12 +227,13 @@ cmservice() {
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
Expand Down
28 changes: 26 additions & 2 deletions tools/mariadb-jemalloc.sh
Expand Up @@ -56,8 +56,32 @@ for g in "" e f; do
alias ${g}grep="LC_ALL=C ${g}grep" # speed-up grep, egrep, fgrep
done

cmservice() {
servicename=$1
action=$2
if [[ "$CENTOS_SEVEN" != '7' ]] && [[ "${servicename}" = 'haveged' || "${servicename}" = 'pure-ftpd' || "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' || "${servicename}" = 'memcached' || "${servicename}" = 'nsd' || "${servicename}" = 'csf' || "${servicename}" = 'lfd' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
fi
fi
fi
}

switch_malloc() {
if [[ "$JEMALLOC" = [yY] && "$(service mysql status >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
if [[ "$JEMALLOC" = [yY] && "$(cmservice mysql status >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
echo
cecho "check existing mysqld memory usage" $boldyellow
pidstat -rh -C mysqld | sed -e "s|$(hostname)|hostname|g"
Expand Down Expand Up @@ -117,7 +141,7 @@ switch_malloc() {
}

numa_opt() {
if [[ "$NUMA" = [yY] && "$(service mysql status >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
if [[ "$NUMA" = [yY] && "$(cmservice mysql status >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
echo
cecho "apply numa optimisation if required" $boldyellow
if [[ -f /usr/bin/numactl && "$(numactl --hardware | awk '/available:/ {print $2}')" -gt '2' && ! -f /etc/systemd/system/mariadb.service.d/numa.conf ]]; then
Expand Down
5 changes: 3 additions & 2 deletions tools/nv.sh
Expand Up @@ -319,12 +319,13 @@ cmservice() {
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
Expand Down
5 changes: 3 additions & 2 deletions tools/nvwp.sh
Expand Up @@ -251,12 +251,13 @@ cmservice() {
service "${servicename}" "$action"
fi
else
if [[ "${servicename}" = 'mysql' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
if [[ "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service "${servicename}" "$action"
fi
else
elif [[ "${servicename}" = 'mysql' || "${servicename}" = 'mysqld' ]]; then
servicename='mariadb'
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl "$action" "${servicename}.service"
Expand Down

0 comments on commit 6bc6ba7

Please sign in to comment.