MySQL之——主从server-id不生效,The server is not configured as slave
来源:互联网 发布:阿里云装mysql数据库 编辑:程序博客网 时间:2024/04/30 03:04
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/48413681
数据库已搭建完成,各种配置均已完成,但是在start slave ;的时候,报错:
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO这里说,我没有配置为从机,但我明明配置过的啊。
MySQL版本:5.6.19
主:master IP : 172.17.210.199
从:slave IP :172.17.206.138
先看看从机172.17.206.138的my.cnf
[root@liuyazhuang ~]# vi /etc/my.cnf[mysqld]datadir=/usr/local/mysql/datasocket=/tmp/mysql.sockskip-grant-tablesuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0tmpdir=/tmp[mysqld_safe]log-error=/usr/local/data/mysqld.logpid-file=/usr/local/mysql/data/mysqld.pid###############以下是添加主从的配置server_id = 2log-bin = /usr/local/mysql/log/solve-bin.logmaster-host = 172.17.210.199master-user = testmaster-pass = 123456master-port = 3306master-connect-retry = 60这是MySQL主机172.17.210.199的my.cnf
[root@liuyazhuang ~]$ cat /etc/my.cnf[mysqld]log-bin = /u01/mysql/log/masters-bin.logread-only = 0basedir = /u01/mysqldatadir = /u01/mysql/dataport = 3306server_id = 1socket = /tmp/mysql.sockjoin_buffer_size = 128Msort_buffer_size = 2Mread_rnd_buffer_size = 2Msql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES尝试过多次 重启主从还是报错;
接着手动chang to 后还是一样报错
mysql> CHANGE MASTER TOMASTER_HOST='172.17.210.199',MASTER_USER='test',MASTER_PASSWORD='123456',MASTER_LOG_FILE='masters-bin.000003',MASTER_LOG_POS=120;Query OK, 0 rows affected, 2 warnings (0.04 sec)在从库服务器执行START slave;命令启动slave
mysql> START slave;报错:
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO
于是查看日志
1.查看SLAVE172.17.206.138上的Mysql报错日志,有这么一句:
141009 6:06:29 [ERROR] Server id not set, will not start slave
意思是,slave的server-id没有设置。
那就奇怪了,我明明在配置文件里面指定了server-id的了,并且有重启mysql服务,难道不起效?
分别在主从上执行命令“show variables like 'server_id';”。
mysql> mysql> SHOW VARIABLES LIKE 'server_id';+---------------+-------+| Variable_name | Value |+---------------+-------+| server_id | 0 |+---------------+-------+1 row in set (0.00 sec)命名设置的是2,怎么会变成0
-------主机上面查看
mysql> SHOW VARIABLES LIKE 'server_id';+---------------+-------+| Variable_name | Value |+---------------+-------+| server_id | 1 |+---------------+-------+1 row in set (0.00 sec)跟设置的一样。
既然参数文件不生效,就试试在数据库命令里面设置:在从机 172.17.206.138上执行命令
mysql > SET GLOBAL server_id=2;再次在从机 172.17.206.138上执行slave start和show slave status,成功了。
注意!!!由于“SET GLOBAL server_id=;”命令会在mysql服务重启后丢失,所以一定要写到配置文件里面。
但为什么我之前修改了my.cnf文件不起效?
仔细排查,发现配置里面有[mysqld]和[mysqld_safe],之前将修改的配置内容基本都放在了[mysqld_safe]下面,新增的配置文件放的位置不一样也有关系?于是我尝试把配置文件里修改的部分放在[mysqld]下面,于是改成这样:
[root@liuyazhuang]# cat /etc/my.cnf[mysqld]datadir=/usr/local/mysql/datasocket=/tmp/mysql.sockskip-grant-tablesuser=mysqlsymbolic-links=0tmpdir=/tmpserver_id = 2log-bin = /usr/local/mysql/log/solve-bin.logmaster-host = 172.17.210.199master-user = testmaster-pass = 123456master-port = 3306master-connect-retry = 60[mysqld_safe]log-error=/usr/local/data/mysqld.logpid-file=/usr/local/mysql/data/mysqld.pid如图,就是将图中标注的内容从[mysqld_safe]下修改到[mysqld]下
修改之后,再次同步,成功了!
mysql>mysql> STOP slave;Query OK, 0 rows affected (0.05 sec)mysql> START slave;Query OK, 0 rows affected (0.00 sec)
0 0
- MySQL之——主从server-id不生效,The server is not configured as slave
- mySql主从配置出错:The server is not configured as slave; fix in config file or with CHANGE MASTER TO
- Mysql 出现错误The server is not configured as slave; fix in config file or with CHANGE MASTER TO
- The selected server is enabled,but is not configured pro
- #2002 - 服务器没有响应 (or the local MySQL server's socket is not correctly configured)
- #2002 - 服务器没有响应 (or the local MySQL server's socket is not correctly configured)解决
- MySQL之——The slave I/O thread stops because master and slave have equal MySQL server UUIDs
- unable to start debugging on the web server.The web server is not configured
- Server '' is not configured for RPC.
- Unable to start debugging on the web server. The project is not configured to be debugged.
- Unable to start debugging on the web server. The project is not configured to be debugged.
- IIS 7 The Web server is configured to not list the contents of this directory
- Server: Msg 7411 Server '' is not configured for RPC.
- Cannot start server. Server instance is not configured.
- Tomcat启动:Cannot start server. Server instance is not configured.
- mysql 5.5 主从同步数据到 msyql5.6数据库,报错为Slave is not configured or failed to initialize properly. You must
- the selected server is enabled,but is not configured properly.Deployment to it will not be permitted
- myeclipse结合tomcat部署项目时报错the selected server is enabled,but is not configured properly
- QT window 和linux下的双编译
- ADS解决xxxis an undefined model
- qt中添加C语言源码若干问题
- 【硬件测试】华为2016校招·硬件技术工程师机考试题
- eclipse 开发环境下,提示 String cannot be resolved to a type
- MySQL之——主从server-id不生效,The server is not configured as slave
- 小猫统计——根据Excel文件或者文本文件自动建表
- Java、Spring 国际化
- android开发xml style使用
- C++-----自己写的哈希表
- 《剑指offer》不用加减乘除做加法
- c++实现八大排序方法(一)
- MongoDB学习之在Windows下安装MongoDB
- ./scripts/feeds update -a执行失败