您好,登錄后才能下訂單哦!
環(huán)境:mysql一主一從架構(gòu),主庫(kù)是mysql5.1,從庫(kù)是mysql5.6;系統(tǒng)均為CentOS6.2
問(wèn)題:
在主庫(kù)上面執(zhí)行的SQL語(yǔ)句
1.創(chuàng)建表
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.創(chuàng)建用戶并且給予權(quán)限
grant select on databasename.* to 'username'@'IPaddress' identified by 'password'
3.刷新權(quán)限信息
flush privileges
在主庫(kù)上面執(zhí)行完之后,在從庫(kù)上面執(zhí)行show slave status \G發(fā)現(xiàn)IO進(jìn)程和SQL進(jìn)程顯示的都是NO,然后執(zhí)行start slave IO_THREAD之后再次執(zhí)行show slave status \G 發(fā)現(xiàn)IO進(jìn)程是拉起來(lái)了的顯示的是YES,之后再執(zhí)行start slave SQL_THREAD進(jìn)程,show slave status \G發(fā)現(xiàn)IO進(jìn)程和SQL進(jìn)程都是顯示的NO,并且在從庫(kù)的錯(cuò)誤日志中可以獲取得到:
在錯(cuò)誤日志中可以很明顯的看得到日志提示:
Missing system table mysql.proxies_pri;please run mysql_upgrade to create it
日志提示系統(tǒng)表mysql.proxies_pri不存在,需要執(zhí)行mysql_upgrade,然后我自己google了一下,
發(fā)現(xiàn)大部分都是因?yàn)樯?jí)mysql之后沒(méi)有執(zhí)行mysql_upgrade導(dǎo)致的,但是我在主庫(kù)上面根本就沒(méi)有進(jìn)
行任何的升級(jí)操作,在從庫(kù)也是這個(gè)樣子,然后網(wǎng)上的建議是mysql_upgrade升級(jí)修復(fù)一下。
mysql_upgrade主要作用是檢測(cè)所有的表并且升級(jí)mysql這個(gè)系統(tǒng)庫(kù)內(nèi)所有的表,是進(jìn)行在線升級(jí)的,所以并不會(huì)影響線上操作(PS:當(dāng)然不包括有關(guān)mysql庫(kù)的操作)。
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.
可以看到上述對(duì)于mysql.proxies_priv系統(tǒng)表的猜測(cè),可以比較明顯的看到這個(gè)表主要是用來(lái)管理
數(shù)據(jù)庫(kù)用戶權(quán)限信息的表,所以我猜測(cè)數(shù)據(jù)庫(kù)很有可能卡在權(quán)限這塊了,并且在從庫(kù)中我在mysql.user這個(gè)表中并沒(méi)有發(fā)現(xiàn)我之前grant創(chuàng)建的用戶。這個(gè)時(shí)候我在從庫(kù)上面設(shè)置了跳過(guò)一個(gè)事務(wù):
set global sql_slave_skip_counter = 1(只是跳過(guò)一個(gè)事務(wù),跳過(guò)之后歸0)
之后我在重啟start slave。slave恢復(fù)了正常,日志也能夠正常的往里面寫了。所以我猜想這個(gè)問(wèn)題和
權(quán)限有關(guān),假如需要驗(yàn)證的話,最好是在從庫(kù)上面開(kāi)啟general log,并且在從庫(kù)的binlog獲取最新的事
務(wù)的信息并且根據(jù)獲取的信息在relay log中繼日志找到下一個(gè)事務(wù)是不是這個(gè)。
但是這個(gè)方案也是屬于治標(biāo)不治本,下次在執(zhí)行g(shù)rant操作的時(shí)候,可能還是會(huì)出現(xiàn)這個(gè)問(wèn)題,所以還是最后使用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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。