欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot如何配置數(shù)據(jù)庫主從shardingsphere

 更新時(shí)間:2024年04月19日 15:27:59   作者:偷代碼的貓  
這篇文章主要介紹了SpringBoot如何配置數(shù)據(jù)庫主從shardingsphere問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

SpringBoot配置數(shù)據(jù)庫主從shardingsphere

spring:
  shardingsphere:
    props.sql.show: true
    datasource:
      names: master,slave1
      master:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://192.168.1.101:3306/user?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true
        username: admin
        password: 123456
        minimum-idle: 10
        maximum-pool-size: 20
        idle-timeout: 300000
        max-lifetime: 900000
        connection-timeout: 30000
        connection-test-query: SELECT 1
      slave1:
        type: com.zaxxer.hikari.HikariDataSource
        driver-class-name: com.mysql.jdbc.Driver
        jdbc-url: jdbc:mysql://192.168.1.102:3306/user?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&allowMultiQueries=true
        username: admin
        password: 123456
        minimum-idle: 10
        maximum-pool-size: 20
        idle-timeout: 300000
        max-lifetime: 900000
        connection-timeout: 30000
        connection-test-query: SELECT 1
    masterslave:
      name: us
      load-balance-algorithm-type: ROUND_ROBIN
      master-data-source-name: master
      slave-data-source-names:
        - slave1
        - master
  jackson:
    serialization:
      indent_output: true
  main:
    allow-bean-definition-overriding: true

1、SQL是否打印顯示

props.sql.show: true

2、數(shù)據(jù)源名稱

names: master,slave1

3、負(fù)載均衡算法

load-balance-algorithm-type: ROUND_ROBIN
 
ROUND_ROBIN:輪詢
RANDOM:隨機(jī)

4、主數(shù)據(jù)源名稱

master-data-source-name: master

5、從數(shù)據(jù)源名稱

slave-data-source-names:
    - slave1
    - master

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論