解決java connection
一、故障現象
環境:CentOS release 6.8 (Final) ,java 1.7 資料庫oracle 11gR2 寫了一個簡單的連線資料庫的JDBC指令碼,連線資料庫,幾十秒後出現connection reset錯誤:
[root@tomcat162 ~]# java -cp /tmp/javaclass/ojdbc14-10.2.0.4.0.jar:/tmp/javaclass/ ConnOracleJdbc
start connection database
java.sql.SQLRecoverableException: IO Error: Connection reset
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnOracleJdbc.testOracle(ConnOracleJdbc.java:30)
at ConnOracleJdbc.main(ConnOracleJdbc.java:12)
出現這個問題有如下幾個特徵:資料庫負載不高,在其他機器的windows中能迅速連線上,在redhat系統中也能迅速連線上。
二、分析問題:在oracle的alert 日誌出現如下錯誤
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.3.0 - Production
Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
Time: 20-SEP-2016 19:25:49
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: TNS:operation timed out
ns secondary err code: 12606
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0
Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=172.16.0.111)(PORT=62302))
WARNING: inbound connection timed out (ORA-3136)
Tue Sep 20 20:23:57 2016
三、進一步分析問題:oracle引數SQLNET.INBOUND_CONNECT_TIMEOUT設定為60秒,可以應付絕大部分情況。這裡情況是在連線時候超出了60秒,所以alert.log列印上面日誌。
四、問題解決:這個問題是java jdk 生成安全隨機數的問題
vim /usr/local/jdk/jre/lib/security/java.security
securerandom.source=file:/dev/urandom
改成:
securerandom.source=file:/dev/./urandom
環境:CentOS release 6.8 (Final) ,java 1.7 資料庫oracle 11gR2 寫了一個簡單的連線資料庫的JDBC指令碼,連線資料庫,幾十秒後出現connection reset錯誤:
[root@tomcat162 ~]# java -cp /tmp/javaclass/ojdbc14-10.2.0.4.0.jar:/tmp/javaclass/ ConnOracleJdbc
start connection database
java.sql.SQLRecoverableException: IO Error: Connection reset
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at ConnOracleJdbc.testOracle(ConnOracleJdbc.java:30)
at ConnOracleJdbc.main(ConnOracleJdbc.java:12)
出現這個問題有如下幾個特徵:資料庫負載不高,在其他機器的windows中能迅速連線上,在redhat系統中也能迅速連線上。
二、分析問題:在oracle的alert 日誌出現如下錯誤
Fatal NI connect error 12170.
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.3.0 - Production
Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.3.0 - Production
Time: 20-SEP-2016 19:25:49
Tracing not turned on.
Tns error struct:
ns main err code: 12535
TNS-12535: TNS:operation timed out
ns secondary err code: 12606
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0
Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=172.16.0.111)(PORT=62302))
WARNING: inbound connection timed out (ORA-3136)
Tue Sep 20 20:23:57 2016
三、進一步分析問題:oracle引數SQLNET.INBOUND_CONNECT_TIMEOUT設定為60秒,可以應付絕大部分情況。這裡情況是在連線時候超出了60秒,所以alert.log列印上面日誌。
四、問題解決:這個問題是java jdk 生成安全隨機數的問題
vim /usr/local/jdk/jre/lib/security/java.security
securerandom.source=file:/dev/urandom
改成:
securerandom.source=file:/dev/./urandom
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30393770/viewspace-2125282/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JMETER java.net.SocketException: Connection reset 報錯解決方案JMeterJavaException
- java.net.ConnectException: Connection refused (Connection refused)JavaException
- 解決 Android studio Connect to 127.0.0.1:[/127.0.0.1] failed: Connection refusedAndroid127.0.0.1AI
- go grpc: connection reset by peer 的一種解決方案GoRPC
- Mysql host is blocked because of many connection errors;unblock解決方法MySqlBloCError
- 解決問題-There appears to be trouble with your network connection. Retrying...APP
- Mysql mysql lost connection to server during query 問題解決方法MySqlServer
- Error establishing a database connection 的解決方法(發現黑客入侵)ErrorDatabase黑客
- 異常解決——GitLab : ssh: connect to host port 22: Connection refusedGitlab
- FileZilla:425 Can't open data connection for transfer of解決辦法
- org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection 解決辦法SpringFrameworkJDBCOTGExceptionAI
- 免密scp解決ssh_exchange_identification:read connection reset by peer 原因IDE
- java.net.ConnectException: Connection refused 異常JavaException
- 解決telnet: connect to address 127.0.0.1: Connection refused的錯誤資訊問題127.0.0.1
- nacos Connection refused (Connection refused)
- android中The connection to adb is down,問題和解決Android
- JAVA | Java 解決跨域問題Java跨域
- Laravel 安裝 sail時ubuntu軟體源很慢或者connection failed 解決辦法LaravelAIUbuntu
- Connection
- Java RMI遇到的Connection refused to Host: 127.x.x.x/192.x.x.x/10.x.x.x問題解決方法Java
- Mysql 錯誤日誌出現大量[Warning] Aborted connection to db user host的解決思路MySql
- Java中處理SocketException: Connection reset”異常的方法JavaException
- java.lang.OutOfMemoryError: Java heap space的解決JavaError
- Java限流及常用解決方案Java
- Java解決跨域問題Java跨域
- java.net.UnknownHostException 解決方法JavaException
- java 遇到NoSuchMethodError通用解決思路JavaError
- Jedis 連線 Redis報JedisConnectionException: java.net.ConnectException: Connection refusedRedisExceptionJava
- 解決Mac終端下載報錯 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refusedMacAIGithub
- 使用putty遠端登入Ubuntu時,報Network error:Connection refused錯誤及解決(記錄)UbuntuError
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error
- 解決java.lang.NoSuchMethodError錯誤JavaError
- Java謎題1:小丑 - 解決方案Java
- java解決數字黑洞問題Java
- JAVA IPMI Command time out 解決方法Java
- java.lang.OutOfMemoryError及解決方案JavaError
- Java定時任務解決方案Java
- wsl docker 安裝frp內網穿透出現error: dial tcp 127.0.0.1:xxxx: connect: connection refused解決方法DockerFRP內網穿透ErrorTCP127.0.0.1
- nmcli connection reload