。。。怎么会出现mariadb的信息,这个跟我的操作系统有关,CentOS 7,默认的数据库是Mariadb,而不是MysQL。
失败原因:
没有指定错误日志
指定错误日志后,log-error=/sales3307/mysql/log/error.log
重新启动,又报如下错误:
2016-01-16 20:41:09 18683 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mariadb/mariadb.pid' (Errcode: 2 - No such file or directory) 2016-01-16 20:41:09 18683 [ERROR] Can't start server: can't create PID file: No such file or directory 160116 20:41:10 mysqld_safe mysqld from pid file /var/run/mariadb/mariadb.pid ended
失败原因:没有指定pid文件
指定pid文件的路径
pid-file=/sales3307/mysql/run/mysqld.pid
重新启动,终于启动成功
# mysqld_multi --defaults-file=/root/multi.cnf report Reporting MySQL servers MySQL server from group: mysqld3306 is running MySQL server from group: mysqld3307 is running
最后贴一下配置文件:
mysqld的部分没有贴,这块配置是公用的
[mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin #用来做关闭mysql使用 user = root log=/usr/local/mysql/multi.log ##password='' [mysqld3306] port=3306 socket=/sales3306/mysql/run/mysql.sock datadir=/sales3306/mysql/data server-id=1003306 log-bin=/sales3306/mysql/log/mysql-bin tmpdir=/sales3306/mysql/tmp/ innodb_log_group_home_dir = /sales3306/mysql/data innodb_buffer_pool_size=200M log-error=/sales3306/mysql/log/error.log pid-file=/sales3306/mysql/run/mysqld.pid [mysqld3307] port=3307 socket=/sales3307/mysql/run/mysql.sock datadir=/sales3307/mysql/data server-id=1003307 log-bin=/sales3307/mysql/log/mysql-bin tmpdir=/sales3307/mysql/tmp/ innodb_log_group_home_dir = /sales3307/mysql/data innodb_buffer_pool_size=100M log-error=/sales3307/mysql/log/error.log pid-file=/sales3307/mysql/run/mysqld.pid
在折腾过程中还是蛮多坎坷的,结论就是很个性化的定制,譬如socket,log-error,pid-file都要指定各自的路径。不然启动过程中,系统会按默认的来,多实例都按默认的来,会起冲突的。但整个排错过程还是蛮简单的,不是看mysqld_multi的错误日志,就是实例本身的日志。
下面演示一下,mysqld_multi的用法:
[root@spark01 ~]# mysqld_multi --defaults-file=/root/multi.cnf stop
[root@spark01 ~]# mysqld_multi --defaults-file=/root/multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
MySQL server from group: mysqld3307 is not running
[root@spark01 ~]# mysqld_multi --defaults-file=/root/multi.cnf report 3306
Reporting MySQL servers
MySQL server from group: mysqld3306 is not running
[root@spark01 ~]# mysqld_multi --defaults-file=/root/multi.cnf start 3306
[root@spark01 ~]# mysqld_multi --defaults-file=/root/multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is not running
在上述[mysqld_multi]的配置中,有个user和password,这个是用来执行mysqladmin关闭程序的。
有时候,用root权限太大,且密码以明文的方式暴露存在安全风险。
虽然mysqld_multi支持--password选项,但如果两个实例的密码不一样,又如何同时关闭实例呢?
可为两个实例创建同名账户,只赋予shutdown权限,这样可解决上述的困扰。