成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

ProxySQL+MySQL實現(xiàn)數(shù)據(jù)庫讀寫分離實戰(zhàn)

數(shù)據(jù)庫 MySQL
今天給大家?guī)淼氖顷P(guān)于數(shù)據(jù)庫讀寫分離相關(guān)的實戰(zhàn)操作。一起來卡一下吧。

前面也寫過幾篇關(guān)于Mysql數(shù)據(jù)的文章:

  •  MySQL集群高可用架構(gòu)之MHA
  •  MySQL 同步復(fù)制及高可用方案總結(jié)
  •  官方工具|MySQL Router 高可用原理與實戰(zhàn)

今天給大家?guī)淼氖顷P(guān)于數(shù)據(jù)庫讀寫分離相關(guān)的實戰(zhàn)操作。

ProxySQL介紹

ProxySQL是一個高性能的MySQL中間件,擁有強大的規(guī)則引擎。具有以下特性:http://www.proxysql.com/

1、連接池,而且是multiplexing

2、主機和用戶的最大連接數(shù)限制

3、自動下線后端DB

  • 延遲超過閥值
  • ping 延遲超過閥值
  • 網(wǎng)絡(luò)不通或宕機

4、強大的規(guī)則路由引擎

  • 實現(xiàn)讀寫分離
  • 查詢重寫
  • sql流量鏡像

5、支持prepared statement

6、支持Query Cache

7、支持負(fù)載均衡,與gelera結(jié)合自動failover

整體環(huán)境介紹

1、系統(tǒng)環(huán)境

三臺服務(wù)器系統(tǒng)環(huán)境一致如下 

  1. [root@db1 ~]# cat /etc/redhat-release   
  2. CentOS Linux release 7.4.1708 (Core)   
  3. [root@db1 ~]# uname -r  
  4. 3.10.0-693.el7.x86_64 

2、IP地址與軟件版本

  • proxy  192.168.22.171
  • db1     192.168.22.173
  • db2    192.168.22.174
  • mysql  5.7.17
  • proxy  sql 1.4.8

3、關(guān)閉防火墻、selinux 

  1. systemctl stop firewalld  #停止防火墻服務(wù)  
  2. systemctl disable firewalld  #禁止開機自啟動  
  3. sed -i 's#SELINUX=enforcing#SELINUX=disabled#g'  /etc/selinux/conf  && reboot  
  4. #用sed命令替換的試修改selinux的配置文件 

4、mysql安裝與主從同步

安裝請參考以下文章

LAMP架構(gòu)應(yīng)用實戰(zhàn)——MySQL服務(wù)

主從同步請參以下文章

Linux系統(tǒng)MySQL數(shù)據(jù)庫主從同步實戰(zhàn)過程

安裝布署過程

