您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“sharding-proxy docker打包部署和測(cè)試的方法是什么”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
1、準(zhǔn)備好mysql master/slave 環(huán)境。
2、自己打包部署:
自己打包,先下載 apache-shardingsphere-4.1.1-sharding-proxy-bin.tar.gz curl -O https://archive.apache.org/dist/shardingsphere/4.1.1/apache-shardingsphere-4.1.1-sharding-proxy-bin.tar.gz 解壓后,如果連mysq8.0,需把 mysql-connector-java-8.0.15.jar 驅(qū)動(dòng)包拷貝到 lib 下 [Dockfile] FROM openjdk:8-jre-slim MAINTAINER summer RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone ADD apache-shardingsphere-4.1.1-sharding-proxy-bin /opt/sharding-proxy ENTRYPOINT ["/bin/sh","-c","/opt/sharding-proxy/bin/start.sh ${PORT} && tail -f /opt/sharding-proxy/logs/stdout.log"] [Build] docker build -t summer/sharding-proxy:v1.0.0 . docker run \ -v /root/dev/sharding-proxy/conf:/opt/sharding-proxy/conf \ -v /root/dev/sharding-proxy/logs:/opt/sharding-proxy/logs \ --link mysql-master:mysql-master-host \ --link mysql-slave0:mysql-slave0-host \ -e PORT=3306 -p3307:3306 --name sharding-proxy -d summer/sharding-proxy:v1.0.0
2、用官方鏡像打包部署
docker pull apache/sharding-proxy:4.1.1 建立 /root/dev/sharding-proxy/conf /root/dev/sharding-proxy/logs /root/dev/sharding-proxy/ext-lib 將 mysql-connector-java-8.0.15.jar 拷貝到 ext-lib docker run \ -v /root/dev/sharding-proxy/conf:/opt/sharding-proxy/conf \ -v /root/dev/sharding-proxy/logs:/opt/sharding-proxy/logs \ -v /root/dev/sharding-proxy/ext-lib:/opt/sharding-proxy/ext-lib \ --link mysql-master:mysql-master-host \ --link mysql-slave0:mysql-slave0-host \ -e PORT=3306 -p3307:3306 --name apache-sharding-proxy -d apache/sharding-proxy:4.1.1 修改配置文件: [server.yaml] authentication: users: root: password: root sharding: password: sharding authorizedSchemas: sharding_db props: max.connections.size.per.query: 1 acceptor.size: 16 # The default value is available processors count * 2. executor.size: 16 # Infinite by default. [config-base.yaml] schemaName: sharding_db dataSources: master_ds: url: jdbc:mysql://mysql-master-host:3306/shardingjdbc?serverTimezone=UTC&useSSL=false username: base_sa password: base_sa connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 slave_ds_0: url: jdbc:mysql://mysql-slave0-host:3306/shardingjdbc?serverTimezone=UTC&useSSL=false username: base_sa password: base_sa connectionTimeoutMilliseconds: 30000 idleTimeoutMilliseconds: 60000 maxLifetimeMilliseconds: 1800000 maxPoolSize: 50 masterSlaveRule: name: ms_ds masterDataSourceName: master_ds slaveDataSourceNames: - slave_ds_0
如果有報(bào)錯(cuò): com.mysql.cj.jdbc.MysqlXAException: XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency 原因是atomikos 解決分布式事務(wù)報(bào)錯(cuò) 解決方案:給賬號(hào)加系統(tǒng)權(quán)限 GRANT XA_RECOVER_ADMIN ON *.* TO base_sa@'%' ;
3、測(cè)試應(yīng)用的配置文件
spring: main: lazy-initialization: false jmx: enabled: false datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://xxxxxxxxxx:3307/sharding_db?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B8 username: sharding password: sharding
“sharding-proxy docker打包部署和測(cè)試的方法是什么”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(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)容。