MySQL學習筆記05MySQL叢集的分布式許可權

來源:互聯網
上載者:User

標籤:str   部署   rest   ges   false   call   資料   roo   節點   

在使用了多個SQL節點之後,預設情況下,在一個節點中增加的使用者,在其它節點上並不是可見的。MySQL 叢集提供了讓使用者和許可權在整個叢集中有效途徑。

 

(1)執行MySQL叢集提供的SQL指令碼。

MySQL叢集在安裝目錄提供了ndb_dist_priv.sql這個指令碼,用於為叢集提供分布式許可權。

在某一個SQL節點61的MySQL服務中執行這個指令碼,這個指令碼將使用者與許可權相關的資料表比如user表等的儲存引擎從MyISAM修改為NDBCluster。

mysql -uroot -p < /usr/share/mysql/ndb_dist_priv.sql

 

執行完畢後,可以看到以下跟分布式許可權有關的預存程序和函數:

mysql> select routine_name,routine_schema,routine_type from information_schema.routines where routine_name like ‘mysql_cluster%‘ order by routine_type asc;

+---------------------------------------------+----------------+--------------+

| routine_name                                | routine_schema | routine_type |

+---------------------------------------------+----------------+--------------+

| mysql_cluster_privileges_are_distributed    | mysql          | FUNCTION     |

| mysql_cluster_backup_privileges             | mysql          | PROCEDURE    |

| mysql_cluster_move_grant_tables             | mysql          | PROCEDURE    |

| mysql_cluster_move_privileges               | mysql          | PROCEDURE    |

| mysql_cluster_restore_local_privileges      | mysql          | PROCEDURE    |

| mysql_cluster_restore_privileges            | mysql          | PROCEDURE    |

| mysql_cluster_restore_privileges_from_local | mysql          | PROCEDURE    |

+---------------------------------------------+----------------+--------------+

7 rows in set (0.08 sec)

 

執行以下函數查詢是否已經部署了分布式許可權。在剛剛執行上述指令碼後,結果是FALSE。

mysql> select mysql_cluster_privileges_are_distributed();

+--------------------------------------------+

| mysql_cluster_privileges_are_distributed() |

+--------------------------------------------+

|                                          0 |

+--------------------------------------------+

1 row in set (0.00 sec)

 

 

(2)執行有關預存程序。

 

需要執行MySQL Cluster提供的以下預存程序,才能實現分布式許可權。

mysql> call mysql_cluster_move_privileges();

Query OK, 0 rows affected (4.23 sec)

 

重新查詢是否部署了分布式許可權,結果為TRUE。

mysql> select mysql_cluster_privileges_are_distributed();

+--------------------------------------------+

| mysql_cluster_privileges_are_distributed() |

+--------------------------------------------+

|                                          1 |

+--------------------------------------------+

1 row in set (0.00 sec)

 

 

(3)重新啟動其它SQL節點的MySQL服務。

在重新啟動之後,就可以看到在節點61上的MySQL服務中的user表的儲存引擎已經修改為NDBCluster了。同時可以看到user表中已經有了節點61中的test使用者了,而且可以使用該使用者進行登入。由於使用者與許可權相關的資料表的儲存引擎為NDBCluster,在之後對使用者與許可權進行的修改,將在整個叢集中有效。

 

至此,MySQL的分布式許可權已經部署完畢了。

 

MySQL學習筆記05MySQL叢集的分布式許可權

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.