1、數(shù)據(jù)庫主從同步

  • 查看主從同步狀態(tài) 
  1. mysql> show slave status\G  
  2. *************************** 1. row ***************************           
  3.  Slave_IO_State: Waiting for master to send event  
  4. Master_Host: 192.168.22.173                
  5. Master_User: rep              
  6. Master_Port: 3306                 
  7. Connect_Retry: 60               
  8. Master_Log_File: master-log.000001 
  9. Read_Master_Log_Pos: 154                
  10. Relay_Log_File: db2-relay-bin.000002  
  11. Relay_Log_Pos: 321          
  12. Relay_Master_Log_File: master-log.000001   
  13. Slave_IO_Running: Yes        
  14. Slave_SQL_Running: Yes             
  15. Replicate_Do_DB:            
  16. Replicate_Ignore_DB:             
  17. Replicate_Do_Table:         
  18. Replicate_Ignore_Table:        
  19. Replicate_Wild_Do_Table:    
  20. Replicate_Wild_Ignore_Table:                     
  21. Last_Errno: 0  
  22. Last_Error:  
  23. Skip_Counter: 0  
  24. Exec_Master_Log_Pos: 154  
  25. Relay_Log_Space: 526  
  26. Until_Condition: None  
  27. Until_Log_File:  
  28. Until_Log_Pos: 0  
  29. Master_SSL_Allowed: No   
  30. Master_SSL_CA_File:   
  31. Master_SSL_CA_Path:   
  32. Master_SSL_Cert:  
  33. Master_SSL_Cipher:  
  34. Master_SSL_Key:  
  35. Seconds_Behind_Master: 0  
  36. Master_SSL_Verify_Server_Cert: No   
  37. Last_IO_Errno: 0   
  38. Last_IO_Error:   
  39. Last_SQL_Errno: 0   
  40. Last_SQL_Error:  
  41. Replicate_Ignore_Server_Ids:   
  42. Master_Server_Id: 1   
  43. Master_UUID: 70a61633-63ae-11e8-ab86-000c29fe99ea   
  44. Master_Info_File: /mysqldata/master.info  
  45. SQL_Delay: 0   
  46. SQL_Remaining_Delay: NULL  
  47. Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates   
  48. Master_Retry_Count: 86400   
  49. Master_Bind:  
  50. Last_IO_Error_Timestamp:  
  51. Last_SQL_Error_Timestamp:  
  52. Master_SSL_Crl:   
  53. Master_SSL_Crlpath:   
  54. Retrieved_Gtid_Set:   
  55. Executed_Gtid_Set:   
  56. Auto_Position: 0   
  57. Replicate_Rewrite_DB:  
  58. Channel_Name:   
  59. Master_TLS_Version:  
  60. 1 row in set (0.00 sec) 
  • 檢測主從同步 
  1. [root@db1 ~]# mysql -uroot -p -e "create database testdb;  
  2. "Enter password:   
  3. [root@db1 ~]# mysql -uroot -p -e "show  databases;" |grep testdb  
  4. Enter password:   
  5. testdb  
  6. #db2上查看是否同步  
  7. mysql> show databases;  
  8. +--------------------+  
  9. | Database           |  
  10. +--------------------+  
  11. | information_schema |  
  12. | mysql              |  
  13. | performance_schema |  
  14. | sys                |  
  15. | testdb             |  
  16. +--------------------+  
  17. 5 rows in set (0.01 sec) 

2、準(zhǔn)備proxySQL軟件 

  1. [root@proxy ~]# wget https://github.com/sysown/proxysql/releases/download/v1.4.8/proxysql-1.4.8-1-centos7.x86_64.rpm  
  2. [root@proxy ~]# ll proxysql-1.4.8-1-centos7.x86_64.rpm   
  3. -rw-r--r-- 1 root root 5977168 Apr 10 11:38 proxysql-1.4.8-1-centos7.x86_64.rpm 

3、安裝配置 

  1. [root@proxy ~]# yum install -y proxysql-1.4.8-1-centos7.x86_64.rpm  
  2. [root@proxy ~]# rpm -ql  proxysql  
  3. /etc/init.d/proxysql    #啟動腳本  
  4. /etc/proxysql.cnf       #配置文件,僅在第一次(/var/lib/proxysql/proxysql.db文件不存在)啟動時有效。啟#動后可以在proxysql管理端中通過修改數(shù)據(jù)庫的方式修改配置并生效(官方推薦方式。)  
  5. /usr/bin/proxysql       #主程序文件  
  6. /usr/share/proxysql/tools/proxysql_galera_checker.sh  
  7. /usr/share/proxysql/tools/proxysql_galera_writer.pl 

