MaxScale2.0.1結合Java Druid串連池實現讀寫分離注意事項

來源:互聯網
上載者:User

標籤:串連池   讀寫分離   maxscale   

現象:

程式會不定時的出現串連錯誤,問題bug的異常資訊如下:

The last packet successfully received from the server was 116 milliseconds ago.  The last packet sent successfully to the server was 115 milliseconds ago.

java.sql.SQLException: No database selected

 

但通過用戶端sqlyog/navicat串連均為正常。

----------------------------------------------------------------------

另:maxscale1.4.3有時還會出現掛起現象,4006連接埠直接關閉。後我們用了watch命令後台跑監控。

watch -d /bin/bash /root/sh/restart_maxsacle.sh

#!/bin/bashnetstat -ntlp | grep maxscale | grep 4006 > /dev/null 2>&1if [ $? -eq 1 ];then/etc/init.d/maxscale startfi


解決:5.6以下可以直接在url上配置:autoReconnect=true

對於5.6以上的只能在jdbc的連結池裡設定:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/89/C7/wKiom1gcJ8eRZd5cAABCHLTCyQg422.png" title="圖片1.png" alt="wKiom1gcJ8eRZd5cAABCHLTCyQg422.png" />


第一個設定成ture,逾時自動連結,對於mysql要把第二個設定成false,不啟用緩衝。

以上是開發需要注意的都是一些基本的配置。

 

其目的為:每次歸還串連時執行select ‘x‘檢測串連是否有效。




本文出自 “賀春暘的技術專欄” 部落格,請務必保留此出處http://hcymysql.blog.51cto.com/5223301/1869414

MaxScale2.0.1結合Java Druid串連池實現讀寫分離注意事項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.