当前位置:网站首页>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
边栏推荐
- 执行npm install -g serve时报错权限权限问题解决方案
- [recommend 10 easy idea plug-ins with less tedious and repetitive code]
- Multisensor fusion sensing
- C#实现给DevExpress中GridView表格指定列添加进度条显示效果——代码实现方式
- GMP model
- CMDA 3634 image processing
- ES cluster_block_exception read_only_allow_delete问题
- i3wm 获取window class
- Error reported by using two-dimensional array [[]] in thymeleaf: could not parse as expression
- Detailed materials of applying for residence permit in non local Beijing
猜你喜欢

Crosslinked porphyrin based polyimide ppbpi-2, ppbpi-1-cr and ppbpi-2-cr; Porous porphyrin based hyperbranched polyimide (ppbpi-1, ppbpi-2) supplied by Qiyue

i3wm 获取window class

基于sanic的服务使用celery完成动态修改定时任务

一文深入底层分析Redis对象结构

Solution to the problem of multi application routing using thinkphp6.0

Teach you how to use the harmonyos local simulator

Cache usage

Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue

Machine learning - Iris Flower classification

少年,你可知 Kotlin 协程最初的样子?
随机推荐
How to quickly merge multiple PDF files?
MySQL 'replace into' 的坑 自增id,备机会有问题
多传感器融合感知
Shell input validation alphanumeric only
Multisensor fusion sensing
Redis系列——5种常见数据类型day1-3
Jemter stress test - Basic request - [teaching]
职场“大冤种”,不仅身累,心也被掏空……
SQL query statement
Nine hours, nine people and nine doors (01 backpack deformation) - Niuke
Encapsulating ranging and surface class based on leaflet
Shengshi Haotong enterprise wechat sector creates a digital ecological community
Cocoscreator plays spine animation
C implementation adds a progress bar display effect to the specified column of the GridView table in devaxpress - code implementation method
2021 project improvement
Parameter index out of range (0 < 1) (1> number of parameters, which is 0
卡尔曼滤波器_Recursive Processing
Meso tetra (4-bromophenyl) porphyrin (tbpp); 5,10,15,20-tetra (4-methoxy-3-sulfonylphenyl) porphyrin [t (4-mop) ps4] supplied by Qiyue
Crosslinked porphyrin based polyimide ppbpi-2, ppbpi-1-cr and ppbpi-2-cr; Porous porphyrin based hyperbranched polyimide (ppbpi-1, ppbpi-2) supplied by Qiyue
面试被问Redis主从复制不会答?这13张图让你彻底弄明白