Scripts
This chapter presents the available scripts. All our scripts have a detailed synopsis please check the option “-h” or “—help”.
O.S Start/Stop script integration until Red Hat/Oracle Linux 7
DMK provides a tiny script, which integrated to the boot procedure serves to start & stop all the mysql services smoothly, source code:
cat ${DMK_HOME}/templates/init.d/mysql.linux
#!/bin/bash
#...
case "$1" in
'start')
su - mysql -c "${DMK_HOME:-/u01/app/mysql/local/dmk}/bin/mysql.sh $*"
;;
'stop')
su - mysql -c "${DMK_HOME:-/u01/app/mysql/local/dmk}/bin/mysql.sh $*"
;;
*)
echo "usage $0 {start|stop}"
exit 1
;;
esac
We added the restart feature in ours scripts : mariadb.sh and mysql.sh.
Below, all steps for the implementation & integration into the boot sequence:
Firstly, copy the script to the “/etc/init.d” and set the correct privileges
cp $DMK_HOME/templates/init.d/mysql.linux /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
Secondly, integrate the new script to the boot sequence
[root@svr01 ~]# /sbin/chkconfig --add mysql
All necessary metadata for the Run-Levels are available within the script.
Finally, Verify the integration
[root@svr01 ~]# /sbin/chkconfig --list mysql
mysql 0:off 1:off 2:off 3:on 4:off 5:on 6:off
O.S Start/Stop script integration since Red Hat/Oracle Linux 7
DMK provides a tiny script, which integrated to the boot procedure serves to start & stop all the mysql services smoothly, source code:
cat ${DMK_HOME}/templates/systemd/mariadb.service
[Unit]
Description=MySQL Database Service
After=syslog.target network.target
[Service]
LimitMEMLOCK=infinity
LimitNOFILE=65535
Type=simple
RemainAfterExit=yes
User=mysql
Group=mysql
ExecStart=/u01/app/mysql/local/dmk/bin/mariadb.sh start
ExecStop=/u01/app/mysql/local/dmk/bin/mariadb.sh stop
[Install]
WantedBy=multi-user.target
Below, all steps for the implementation & integration into the boot sequence:
Firstly, copy the script to the /usr/lib/systemd/systemd” systemd source code repository and set the correct privileges
cp /u01/app/mysql/local/dmk/templates/systemd/mariadb.service \\/usr/lib/systemd/system/
chmod 644 /usr/lib/systemd/system/mariadb.service
cd /etc/systemd/system/
ln –s /usr/lib/systemd/system/mariadb.service mariadb.service
Secondly, reload systemd and enabled the new service
[root@svr01 ~]# systemctl deamon-reload
[root@svr01 ~]# systemctl enable mariadb.service
All necessary systemd link and dependencies are automatically performed by the O.S
Finally, verify the integration
[root@svr01 ~]# systemctl status mariadb.service
● mysql.service - The MySQL Database Service
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled;
vendor preset: disabled)
Active: inactive (dead)
Tail the systemd logfile
[root@svr01 ~]# journalctl --unit=mysql -f
mariadb.sh and mysql.sh
This script serves to start, stop and restart either all databases simultaneously or a specific database.
Syntax :
[mariadb|mysql].sh [start|stop|restart] [MYSQL_SERVER|none]
Without MYSQL_SEVER parameter, it will manage all instances on the server.
dmk-run.sh
This script prints the status of MariaDB components. It’s commonly launched with the short aliases “sta”, “ser” or “u”.
Please check the respective platform script as the features differ (i.e. hiding stopped components)
Syntax
dmk-run.sh -h
housekeeping.sh
dbi services offers an intelligent housekeeping script to perform several types of operations on log files which are valid and identical for Linux/Unix systems.
Archive & Truncate the Alert*.log or the dr*.log (Dataguard broker) log fileS
Truncate files
Delete files older than the threshold
Oracle ADRCI (Automatic Diagnostic Repository Command Interpreter) purge. This function is available for any installed oracle products which have a Diagnostic repository.
The implementation consists of
Copy the conf. template
cp ${DMK_HOME}/templates/etc/housekeeping.cfg ${DMK_HOME}/etc
Adapt the configuration file
This configuration file is composed of three sections:
The Definition section, set default values for all operation types
DEF::DELET::100::# delete files older than 100 days
DEF::TRUNC::1000::# keep the 1000 last lines
DEF::ARCHI::1000::# backup the file and keep the 1000 last lines
DEF::RMDIR::50::# delete empty directories older than 50 days
The Standard section, which is composed as follows
STD::MYSQL_ERR_LOG::ARCHI::::
This above line stands for the mysql database error logs of all databases running on the machine.
The Custom section
CST::/u01/app/mysql/admin/*/hist/*::DELET::100:: # customized aging
CST::/u01/app/mysql/admin/*/log/*::DELET::::
The last feature is the customization of each line by adding digits between the double colons at the end of the line, like the 100 days from above example
The option RMDIR remove empty directories which have not been modified since the specified threshold time (keyword section)
# For deletion of empty directories
# Beware of Syntax !!!
# The deletion stop at the level of the first start character
CST::/u90/mysqlbackup/mysqld?/*::RMDIR:::
Syntax
housekeeping.sh [-c configuration file|none]
mysql_dump_backup.ksh
This script allows to create rapidly compressed MariaDB dumps.
Syntax
Mysql_dump_backup.ksh [MYSQL_SERVER] [common backup filesystem]
Last updated