美文网首页
Druid 监控

Druid 监控

作者: sun_十一 | 来源:发表于2019-07-24 09:57 被阅读0次

1.dubbo服务提供者非web项目

项目启动加上如下参数:
-Djava.net.preferIPv4Stack=true
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote.port=9876
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

2.dubbo消费者web项目

在项目的web.xml中配置监控的过滤器:

<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>

<init-param>
<param-name>jmxUrl</param-name>
<param-value>service:jmx:rmi:///jndi/rmi://127.0.0.1:9876/jmxrmi</param-value>
</init-param>

    <init-param>
        <param-name>loginUsername</param-name>
        <param-value>admin</param-value>
    </init-param>
    <init-param>
        <param-name>loginPassword</param-name>
        <param-value>admin</param-value>
    </init-param>

</servlet>
<servlet-mapping>
    <servlet-name>DruidStatView</servlet-name>
    <url-pattern>/druid/*</url-pattern>
</servlet-mapping>

3.数据源配置加上


<property name="proxyFilters">
<list>
<ref bean="stat-filter" />
</list>
</property>


<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
<property name="mergeSql" value="true" />
<property name="slowSqlMillis" value="500" />
<property name="logSlowSql" value="true" />
</bean>

相关文章

网友评论

      本文标题:Druid 监控

      本文链接:https://www.haomeiwen.com/subject/zuweaftx.html