12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
mysql数据库 时间:2024-12-25 09:54:55
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
环境:mysql一主一从架构,主库是mysql5.1,从库是mysql5.6;系统均为CentOS6.2问题:在主库上面执行的SQL语句1.创建表CREATETABLE`app_versions`(
`date`dateNOTNULL,
`app`char(16)
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
环境:mysql一主一从架构,主库是mysql5.1,从库是mysql5.6;系统均为CentOS6.2
问题:
在主库上面执行的SQL语句
1.创建表
CREATETABLE`app_versions`(
`date`dateNOTNULL,
`app`char(16)NOTNULL,
`ver`char(16)NOTNULL,
`val`int(11)DEFAULT'0',
PRIMARYKEY(`date`,`app`,`ver`)
)ENGINE=MyISAMDEFAULTCHARSET=latin1;
2.创建用户并且给予权限
grant select on databasename.* to 'username'@'IPaddress' identified by 'password'
3.刷新权限信息
flush privileges
在主库上面执行完之后,在从库上面执行show slave status \G发现IO进程和SQL进程显示的都是NO,然后执行start slave IO_THREAD之后再次执行show slave status \G 发现IO进程是拉起来了的显示的是YES,之后再执行start slave SQL_THREAD进程,show slave status \G发现IO进程和SQL进程都是显示的NO,并且在从库的错误日志中可以获取得到:
在错误日志中可以很明显的看得到日志提示:
Missing system table mysql.proxies_pri;please run mysql_upgrade to create it
日志提示系统表mysql.proxies_pri不存在,需要执行mysql_upgrade,然后我自己google了一下,
发现大部分都是因为升级mysql之后没有执行mysql_upgrade导致的,但是我在主库上面根本就没有进
行任何的升级操作,在从库也是这个样子,然后网上的建议是mysql_upgrade升级修复一下。
mysql_upgrade主要作用是检测所有的表并且升级mysql这个系统库内所有的表,是进行在线升级的,所以并不会影响线上操作(PS:当然不包括有关mysql库的操作)。
Themysql.proxies_priv
table contains information about proxy privileges. The table can be queried and although it is possible to directly update it, it is best to useGRANTfor setting privileges.
可以看到上述对于mysql.proxies_priv系统表的猜测,可以比较明显的看到这个表主要是用来管理
数据库用户权限信息的表,所以我猜测数据库很有可能卡在权限这块了,并且在从库中我在mysql.user这个表中并没有发现我之前grant创建的用户。这个时候我在从库上面设置了跳过一个事务:
set global sql_slave_skip_counter = 1(只是跳过一个事务,跳过之后归0)
之后我在重启start slave。slave恢复了正常,日志也能够正常的往里面写了。所以我猜想这个问题和
权限有关,假如需要验证的话,最好是在从库上面开启general log,并且在从库的binlog获取最新的事
务的信息并且根据获取的信息在relay log中继日志找到下一个事务是不是这个。
但是这个方案也是属于治标不治本,下次在执行grant操作的时候,可能还是会出现这个问题,所以还是最后使用mysql_upgrade
mysql_upgrade -uroot -p
[root@gitlab-test data]# mysql_upgrade -uroot -p
Enter password:
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
This installation of MySQL is already upgraded to 5.6.35, use --force if you still need to run mysql_upgrade
[root@gitlab-test data]# mysql_upgrade -uroot -p --force
Enter password:
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/data/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/data/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv OK
mysql.dbOK
mysql.eventOK
mysql.func OK
mysql.general_log OK
mysql.help_categoryOK
mysql.help_keyword OK
mysql.help_relationOK
mysql.help_topicOK
mysql.innodb_index_statsOK
mysql.innodb_table_statsOK
mysql.ndb_binlog_index OK
mysql.pluginOK
mysql.proc OK
mysql.procs_privOK
mysql.proxies_priv_bak OK
mysql.servers OK
mysql.slave_master_infoOK
mysql.slave_relay_log_info OK
mysql.slave_worker_infoOK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zoneOK
mysql.time_zone_leap_secondOK
mysql.time_zone_nameOK
mysql.time_zone_transition OK
mysql.time_zone_transition_typeOK
mysql.user OK
Running 'mysql_fix_privilege_tables'...
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/data/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/data/mysql/mysql.sock'
Warning: Using a password on the command line interface can be insecure.
core_test.test OK
data_test.test OK
gitlabhq_production.abuse_reports OK
gitlabhq_production.application_settingsOK
gitlabhq_production.audit_eventsOK
gitlabhq_production.broadcast_messages OK
gitlabhq_production.deploy_keys_projectsOK
gitlabhq_production.emails OK
gitlabhq_production.events OK
gitlabhq_production.forked_project_linksOK
gitlabhq_production.identities OK
gitlabhq_production.issues OK
gitlabhq_production.keysOK
gitlabhq_production.label_linksOK
gitlabhq_production.labels OK
gitlabhq_production.membersOK
gitlabhq_production.merge_request_diffsOK
gitlabhq_production.merge_requests OK
gitlabhq_production.milestones OK
gitlabhq_production.namespaces OK
gitlabhq_production.notes OK
gitlabhq_production.oauth_access_grantsOK
gitlabhq_production.oauth_access_tokensOK
gitlabhq_production.oauth_applications OK
gitlabhq_production.project_import_dataOK
gitlabhq_production.projectsOK
gitlabhq_production.protected_branches OK
gitlabhq_production.schema_migrations OK
gitlabhq_production.servicesOK
gitlabhq_production.snippetsOK
gitlabhq_production.subscriptions OK
gitlabhq_production.taggingsOK
gitlabhq_production.tagsOK
gitlabhq_production.users OK
gitlabhq_production.users_star_projectsOK
gitlabhq_production.web_hooks OK
OK
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19