4、配置文件詳解 

  1. [root@proxy ~]# egrep -v "^#|^$" /etc/proxysql.cnf  
  2. datadir="/var/lib/proxysql"     #數(shù)據(jù)目錄  
  3. admin_variables 
  4. {      
  5. admin_credentials="admin:admin"   #連接管理端的用戶名與密碼   
  6. mysql_ifaces="0.0.0.0:6032"       #管理端口,用來連接proxysql的管理數(shù)據(jù)庫  
  7.  
  8. mysql_variables 
  9. {      
  10. threads=4      #指定轉(zhuǎn)發(fā)端口開啟的線程數(shù)量      
  11. max_connections=2048      
  12. default_query_delay=0  
  13. default_query_timeout=36000000  
  14. have_compress=true  
  15. poll_timeout=2000  
  16. interfaces="0.0.0.0:6033"        #指定轉(zhuǎn)發(fā)端口,用于連接后端mysql數(shù)據(jù)庫的,相當(dāng)于代理作用  
  17. default_schema="information_schema"  
  18. stacksize=1048576  
  19. server_version="5.5.30"          #指定后端mysql的版本  
  20. connect_timeout_server=3000   
  21. monitor_username="monitor"  
  22. monitor_password="monitor"  
  23. monitor_history=600000  
  24. monitor_connect_interval=60000  
  25. monitor_ping_interval=10000  
  26. monitor_read_only_interval=1500   
  27. monitor_read_only_timeout=500    
  28. ping_interval_server_msec=120000   
  29. ping_timeout_server=500  
  30. commands_stats=true   
  31. sessions_sort=true   
  32. connect_retries_on_failure=10  
  33.  
  34. mysql_servers =  
  35.  
  36.  
  37. mysql_users:  
  38.  
  39.  
  40. mysql_query_rules:  
  41.  
  42.  
  43. scheduler 
  44.  
  45.  
  46. mysql_replication_hostgroups 
  47.  
  48.  
  49. #因此我們使用官方推薦的方式來配置proxy sql 

5、啟動服務(wù)并查看 

  1. [root@proxy ~]# /etc/init.d/proxysql  
  2. startStarting ProxySQL: DONE!  
  3. [root@proxy ~]# ss -lntup|grep proxy  
  4. tcp    LISTEN     0   128   *:6032      *:*    users:(("proxysql",pid=1199,fd=23))  
  5. tcp    LISTEN     0   128   *:6033      *:*    users:(("proxysql",pid=1199,fd=22))  
  6. tcp    LISTEN     0   128   *:6033      *:*    users:(("proxysql",pid=1199,fd=21))  
  7. tcp    LISTEN     0   128   *:6033      *:*    users:(("proxysql",pid=1199,fd=20))  
  8. tcp    LISTEN     0   128   *:6033      *:*    users:(("proxysql",pid=1199,fd=19))   
  9. #可以看出轉(zhuǎn)發(fā)端口6033是啟動了四個線程 

6、在mysql上配置賬號并授權(quán) 

  1. mysql> GRANT ALL ON *.* TO 'proxysql'@'192.168.22.%' IDENTIFIED BY '123456';  
  2. Query OK, 0 rows affected, 1 warning (0.03 sec)  
  3. mysql> flush privileges;  
  4. Query OK, 0 rows affected (0.02 sec) 

7、proxysql默認(rèn)數(shù)據(jù)庫說明 

  1. [root@proxy ~]# yum install mysql -y  
  2. [root@proxy ~]# mysql -uadmin -padmin -h127.0.0.1 -P6032  
  3. Welcome to the MariaDB monitor.  Commands end with ; or \g.  
  4. Your MySQL connection id is 1  
  5. Server version: 5.5.30 (ProxySQL Admin Module) 
  6. Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.  
  7. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  8. MySQL [(none)]> show databases;  
  9. +-----+---------------+-------------------------------------+  
  10. | seq | name          | file                                |  
  11. +-----+---------------+-------------------------------------+  
  12. | 0   | main          |                                     |  
  13. | 2   | disk          | /var/lib/proxysql/proxysql.db       |  
  14. | 3   | stats         |                                     |  
  15. | 4   | monitor       |                                     |  
  16. | 5   | stats_history | /var/lib/proxysql/proxysql_stats.db |  
  17. +-----+---------------+-------------------------------------+  
  18. 5 rows in set (0.00 sec) 

main:內(nèi)存配置數(shù)據(jù)庫,表里存放后端db實例、用戶驗證、路由規(guī)則等信息。表名以 runtime_開頭的表示proxysql當(dāng)前運行的配置內(nèi)容,不能通過dml語句修改,只能修改對應(yīng)的不以 runtime_ 開頭的(在內(nèi)存)里的表,然后 LOAD 使其生效, SAVE 使其存到硬盤以供下次重啟加載。

disk:是持久化到硬盤的配置,sqlite數(shù)據(jù)文件。

stats:是proxysql運行抓取的統(tǒng)計信息,包括到后端各命令的執(zhí)行次數(shù)、流量、processlist、查詢種類匯總/執(zhí)行時間等等。

monitor:庫存儲 monitor 模塊收集的信息,主要是對后端db的健康/延遲檢查。

8、proxysql的配置系統(tǒng)

ProxySQL具有一個復(fù)雜但易于使用的配置系統(tǒng),可以滿足以下需求:

1、允許輕松動態(tài)更新配置(這是為了讓ProxySQL用戶可以在需要零宕機時間配置的大型基礎(chǔ)架構(gòu)中使用它)。與MySQL兼容的管理界面可用于此目的。

2、允許盡可能多的配置項目動態(tài)修改,而不需要重新啟動ProxySQL進(jìn)程

3、可以毫不費力地回滾無效配置

4、這是通過多級配置系統(tǒng)實現(xiàn)的,其中設(shè)置從運行時移到內(nèi)存,并根據(jù)需要持久保存到磁盤。

  • 3級配置由以下幾層組成:

參考文章:https://github.com/sysown/pro...

9、配置proxysql管理用戶

proxysql默認(rèn)的表信息如下 

  1. MySQL [main]> show tables;  
  2. +--------------------------------------------+  
  3. | tables                                     |  
  4. +--------------------------------------------+  
  5. | global_variables                           |  
  6. | mysql_collations                           |  
  7. | mysql_group_replication_hostgroups         |  
  8. | mysql_query_rules                          |  
  9. | mysql_query_rules_fast_routing             |  
  10. | mysql_replication_hostgroups               |  
  11. | mysql_servers                              |  
  12. | mysql_users                                |  
  13. | proxysql_servers                           |  
  14. | runtime_checksums_values                   |  
  15. | runtime_global_variables                   |  
  16. | runtime_mysql_group_replication_hostgroups |  
  17. | runtime_mysql_query_rules                  |  
  18. | runtime_mysql_query_rules_fast_routing     |  
  19. | runtime_mysql_replication_hostgroups       |  
  20. | runtime_mysql_servers                      |  
  21. | runtime_mysql_users                        |  
  22. | runtime_proxysql_servers                   |  
  23. | runtime_scheduler                          |  
  24. | scheduler                                  |  
  25. +--------------------------------------------+  
  26. 20 rows in set (0.00 sec)  
  27. #這里是使用insert into語句來動態(tài)配置,而可以不需要重啟  
  28. MySQL [(none)]> insert into mysql_servers(hostgroup_id,hostname,port,weight,comment) values(1,'db1','3306',1,'Write Group');  
  29. Query OK, 1 row affected (0.01 sec)  
  30. MySQL [(none)]> insert intomysql_servers(hostgroup_id,hostname,port,weight,comment) values(2,'db2','3307',1,'Read Group');  
  31. Query OK, 1 row affected (0.00 sec)  
  32. MySQL [(none)]> select * from mysql_servers;  
  33. +--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+  
  34. | hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment     |  
  35. +--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+  
  36. | 1            | db1      | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              | Write Group |  
  37. | 2            | db2      | 3307 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              | Read Group    
  38. |+--------------+----------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+-------------+  
  39. 2 rows in set (0.00 sec)  
  40. #接下來將剛剛在mysql客戶端創(chuàng)建的用戶寫入到proxy sql主機的mysql_users表中,它也是用于proxysql客戶端訪問數(shù)據(jù)庫,默認(rèn)組是寫組,當(dāng)讀寫分離規(guī)則出現(xiàn)問題時,它會直接訪問默認(rèn)組的數(shù)據(jù)庫。  
  41. MySQL [main]> INSERT INTO mysql_users(username,password,default_hostgroup) VALUES ('proxysql','123456',1);  
  42. Query OK, 1 row affected (0.00 sec)  
  43. MySQL [main]> select * from mysql_users;  
  44. +----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+ 
  45. | username | password | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections | 
  46. +----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+ 
  47. | proxysql | 123456   | 1      | 0       | 1                 | NULL           | 0             | 1                      | 0            | 1       | 1        | 10000           | 
  48. +----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+1  
  49. row in set (0.00 sec) 
  • 在mysql上添加監(jiān)控的用戶 
  1. mysql> GRANT SELECT ON *.* TO 'monitor'@'192.168.22.%' IDENTIFIED BY 'monitor';  
  2. Query OK, 0 rows affected, 1 warning (0.00 sec)  
  3. mysql> flush privileges;  
  4. Query OK, 0 rows affected (0.00 sec)  
  5. #在proxysql主機端配置監(jiān)控用戶  
  6. MySQL [main]> set mysql-monitor_username='monitor' 
  7. Query OK, 1 row affected (0.00 sec)  
  8. MySQL [main]> set mysql-monitor_password='monitor' 
  9. Query OK, 1 row affected (0.00 sec)  
  10. #參考文章:https://github.com/sysown/proxysql/wiki/ProxySQL-Configuration 

10、配置proxysql的轉(zhuǎn)發(fā)規(guī)則 

  1. MySQL [main]> insert into mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply)values(1,1,'^SELECT.*FOR UPDATE$',1,1);  
  2. Query OK, 1 row affected (0.01 sec)  
  3. MySQL [main]> insert into mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply)values(2,1,'^SELECT',2,1); 
  4. Query OK, 1 row affected (0.00 sec)  
  5. MySQL [main]> select rule_id,active,match_digest,destination_hostgroup,apply from mysql_query_rules;  
  6. +---------+--------+----------------------+-----------------------+-------+  
  7. | rule_id | active | match_digest         | destination_hostgroup | apply |  
  8. +---------+--------+----------------------+-----------------------+-------+  
  9. | 1       | 1      | ^SELECT.*FOR UPDATE$ | 1                     | 1     |  
  10. | 2       | 1      | ^SELECT              | 2                     | 1     |  
  11. +---------+--------+----------------------+-----------------------+-------+  
  12. 2 rows in set (0.00 sec)  
  13. #配置查詢select的請求轉(zhuǎn)發(fā)到hostgroup_id=2組上(讀組)#征對select * from table_name  for update這樣的修改語句,我們是需要將請求轉(zhuǎn)到寫組,也就是hostgroup_id=1#對于其它沒有被規(guī)則匹配的請求全部轉(zhuǎn)發(fā)到默認(rèn)的組(mysql_users表中default_hostgroup) 

 11、更新配置到RUNTIME中

