当前位置:网站首页>Yyds dry inventory Druid connection pool usage
Yyds dry inventory Druid connection pool usage
2022-06-26 07:31:00 【Feng, crazy】
brief introduction
Druid Able to provide strong ⼤ Monitoring and expansion functions of .
⼀、 send ⽤
1.1 maven To configure :
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.18</version>
</dependency>
- 1.
- 2.
- 3.
- 4.
- 5.
1.2 Integrate spring boot
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.18</version>
</dependency>
- 1.
- 2.
- 3.
- 4.
- 5.
⼆、 Monitoring statistics
2.1 open
https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter
2.2 send ⽤ And configuration StatViewServlet
https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatViewServlet%E9%85%8D%E7%BD%AE
Druid Built in provides ⼀ individual StatViewServlet⽤ Yu Zhan ⽰Druid Statistical information .
This StatViewServlet Of ⽤ Transit includes :
- Provide monitoring information exhibition ⽰ Of html page ⾯
- Providing monitoring information JSON API
Be careful : send ⽤StatViewServlet, It is suggested that ⽤druid 0.2.6 Above version .
2.3 send ⽤ And configuration WebStatFilter
https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter
WebStatFilter⽤ To collect web-jdbc Associated monitoring data .
2.4 send ⽤ And configuration Spring Association monitoring
Druid Provides Spring and Jdbc Associated monitoring of .
3、 ... and 、 Reference configuration
Database connection pool
DruidDataSource To configure
Druid Spring Boot Starter
https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter
3.1 Add the configuration
spring.datasource.url=jdbc:mysql://localhost:3306/park?
useUnicode=true&characterEncoding=utf8mb4
spring.datasource.username=root
spring.datasource.password=123456
# ... Other configuration ( Optional , It's not necessary , send ⽤ If the database is embedded, the above three items can also be omitted )
- 1.
- 2.
- 3.
- 4.
- 5.
3.2 Configuration properties
Druid Spring Boot Starter The name of the configuration property exactly follows Druid, You can go through Spring Boot To configure ⽂ To configure Druid Database connection
Pool connection and monitoring , If it is not configured, make ⽤ The default value is .
######## JDBC To configure ########
#spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://localhost:3306/park?
useUnicode=true&characterEncoding=utf-8
spring.datasource.password=123456
spring.datasource.username=root
#spring.security.user.name=test
#spring.security.user.password=123456
################################### Start Druid To configure
###################################
######## ⼀、 Connection pool configuration ########
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=30
spring.datasource.druid.min-idle=5
# Get the most ⼤ Waiting time (ms)
spring.datasource.druid.max-wait=60000
# Configure monitoring statistics interception filters, Remove the post monitoring boundary ⾯sql⽆ Law statistics ,'wall'⽤ In case ⽕ wall # Configure multiple English characters ⽂ Comma separated
# this ⾥ send ⽤ Are all default configurations , Sure ⾃ Definition
spring.datasource.druid.filters=stat,wall
# adopt connectProperties Property to open mergeSql function ; slow SQL Record
spring.datasource.druid.connectionproperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
# Merge multiple DruidDataSource Monitoring data
spring.datasource.druid.use-global-data-source-stat=true
# Whether the cache preparedStatement, That is to say PSCache.PSCache Yes ⽀ The performance of database with cursor is greatly improved ⼤,⽐ If you say
oracle. stay mysql The next suggestion is to close .
spring.datasource.druid.pool-prepared-statements=false
# To start ⽤PSCache, You have to configure ⼤ On 0, When ⼤ On 0 when ,poolPreparedStatements⾃ The automatic trigger is modified to true
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=0
# And on ⾯ Equivalence
spring.datasource.druid.max-open-prepared-statements= 0
# ⽤ To check whether the connection is valid sql
spring.datasource.druid.validation-query=select 1 from dual
spring.datasource.druid.validation-query-timeout=60000
# Apply for connection with ⾏validationQuery Check whether the connection is valid , This configuration will degrade performance .
spring.datasource.druid.test-on-borrow=false
# Return the connection with ⾏validationQuery Check whether the connection is valid , This configuration will degrade performance .
spring.datasource.druid.test-on-return=false
# Recommended configuration is true, No performance impact , And ensure safety . Check when applying for connection , If you have free time ⼤ On
timeBetweenEvictionRunsMillis, Of board ⾏validationQuery Check whether the connection is valid
spring.datasource.druid.test-while-idle=true
# How long is the configuration interval ⾏⼀ Secondary test , Detects idle connections that need to be closed , In milliseconds
spring.datasource.druid.time-between-eviction-runs-millis=60000
# The connection remains idle ⽽ The best way not to be expelled ⼩ Time spring.datasource.druid.min-evictable-idle-time-millis=300000
spring.datasource.druid.max-evictable-idle-time-millis=300000
spring.datasource.druid.login-timeout=6000
######## ⼆、WebStatFilter To configure ########
#
## WebStatFilter To configure , Please refer to Druid Wiki, To configure _ To configure WebStatFilter
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-statfilter.exclusions=*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*,/druid
spring.datasource.druid.web-stat-filter.session-stat-enable=
spring.datasource.druid.web-stat-filter.session-stat-max-count=
spring.datasource.druid.web-stat-filter.principal-session-name=
spring.datasource.druid.web-stat-filter.principal-cookie-name=
spring.datasource.druid.web-stat-filter.profile-enable=
######## ⼆、StatViewServlet To configure ########
#
## StatViewServlet To configure , Please refer to Druid Wiki, To configure _StatViewServlet To configure
# Start or not ⽤StatViewServlet( Monitoring page ⾯) The default value is false( Considering the security problem, it is not started by default , To start ⽤ It is recommended to set a key or ⽩ List to ensure safety )
spring.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=123456
# Forbid ⽤HTML page ⾯ Upper “Reset All” function
spring.datasource.druid.stat-view-servlet.reset-enable=false
# IP⽩ list ( Not configured or empty , All access is allowed )
spring.datasource.druid.stat-view-servlet.allow=
# IP⿊ list ( In common ,deny Prior to the allow)
spring.datasource.druid.stat-view-servlet.deny=
######## 3、 ... and 、StatViewServlet To configure ########
#
## Spring Monitoring configuration , Please refer to Druid Github Wiki, To configure _Druid and Spring Associated monitoring configuration
# Spring monitor AOP cut ⼊ spot , Such as x.y.z.service.*, Configure multiple English characters ⽂ Comma separated
spring.datasource.druid.aoppatterns=com.xiaofu.park.controller.*,com.xiaofu.park.service.*,com.xiaofu.park.dao.
*
################################### End Druid To configure
###################################
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.
3.3 filter send ⽤
⽬ The former is the following Filter Provides configuration ⽀ a , Please refer to ⽂ Or according to IDE carry ⽰(spring.datasource.druid.filter.*) Into the ⾏ To configure .
- StatFilter
- WallFilter
- ConfigFilter
- EncodingConvertFilter
- Slf4jLogFilter
- Log4jFilter
- Log4j2Filter
- CommonsLogFilter
边栏推荐
- Qt基础教程:QString
- How to convert Unicode into Chinese characters in Excel
- Dark red crystal meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin (co TAPP); Meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin no complex (TAPP co no) supplied by Qiyue
- Liquid crystal texture diagram of purple solid mm-tpp-10c methacrylic acid decanoxy tetraphenyl porphyrin and mm-tpp-12c methacrylic acid dodecanoxy tetraphenyl porphyrin - Qi Yue display
- How can I find the completely deleted photos in Apple mobile phone?
- Jemter 压力测试 -基础请求-【教学篇】
- MySQL'replace into'has a self incrementing ID of the pit. There is a problem with the backup opportunity
- 一文分析EventBus-事件总线的使用方法和实现原理
- Recognize pnpm: faster, higher performance NPM
- In interface testing, several methods to verify the success of deleting interfaces
猜你喜欢

