您好,登錄后才能下訂單哦!
環境:mysql一主一從架構,主庫是mysql5.1,從庫是mysql5.6;系統均為CentOS6.2
問題:
在主庫上面執行的SQL語句
1.創建表
CREATE TABLE `app_versions` (
`date` date NOT NULL,
`app` char(16) NOT NULL,
`ver` char(16) NOT NULL,
`val` int(11) DEFAULT '0',
PRIMARY KEY (`date`,`app`,`ver`)
) ENGINE=MyISAM DEFAULT CHARSET=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庫的操作)。
The mysql.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 use GRANT for 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.db OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv_bak OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
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_settings OK
gitlabhq_production.audit_events OK
gitlabhq_production.broadcast_messages OK
gitlabhq_production.deploy_keys_projects OK
gitlabhq_production.emails OK
gitlabhq_production.events OK
gitlabhq_production.forked_project_links OK
gitlabhq_production.identities OK
gitlabhq_production.issues OK
gitlabhq_production.keys OK
gitlabhq_production.label_links OK
gitlabhq_production.labels OK
gitlabhq_production.members OK
gitlabhq_production.merge_request_diffs OK
gitlabhq_production.merge_requests OK
gitlabhq_production.milestones OK
gitlabhq_production.namespaces OK
gitlabhq_production.notes OK
gitlabhq_production.oauth_access_grants OK
gitlabhq_production.oauth_access_tokens OK
gitlabhq_production.oauth_applications OK
gitlabhq_production.project_import_data OK
gitlabhq_production.projects OK
gitlabhq_production.protected_branches OK
gitlabhq_production.schema_migrations OK
gitlabhq_production.services OK
gitlabhq_production.snippets OK
gitlabhq_production.subscriptions OK
gitlabhq_production.taggings OK
gitlabhq_production.tags OK
gitlabhq_production.users OK
gitlabhq_production.users_star_projects OK
gitlabhq_production.web_hooks OK
OK
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。