由上面的配置系統(tǒng)層級關(guān)系可以得知所有進(jìn)來的請求首先是經(jīng)過RUNTIME層 

  1. MySQL [main]> load mysql users to runtime;  
  2. Query OK, 0 rows affected (0.00 sec)  
  3. MySQL [main]> load mysql servers to runtime;  
  4. Query OK, 0 rows affected (0.02 sec)  
  5. MySQL [main]> load mysql query rules to runtime;  
  6. Query OK, 0 rows affected (0.00 sec)  
  7. MySQL [main]> load mysql variables to runtime; 
  8. Query OK, 0 rows affected (0.00 sec)  
  9. MySQL [main]> load admin variables to runtime;  
  10. Query OK, 0 rows affected (0.00 sec) 

12、將所有配置保存至磁盤上

所有配置數(shù)據(jù)保存到磁盤上,也就是永久寫入/var/lib/proxysql/proxysql.db這個文件中 

  1. MySQL [main]> save mysql users to disk;  
  2. Query OK, 0 rows affected (0.03 sec)  
  3. MySQL [main]> save mysql servers to disk;  
  4. Query OK, 0 rows affected (0.04 sec)  
  5. ySQL [main]> save mysql query rules to disk;  
  6. Query OK, 0 rows affected (0.03 sec)  
  7. MySQL [main]> save mysql variables to disk;  
  8. Query OK, 94 rows affected (0.02 sec) 
  9. MySQL [main]> save admin variables to disk;  
  10. Query OK, 31 rows affected (0.02 sec)  
  11. MySQL [main]> load mysql users to runtime;  
  12. Query OK, 0 rows affected (0.00 sec) 