Deep exploration image theme color extraction

Children play games (greed, prefix and) - Niuke winter vacation training camp
![5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent](/img/2b/837dfa0f80c31c2903927085c491df.jpg)
5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent

In interface testing, several methods to verify the success of deleting interfaces

【推荐一款实体类转换工具 MapStruct,性能强劲,简单易上手 】

一项听起来大胆,并且非常牛逼的操作——复刻一个 Netflix

Kalman filter_ Recursive Processing

Niuniu looks at the cloud (greedy, hash, push formula) - the first session of Niuke winter vacation training camp

Request&Response

职场“大冤种”,不仅身累,心也被掏空……
随机推荐
Error: the specified LINQ expression contains a reference to a query associated with a different context
Jemter 压力测试 -基础请求-【教学篇】
3,3 '- di (3,4-dicarboxyphenoxy) -4,4' - diphenylethynylbiphenyldianhydride (bpebpda) / porphyrin 2dcofs (H2P COF, ZNP COF and cup COF) supplied by Qiyue
ES字符串类型(Text vs keyword)的选择
js模块化
异地北京办理居住证详细材料
Excel中Unicode如何转换为汉字
Typescript: use polymorphism instead of switch and other conditional statements
Zraqnhydae
蓝桥杯嵌入式学习总结(新版)
In depth analysis of redis object structure
MySQL 'replace into' 的坑 自增id,备机会有问题
卡尔曼滤波器_Recursive Processing
MySQL basic usage 01
QPS
执行npm install -g serve时报错权限权限问题解决方案
Median segmentation (find rules) - Niuke
【推荐一款实体类转换工具 MapStruct,性能强劲,简单易上手 】
Database persistence
数据中心灾难恢复的重要参考指标:RTO和RPO