mysql mariadb 多版本多實例 開機啟動
———-mysql多實例開機啟動及加入服務———————–
將腳本cp到init.d目錄
cd /usr/mysqlsoft5.6.38_3346/support-files/
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld3346
[[email protected] support-files]# systemctl status mysqld3346
Unit mysqld3346.service could not be found.
[[email protected] support-files]# systemctl enable mysqld3346 —-開機啟動
mysqld3346.service is not a native service, redirecting to /sbin/chkconfig. —–有報錯,開機啟動加入失敗
Executing /sbin/chkconfig mysqld3346 on
[[email protected] support-files]# systemctl status mysqld3346
● mysqld3346.service – LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld3346; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)
[[email protected] support-files]#
[[email protected] support-files]# systemctl start mysqld3346
[[email protected] support-files]# systemctl status mysqld3346
● mysqld3346.service – LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld3346; bad; vendor preset: disabled)
Active: active (running) since Mon 2017-10-30 03:25:57 EDT; 10s ago
Docs: man:systemd-sysv-generator(8)
Process: 10651 ExecStart=/etc/rc.d/init.d/mysqld3346 start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysqld3346.service
├─10659 /bin/sh /usr/mysqlsoft5.6.38_3346/bin/mysqld_safe –datadir=/usr/mysqldata/3346 –pid-file=/…
└─11368 /usr/mysqlsoft5.6.38_3346/bin/mysqld –basedir=/usr/mysqlsoft5.6.38_3346 –datadir=/usr/mysqldate5…
Oct 30 03:25:54 mysql02 systemd[1]: Starting LSB: start and stop MySQL…
Oct 30 03:25:57 mysql02 mysqld3346[10651]: Starting MySQL.. SUCCESS!
Oct 30 03:25:57 mysql02 systemd[1]: Started LSB: start and stop MySQL.
[[email protected] support-files]#
查看是否開啟開機啟動
[[email protected] support-files]# systemctl is-enabled mysqld3346 —-一種方式
mysqld3346.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld3346 –level=5
enabled
[[email protected] support-files]# chkconfig –list mysqld3346 —兩種方式
mysqld3346 0:off 1:off 2:on 3:on 4:on 5:on 6:off
—————mariadb多實例開機啟動—————
現在增加 多實例開機啟動腳本
vim /etc/rc.d/init.d/mumysql
#!/bin/bash
#add for chkconfig
#chkconfig: 2345 70 30
#description: mysql autostart
#processname: mumysql
/usr/bin/mysqld_multi –defaults-extra-file=/etc/mysql/cfg3325.cnf –log=/var/log/mysql/mysql_3325.log start
#end
說明:
2345是指腳本的運行級別,即在2345這4種模式下都可以運行,234都是文本界面,5就是圖形界面X
70是指腳本將來的啟動順序號,如果別的程序的啟動順序號比70小(比如44、45),則腳本需要等這些程序都啟動以后才啟動。
30是指系統關閉時,腳本的停止順序號。
chmod +x /etc/rc.d/init.d/mumysql
systemctl enable mumysql
[[email protected] support-files]# systemctl is-enabled mumysql
mumysql.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mumysql –level=5
enabled
[[email protected] init.d]# chkconfig –add mumysql 在系統里增加開記機啟動
[[email protected] init.d]# chkconfig –list 查看開機啟動列表。
mumysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
—————————————————–
暫時還木有人評論,坐等沙發!