您好,登錄后才能下訂單哦!
本篇內容介紹了“sharding-proxy docker打包部署和測試的方法是什么”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
1、準備好mysql master/slave 環境。
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 驅動包拷貝到 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
如果有報錯: com.mysql.cj.jdbc.MysqlXAException: XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency 原因是atomikos 解決分布式事務報錯 解決方案:給賬號加系統權限 GRANT XA_RECOVER_ADMIN ON *.* TO base_sa@'%' ;
3、測試應用的配置文件
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打包部署和測試的方法是什么”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。