mysql mariadb 多版本多实例 开机启动

来源:本站原创 Linux 超过56 views围观 0条评论

———-mysql多实例开机启动及加入服务———————–
将脚本cp到init.d目录
cd /usr/mysqlsoft5.6.38_3346/support-files/
[root@mysql02 support-files]# cp mysql.server /etc/init.d/mysqld3346

[root@mysql02 support-files]# systemctl status mysqld3346
Unit mysqld3346.service could not be found.
[root@mysql02 support-files]# systemctl enable mysqld3346    —-开机启动
mysqld3346.service is not a native service, redirecting to /sbin/chkconfig.   —–有报错,开机启动加入失败
Executing /sbin/chkconfig mysqld3346 on
[root@mysql02 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)

[root@mysql02 support-files]#
[root@mysql02 support-files]# systemctl start mysqld3346
[root@mysql02 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.
[root@mysql02 support-files]#

查看是否开启开机启动
[root@mysql02 support-files]# systemctl is-enabled mysqld3346     —-一种方式
mysqld3346.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld3346 –level=5
enabled

[root@mysql02 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

[root@shtsmysql02 support-files]# systemctl is-enabled mumysql
mumysql.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mumysql –level=5
enabled

[root@shjhmysql01 init.d]# chkconfig –add mumysql   在系统里增加开记机启动
[root@shjhmysql01 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

—————————————————–

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3600转载请注明转自CCIE那点事
如果喜欢:点此订阅本站