13、測試讀寫分離 

  1. [root@proxy ~]# mysql -uproxysql -p123456 -h 127.0.0.1 -P 6033  
  2. Welcome to the MariaDB monitor.Commands end with ; or \g.  
  3. Your MySQL connection id is 2Server version: 5.5.30 (ProxySQL) 
  4. Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.  
  5. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  6. MySQL [(none)]> show databases;  
  7. +--------------------+  
  8. | Database           |  
  9. +--------------------+  
  10. | information_schema |  
  11. | mysql              |  
  12. | performance_schema |  
  13. | sys                |  
  14. | testdb             |  
  15. +--------------------+  
  16. 5 rows in set (0.02 sec)#這才是我們真正的數(shù)據(jù)庫啊 
  • 創(chuàng)建數(shù)據(jù)與表,測試讀寫分離情況 
  1. MySQL [(none)]> create database test_proxysql;  
  2. Query OK, 1 row affected (0.02 sec)  
  3. MySQL [(none)]> use test_proxysql;  
  4. Database changed  
  5. MySQL [test_proxysql]> create table test_tables(name varchar(20),age int(4));  
  6. Query OK, 0 rows affected (0.07 sec)  
  7. MySQL [test_proxysql]> insert into test_tables values('zhao','30');  
  8. Query OK, 1 row affected (0.09 sec)  
  9. MySQL [test_proxysql]> select * from test_tables;  
  10. +------+------+  
  11. | name | age  |  
  12. +------+------+  
  13. | zhao |   30 |  
  14. +------+------+  
  15. 1 row in set (0.02 sec) 
  • 在proxysql管理端查看讀寫分離 
  1. MySQL [main]> select * from stats_mysql_query_digest;  
  2. +-----------+--------------------+----------+--------------------+------------------------------------------------------+------------+------------+------------+----------+----------+----------+ 
  3. | hostgroup | schemaname         | username | digest             | digest_text                                          | count_star | first_seen | last_seen  | sum_time | min_time | max_time | 
  4. +-----------+--------------------+----------+--------------------+------------------------------------------------------+------------+------------+------------+----------+----------+----------+ 
  5. | 2         | test_proxysql      | proxysql | 0x57CF7EC26C91DF9A | select * from test_tables                            |1          | 1527667635 | 1527667635 | 14253    | 14253    | 14253    | 
  6. | 1         | information_schema | proxysql | 0x226CD90D52A2BA0B | select @@version_comment limit ?                     | 1          | 1527667214 | 1527667214 | 0        | 0        | 0        | 
  7. | 1         | test_proxysql      | proxysql | 0xFF9877421CFBDA6F | insert into test_tables values(?,?)                  | 1          | 1527667623 | 1527667623 | 89033    | 89033    | 89033    | 
  8. | 1         | information_schema | proxysql | 0xE662AE2DEE853B44 | create database test-proxysql                        | 1          | 1527667316 | 1527667316 | 8470     | 8470     | 8470     | 
  9. | 1         | information_schema | proxysql | 0x02033E45904D3DF0 | show databases                                       | 1          | 1527667222 | 1527667222 | 19414    | 19414    | 19414    | 
  10. | 1         | information_schema | proxysql | 0xB9EF28C84E4207EC | create database test_proxysql                        | 1          | 1527667332 | 1527667332 | 15814    | 15814    | 15814    | 
  11. | 2         | information_schema | proxysql | 0x620B328FE9D6D71A | SELECT DATABASE()                                    | 1          | 1527667342 | 1527667342 | 23386    | 23386    | 23386    | 
  12. | 1         | test_proxysql      | proxysql | 0x02033E45904D3DF0 | show databases                                       | 1          | 1527667342 | 1527667342 | 2451     | 2451     | 2451     | 
  13. | 1         | test_proxysql      | proxysql | 0x59F02DA280268525 | create table test_tables                             | 1          | 1527667360 | 1527667360 | 9187     | 9187     | 9187     | 
  14. | 1         | test_proxysql      | proxysql | 0x99531AEFF718C501 | show tables                                          | 1          | 1527667342 | 1527667342 | 1001     | 1001     | 1001     | 
  15. | 1         | test_proxysql      | proxysql | 0xC745E37AAF6095AF | create table test_tables(name varchar(?),age int(?)) | 1          | 1527667558 | 1527667558 | 68935    | 68935    | 68935    | 
  16. +-----------+--------------------+----------+--------------------+------------------------------------------------------+------------+------------+------------+----------+----------+----------+ 
  17. 11 rows in set (0.01 sec)#從上述結(jié)果就可以看出讀寫分離配置是成功的,讀請求是轉(zhuǎn)發(fā)到2組,寫請求轉(zhuǎn)發(fā)到1組 

  • 整個讀寫分離的架構(gòu)配置到此就完成了,但是此架構(gòu)存在需要優(yōu)化的地方,那就是此架構(gòu)存在單點問題。實際生產(chǎn)環(huán)境中可采用MHA+ProxySQL+Mysql這類架構(gòu)解決此問題,請持續(xù)關(guān)注! 

 

