sharding-proxydocker打包部署和测试的方法是什么
本篇内容介绍了“sharding-proxy docker打包部署和测试的方法是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
10年积累的做网站、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有潮南免费网站建设让你可以放心的选择与我们合作。
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打包部署和测试的方法是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!
本文标题:sharding-proxydocker打包部署和测试的方法是什么
当前URL:http://scyanting.com/article/gggjgi.html