SELECT VARIABLE_VALUE ..."/>
您好,登錄后才能下訂單哦!
可以通過global status
group_replication_primary_member
確定
root@db20:59: [mgr]> SELECT VARIABLE_VALUE -> FROM performance_schema.global_status -> WHERE VARIABLE_NAME = 'group_replication_primary_member'; +--------------------------------------+ | VARIABLE_VALUE | +--------------------------------------+ | f8da6826-328a-11e9-8e54-000c29d7ca48 | +--------------------------------------+ 1 row in set (0.00 sec)
可以結(jié)合 performance_schema.replication_group_members 表 獲取主機(jī)名和端口信息:
root@db21:05: [mgr]> SELECT -> MEMBER_HOST, MEMBER_PORT -> FROM -> performance_schema.replication_group_members -> WHERE -> MEMBER_ID = (SELECT -> VARIABLE_VALUE -> FROM -> performance_schema.global_status -> WHERE -> VARIABLE_NAME = 'group_replication_primary_member'); +-------------+-------------+ | MEMBER_HOST | MEMBER_PORT | +-------------+-------------+ | mgr1 | 3306 | +-------------+-------------+ 1 row in set (0.00 sec)
或者獲取全部成員信息:
root@db21:05: [mgr]> SELECT -> MEMBER_ID, -> MEMBER_HOST, -> MEMBER_PORT, -> MEMBER_STATE, -> IF(global_status.VARIABLE_NAME IS NOT NULL, -> 'PRIMARY', -> 'SECONDARY') AS MEMBER_ROLE -> FROM -> performance_schema.replication_group_members -> LEFT JOIN -> performance_schema.global_status ON global_status.VARIABLE_NAME = 'group_replication_primary_member' -> AND global_status.VARIABLE_VALUE = replication_group_members.MEMBER_ID; +--------------------------------------+-------------+-------------+--------------+-------------+ | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | +--------------------------------------+-------------+-------------+--------------+-------------+ | f8da6826-328a-11e9-8e54-000c29d7ca48 | mgr1 | 3306 | ONLINE | PRIMARY | | 030930d7-32b2-11e9-8298-000c292aafc5 | mgr2 | 3306 | ONLINE | SECONDARY | | 202bdcd5-32b3-11e9-9f4f-000c29322d33 | mgr3 | 3306 | ONLINE | SECONDARY | +--------------------------------------+-------------+-------------+--------------+-------------+ 3 rows in set (0.01 sec)
MySQL 8.0.2開始, Performance Schema被擴(kuò)展
SELECT MEMBER_HOST, MEMBER_PORT FROM performance_schema.replication_group_members WHERE MEMBER_ROLE = 'PRIMARY';
或者獲取全部成員信息:
mysql> SELECT MEMBER_ID, MEMBER_HOST, MEMBER_PORT, MEMBER_STATE, MEMBER_ROLE, MEMBER_VERSION FROM performance_schema.replication_group_members;
免責(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)容。