責(zé)任編輯:龐桂玉 來源: segmentfault
相關(guān)推薦

2022-12-15 09:44:29

數(shù)據(jù)庫利器

2018-10-16 16:45:05

數(shù)據(jù)庫讀寫分離

2018-02-24 19:37:33

Java8數(shù)據(jù)庫中間件

2019-07-05 11:20:31

PythonMySQL數(shù)據(jù)庫

2022-12-05 07:51:24

數(shù)據(jù)庫分庫分表讀寫分離

2017-03-14 13:12:19

2009-05-04 09:13:52

PHPMySQL讀寫分離

2017-09-04 09:53:58

MySQLAtlasNavicat

2021-06-25 10:05:58

SpringBootMySQL數(shù)據(jù)庫

2017-05-25 10:22:13

NoSQL數(shù)據(jù)庫主主備份

2024-09-20 07:38:00

數(shù)據(jù)庫性能策略

2025-04-22 09:31:52

2011-08-30 09:59:47

Mysql ProxyLUA

2021-09-08 10:23:08

讀寫分離Java數(shù)據(jù)庫

2018-01-09 18:46:44

數(shù)據(jù)庫架構(gòu)讀寫分離

2018-01-15 05:54:45

數(shù)據(jù)庫讀寫分離互聯(lián)網(wǎng)

