關於MyCAT字元集的驗證

來源:互聯網
上載者:User

關於MyCAT字元集的驗證

MyCAT預設字元集是UTF8

下面通過查看日誌來驗證不同的MySQL用戶端字元集和伺服器字元集對於MyCAT的影響。

日誌中與字元集有關的主要有三部分:

1. 初始化MyCAT串連池

2. 心跳檢測

3. 在執行SQL語句時的串連同步。

因為MyCAT實現的是三節點的讀寫分離和自動切換,以下修改的均是localhost節點上MySQL執行個體的字元集,其它兩個點(192.168.244.146和192.168.244.144)均沒有修改。預設為

mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | latin1                     || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | latin1                     || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.01 sec) 

一、當用戶端字元集(character_set_client)為utf8,服務端字元集(character_set_server)為latin1。

mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | latin1                     || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | latin1                     || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)

MyCAT的日誌輸出如下:

1. 初始化串連池

2. 心跳檢測

3. 在執行SQL語句時的串連同步。

二、當用戶端字元集為latin1,服務端字元集也為latin1。

mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | latin1                     || character_set_connection | latin1                     || character_set_database   | latin1                     || character_set_filesystem | binary                     || character_set_results    | latin1                     || character_set_server     | latin1                     || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)

MyCAT的日誌輸出如下:

1. 初始化MyCAT串連池

2. 心跳檢測

3. 在執行SQL語句時的串連同步。

三、當用戶端字元集為latin1,服務端字元集也為utf8。

mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | latin1                     || character_set_connection | latin1                     || character_set_database   | utf8                       || character_set_filesystem | binary                     || character_set_results    | latin1                     || character_set_server     | utf8                       || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)

MyCAT的日誌輸出如下:

1. 初始化MyCAT串連池

2. 心跳檢測

3. 在執行SQL語句時的串連同步。

四、當用戶端字元集為utf8,服務端字元集也為utf8。

mysql> show variables like 'character_set_%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | utf8                       || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | utf8                       || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)

MyCAT的日誌輸出如下:

1. 初始化MyCAT串連池

2. 心跳檢測

3. 在執行SQL語句時的串連同步。

總結:

初始化MyCAT串連池,心跳檢測的字元與服務端字元集有關,即character_set_server設定的值。當localhost的MySQL執行個體的字元集改成utf8後,因為192.168.244.146和192.168.244.144兩個節點的MySQL執行個體的字元集並沒有發生變化,所以執行心跳檢測時,localhost的字元集為utf8,其它兩個節點仍為latin1。

同步串連與用戶端字元集有關,即character_set_client設定的值。

本文永久更新連結地址:

相關文章

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.