2020-05-26 10:42:31

數(shù)據(jù)庫讀寫分離數(shù)據(jù)庫架構(gòu)

2020-01-03 16:30:14

數(shù)據(jù)庫讀寫分離分庫

2020-11-24 09:56:12

數(shù)據(jù)源讀寫分離

2020-04-23 15:08:41

SpringBootMyCatJava
點贊
收藏

51CTO技術(shù)棧公眾號

主站蜘蛛池模板: 午夜网 | 国产一级特黄真人毛片 | 亚洲欧美在线观看 | 午夜黄色影院 | 四虎在线视频 | 中文字幕一区二区三区四区五区 | 成年人在线视频 | 天堂一区二区三区四区 | 精品国产乱码久久久久久蜜退臀 | 国产成人在线视频免费观看 | 国产一区三区在线 | 亚洲有码转帖 | 国产ts人妖系列高潮 | av网站免费在线观看 | 成人av网站在线观看 | 亚洲性视频网站 | 不卡在线视频 | 日韩三极 | 成人免费一区二区三区视频网站 | 国内av在线| 久久成人一区 | 中文字幕精品一区二区三区精品 | 久久久久久久夜 | 欧洲免费毛片 | 欧美大片久久久 | 国产中文字幕在线观看 | 亚洲精久久久 | www.精品一区 | 欧美极品一区二区 | 毛片电影 | 国产精品一级 | 国产a级毛毛片 | 精品福利在线 | 国产成人a亚洲精品 | 国产999精品久久久久久 | 九九伦理片| 男女激情网站免费 | 成人综合一区 | 免费观看一级特黄欧美大片 | 国产精品久久精品 | 国产激情一区二区三区 |