{"id":548,"date":"2017-12-27T15:08:46","date_gmt":"2017-12-27T07:08:46","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=548"},"modified":"2017-12-27T15:08:46","modified_gmt":"2017-12-27T07:08:46","slug":"centos7-tomcat-%e5%90%af%e5%8a%a8%e8%bf%87%e7%a8%8b%e5%be%88%e6%85%a2jvm%e4%b8%8a%e7%9a%84%e9%9a%8f%e6%9c%ba%e6%95%b0%e4%b8%8e%e7%86%b5%e6%b1%a0%e7%ad%96%e7%95%a5","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=548","title":{"rendered":"CentOS7 Tomcat \u542f\u52a8\u8fc7\u7a0b\u5f88\u6162,JVM\u4e0a\u7684\u968f\u673a\u6570\u4e0e\u71b5\u6c60\u7b56\u7565"},"content":{"rendered":"<h1>1. CentOS7 Tomcat \u542f\u52a8\u8fc7\u7a0b\u5f88\u6162<\/h1>\n<p>\u5728centos\u542f\u52a8\u5b98\u65b9\u7684tomcat\u65f6\uff0c\u542f\u52a8\u8fc7\u7a0b\u5f88\u6162\uff0c\u9700\u8981\u51e0\u5206\u949f\uff0c\u7ecf\u8fc7\u67e5\u770b\u65e5\u5fd7\uff0c\u53d1\u73b0\u8017\u65f6\u5728\u8fd9\u91cc\uff1a\u662fsession\u5f15\u8d77\u7684\u968f\u673a\u6570\u95ee\u9898\u5bfc\u81f4\u7684\uff1a<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs css has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;14&lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;-Jul-2016&lt;\/span&gt; 04&lt;span class=\"hljs-pseudo\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;:14&lt;\/span&gt;&lt;span class=\"hljs-pseudo\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;:22&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.900&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;INFO&lt;\/span&gt; &lt;span class=\"hljs-attr_selector\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;[localhost-startStop-1]&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;org&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.apache&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.catalina&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.util&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.SessionIdGenerator&lt;\/span&gt;&lt;span class=\"hljs-class\" style=\"box-sizing: border-box; color: rgb(155, 112, 63);\"&gt;.createSecureRandom&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;Creation&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;of&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;SecureRa&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;ndom&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;instance&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;for&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;session&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;ID&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;generation&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;using&lt;\/span&gt; &lt;span class=\"hljs-attr_selector\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;[SHA1PRNG]&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;took&lt;\/span&gt; &lt;span class=\"hljs-attr_selector\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;[142,673]&lt;\/span&gt; &lt;span class=\"hljs-tag\" style=\"color: rgb(0, 0, 0); box-sizing: border-box;\"&gt;milliseconds&lt;\/span&gt;.&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<h1><a name=\"t1\"><\/a><a target=\"_blank\" name=\"t1\" rel=\"noopener\"><\/a>2. JVM\u4e0a\u7684\u968f\u673a\u6570\u4e0e\u71b5\u6c60\u7b56\u7565<\/h1>\n<p>\u5728apache-tomcat\u5b98\u65b9\u6587\u6863\uff1a<a href=\"http:\/\/wiki.apache.org\/tomcat\/HowTo\/FasterStartUp\" target=\"_blank\" rel=\"noopener\">\u5982\u4f55\u8ba9tomcat\u542f\u52a8\u66f4\u5feb<\/a>\u91cc\u9762\u63d0\u5230\u4e86\u4e00\u4e9b\u542f\u52a8\u65f6\u7684\u4f18\u5316\u9879\uff0c\u5176\u4e2d\u4e00\u9879\u662f\u5173\u4e8e\u968f\u673a\u6570\u751f\u6210\u65f6\uff0c\u91c7\u7528\u7684\u201c\u71b5\u6e90\u201d(entropy source)\u7684\u7b56\u7565\u3002<\/p>\n<p>\u4ed6\u63d0\u5230tomcat7\u7684session id\u7684\u751f\u6210\u4e3b\u8981\u901a\u8fc7<a class=\"replace_word\" title=\"Java EE\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/javaee\" target=\"_blank\" rel=\"noopener\">Java<\/a>.security.SecureRandom\u751f\u6210\u968f\u673a\u6570\u6765\u5b9e\u73b0\uff0c\u968f\u673a\u6570<a class=\"replace_word\" title=\"\u7b97\u6cd5\u4e0e\u6570\u636e\u7ed3\u6784\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/datastructure\" target=\"_blank\" rel=\"noopener\">\u7b97\u6cd5<\/a>\u4f7f\u7528\u7684\u662f\u201dSHA1PRNG\u201d<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs cs has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;&lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;private&lt;\/span&gt; String secureRandomAlgorithm = &lt;span class=\"hljs-string\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;\"SHA1PRNG\"&lt;\/span&gt;;&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<p>\u5728sun\/<a class=\"replace_word\" title=\"Oracle\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/oracle\" target=\"_blank\" rel=\"noopener\">Oracle<\/a>\u7684jdk\u91cc\uff0c\u8fd9\u4e2a\u7b97\u6cd5\u7684\u63d0\u4f9b\u8005\u5728\u5e95\u5c42\u4f9d\u8d56\u5230<a class=\"replace_word\" title=\"\u64cd\u4f5c\u7cfb\u7edf\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/operatingsystem\" target=\"_blank\" rel=\"noopener\">\u64cd\u4f5c\u7cfb\u7edf<\/a>\u63d0\u4f9b\u7684\u968f\u673a\u6570\u636e\uff0c\u5728<a class=\"replace_word\" title=\"Linux\u77e5\u8bc6\u5e93\" href=\"http:\/\/lib.csdn.net\/base\/linux\" target=\"_blank\" rel=\"noopener\">Linux<\/a>\u4e0a\uff0c\u4e0e\u4e4b\u76f8\u5173\u7684\u662f\/dev\/random\u548c\/dev\/urandom\uff0c\u5bf9\u4e8e\u8fd9\u4e24\u4e2a\u8bbe\u5907\u5757\u7684\u63cf\u8ff0\u4ee5\u524d\u4e5f\u89c1\u8fc7\u8ba8\u8bba\u968f\u673a\u6570\u7684\u6587\u7ae0\uff0cwiki\u4e2d\u6709\u6bd4\u8f83\u8be6\u7ec6\u7684\u63cf\u8ff0\uff0c\u6458\u6284\u8fc7\u6765\uff0c\u5148\u770b\/dev\/random \uff1a<\/p>\n<blockquote><p>\u5728\u8bfb\u53d6\u65f6\uff0c\/dev\/random\u8bbe\u5907\u4f1a\u8fd4\u56de\u5c0f\u4e8e\u71b5\u6c60\u566a\u58f0\u603b\u6570\u7684\u968f\u673a\u5b57\u8282\u3002\/dev\/random\u53ef\u751f\u6210\u9ad8\u968f\u673a\u6027\u7684\u516c\u94a5\u6216\u4e00\u6b21\u6027\u5bc6\u7801\u672c\u3002\u82e5\u71b5\u6c60\u7a7a\u4e86\uff0c\u5bf9\/dev\/random\u7684\u8bfb\u64cd\u4f5c\u5c06\u4f1a\u88ab\u963b\u585e\uff0c\u76f4\u5230\u6536\u96c6\u5230\u4e86\u8db3\u591f\u7684\u73af\u5883\u566a\u58f0\u4e3a\u6b62<\/p><\/blockquote>\n<p>\u800c \/dev\/urandom \u5219\u662f\u4e00\u4e2a\u975e\u963b\u585e\u7684\u53d1\u751f\u5668:<\/p>\n<blockquote><p>dev\/random\u7684\u4e00\u4e2a\u526f\u672c\u662f\/dev\/urandom \uff08\u201dunlocked\u201d\uff0c\u975e\u963b\u585e\u7684\u968f\u673a\u6570\u53d1\u751f\u5668\uff09\uff0c\u5b83\u4f1a\u91cd\u590d\u4f7f\u7528\u71b5\u6c60\u4e2d\u7684\u6570\u636e\u4ee5\u4ea7\u751f\u4f2a\u968f\u673a\u6570\u636e\u3002\u8fd9\u8868\u793a\u5bf9\/dev\/urandom\u7684\u8bfb\u53d6\u64cd\u4f5c\u4e0d\u4f1a\u4ea7\u751f\u963b\u585e\uff0c\u4f46\u5176\u8f93\u51fa\u7684\u71b5\u53ef\u80fd\u5c0f\u4e8e\/dev\/random\u7684\u3002\u5b83\u53ef\u4ee5\u4f5c\u4e3a\u751f\u6210\u8f83\u4f4e\u5f3a\u5ea6\u5bc6\u7801\u7684\u4f2a\u968f\u673a\u6570\u751f\u6210\u5668\uff0c\u4e0d\u5efa\u8bae\u7528\u4e8e\u751f\u6210\u9ad8\u5f3a\u5ea6\u957f\u671f\u5bc6\u7801\u3002<br \/>\n\u53e6\u5916wiki\u91cc\u4e5f\u63d0\u5230\u4e86\u4e3a\u4ec0\u4e48linux\u5185\u6838\u91cc\u7684\u968f\u673a\u6570\u751f\u6210\u5668\u91c7\u7528SHA1\u6563\u5217\u7b97\u6cd5\u800c\u975e\u52a0\u5bc6\u7b97\u6cd5\uff0c\u662f\u4e3a\u4e86\u907f\u5f00\u6cd5\u5f8b\u98ce\u9669(\u5bc6\u7801\u51fa\u53e3\u9650\u5236)\u3002<\/p><\/blockquote>\n<p>\u56de\u5230tomcat\u6587\u6863\u91cc\u7684\u5efa\u8bae\uff0c\u91c7\u7528\u975e\u963b\u585e\u7684\u71b5\u6e90(entropy source)\uff0c\u901a\u8fc7java\u7cfb\u7edf\u5c5e\u6027\u6765\u8bbe\u7f6e\uff1a<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs avrasm has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;-Djava&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.security&lt;\/span&gt;&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.egd&lt;\/span&gt;=file:\/dev\/.\/urandom&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<p>catalina.sh<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs lua has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;&lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;if&lt;\/span&gt; &lt;span class=\"hljs-string\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;[[ \"$JAVA_OPTS\" != *-Djava.security.egd=* ]]&lt;\/span&gt;; &lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;then&lt;\/span&gt; JAVA_OPTS=&lt;span class=\"hljs-string\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;\"$JAVA_OPTS -Djava.security.egd=file:\/dev\/.\/urandom\"&lt;\/span&gt; fi&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<p>\u8fd9\u4e2a\u7cfb\u7edf\u5c5e\u6027egd\u8868\u793a\u71b5\u6536\u96c6\u5b88\u62a4\u8fdb\u7a0b(entropy gathering daemon)\uff0c\u4f46\u8fd9\u91cc\u503c\u4e3a\u4f55\u8981\u5728dev\u548crandom\u4e4b\u95f4\u52a0\u4e00\u4e2a\u70b9\u5462\uff1f\u662f\u56e0\u4e3a\u4e00\u4e2a<a href=\"http:\/\/bugs.java.com\/bugdatabase\/view_bug.do?bug_id=6202721\" target=\"_blank\" rel=\"noopener\">jdk\u7684bug<\/a>\uff0c\u5728\u8fd9\u4e2abug\u7684\u8fde\u63a5\u91cc\u6709\u4eba\u53cd\u9988\u53ca\u65f6\u5bf9 securerandom.source \u8bbe\u7f6e\u4e3a \/dev\/urandom \u5b83\u4e5f\u4ecd\u7136\u4f7f\u7528\u7684 \/dev\/random\uff0c\u6709\u4eba\u63d0\u4f9b\u4e86\u53d8\u901a\u7684\u89e3\u51b3\u65b9\u6cd5\uff0c\u5176\u4e2d\u4e00\u4e2a\u53d8\u901a\u7684\u505a\u6cd5\u662f\u5bf9securerandom.source\u8bbe\u7f6e\u4e3a \/dev\/.\/urandom \u624d\u884c\u3002\u4e5f\u6709\u4eba\u8bc4\u8bba\u8bf4\u8fd9\u4e2a\u4e0d\u662fbug\uff0c\u662f\u6709\u610f\u4e3a\u4e4b\u3002<\/p>\n<p>\u6211\u770b\u4e86\u4e00\u4e0b\u6211\u5f53\u524d\u6240\u7528\u7684jdk7\u7684java.security\u6587\u4ef6\u91cc\uff0c\u914d\u7f6e\u91cc\u4ecd\u4f7f\u7528\u7684\u662f\/dev\/urandom\uff1a<\/p>\n<blockquote><p># Select the source of seed data for SecureRandom. By default an<br \/>\n# attempt is made to use the entropy gathering device specified by<br \/>\n# the securerandom.source property. If an exception occurs when<br \/>\n# accessing the URL then the traditional system\/thread activity<br \/>\n# algorithm is used.<br \/>\n#<br \/>\n# On Solaris and Linux systems, if file:\/dev\/urandom is specified and it<br \/>\n# exists, a special SecureRandom implementation is activated by default.<br \/>\n# This \u201cNativePRNG\u201d reads random bytes directly from \/dev\/urandom.<br \/>\n#<br \/>\n# On Windows systems, the URLs file:\/dev\/random and file:\/dev\/urandom<br \/>\n# enables use of the Microsoft CryptoAPI seed functionality.<br \/>\n#<br \/>\nsecurerandom.source=file:\/dev\/urandom<\/p><\/blockquote>\n<p>\u6211\u4e0d\u786e\u5b9ajdk7\u91cc\uff0c\u8fd9\u4e2a \/dev\/urandom \u4e5f\u540c\u90a3\u4e2abug\u62a5\u544a\u91cc\u6240\u8bf4\u7684\u7b49\u540c\u4e8e \/dev\/random\uff1b\u8981\u4f7f\u7528\u975e\u963b\u585e\u7684\u71b5\u6c60\uff0c\u8fd9\u91cc\u8fd8\u662f\u8981\u4fee\u6539\u4e3a\/dev\/.\/urandom \u5462\uff0c\u8fd8\u662fjdk7\u5df2\u7ecf\u4fee\u590d\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u540c\u6ce8\u91ca\u91cc\u7684\u610f\u601d\uff0c\u53ea\u597d\u9a8c\u8bc1\u4e00\u4e0b\u3002<\/p>\n<p>\u4f7f\u7528bug\u62a5\u544a\u91cc\u7ed9\u51fa\u7684\u4ee3\u7801\uff1a<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs java has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;&lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;import&lt;\/span&gt; java.security.SecureRandom; class JRand { &lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;public&lt;\/span&gt; &lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;static&lt;\/span&gt; &lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;void&lt;\/span&gt; &lt;span class=\"hljs-title\" style=\"box-sizing: border-box;\"&gt;main&lt;\/span&gt;(String args[]) &lt;span class=\"hljs-keyword\" style=\"color: rgb(0, 0, 136); box-sizing: border-box;\"&gt;throws&lt;\/span&gt; Exception { System.out.println(&lt;span class=\"hljs-string\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;\"Ok: \"&lt;\/span&gt; + SecureRandom.getInstance(&lt;span class=\"hljs-string\" style=\"color: rgb(0, 136, 0); box-sizing: border-box;\"&gt;\"SHA1PRNG\"&lt;\/span&gt;).nextLong()); } }&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;4&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;5&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;6&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;7&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;4&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;5&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;6&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;7&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<p>\u7136\u540e\u8bbe\u7f6e\u4e0d\u540c\u7684\u7cfb\u7edf\u5c5e\u6027\u6765\u9a8c\u8bc1\uff0c\u5148\u662f\u5728\u6211\u7684mac\u4e0a\uff1a<\/p>\n<pre class=\"prettyprint\">&lt;code class=\"hljs avrasm has-numbering\" style=\"display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;\"&gt;% time java -Djava&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.security&lt;\/span&gt;&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.egd&lt;\/span&gt;=file:\/dev\/urandom JRand &lt;span class=\"hljs-label\" style=\"box-sizing: border-box;\"&gt;Ok:&lt;\/span&gt; &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;8609191756834777000&lt;\/span&gt; java -Djava&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.security&lt;\/span&gt;&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.egd&lt;\/span&gt;=file:\/dev\/urandom JRand &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.11&lt;\/span&gt;s user &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.03&lt;\/span&gt;s system &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;115&lt;\/span&gt;% cpu &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.117&lt;\/span&gt; total % time java -Djava&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.security&lt;\/span&gt;&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.egd&lt;\/span&gt;=file:\/dev\/.\/urandom JRand &lt;span class=\"hljs-label\" style=\"box-sizing: border-box;\"&gt;Ok:&lt;\/span&gt; -&lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;3573266464480299009&lt;\/span&gt; java -Djava&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.security&lt;\/span&gt;&lt;span class=\"hljs-preprocessor\" style=\"color: rgb(68, 68, 68); box-sizing: border-box;\"&gt;.egd&lt;\/span&gt;=file:\/dev\/.\/urandom JRand &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.11&lt;\/span&gt;s user &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.03&lt;\/span&gt;s system &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;116&lt;\/span&gt;% cpu &lt;span class=\"hljs-number\" style=\"color: rgb(0, 102, 102); box-sizing: border-box;\"&gt;0.116&lt;\/span&gt; total&lt;\/code&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;4&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;5&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;6&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;7&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;8&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;9&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;10&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;11&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;12&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;13&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;14&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;15&lt;\/li&gt;&lt;\/ul&gt;&lt;ul class=\"pre-numbering\" style=\"box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);\"&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;1&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;2&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;3&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;4&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;5&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;6&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;7&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;8&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;9&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;10&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;11&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;12&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;13&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;14&lt;\/li&gt;&lt;li style=\"box-sizing: border-box; padding: 0px 5px;\"&gt;15&lt;\/li&gt;&lt;\/ul&gt;<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\/dev\/urandom\u548c \/dev\/.\/urandom \u7684\u6267\u884c\u65f6\u95f4\u5dee\u4e0d\u591a\uff0c\u6709\u70b9\u7eb3\u95f7\uff0c\u518d\u4ed4\u7ec6\u770b\u4e00\u4e0bwiki\u91cc\u8bf4\u7684\uff1a<\/p>\n<blockquote><p>FreeBSD\u64cd\u4f5c\u7cfb\u7edf\u5b9e\u73b0\u4e86256\u4f4d\u7684Yarrow\u7b97\u6cd5\u53d8\u4f53\uff0c\u4ee5\u63d0\u4f9b\u4f2a\u968f\u673a\u6570\u6d41\u3002\u4e0eLinux\u7684\/dev\/random\u4e0d\u540c\uff0cFreeBSD\u7684\/dev\/random\u4e0d\u4f1a\u4ea7\u751f\u963b\u585e\uff0c\u4e0eLinux\u7684\/dev\/urandom\u76f8\u4f3c\uff0c\u63d0\u4f9b\u4e86\u5bc6\u7801\u5b66\u5b89\u5168\u7684\u4f2a\u968f\u673a\u6570\u53d1\u751f\u5668\uff0c\u800c\u4e0d\u662f\u57fa\u4e8e\u71b5\u6c60\u3002\u800cFreeBSD\u7684\/dev\/urandom\u5219\u53ea\u662f\u7b80\u5355\u7684\u94fe\u63a5\u5230\u4e86\/dev\/random\u3002<br \/>\n\u5c3d\u7ba1\u5728\u6211\u7684mac\u4e0a\/dev\/urandom\u5e76\u4e0d\u662f\/dev\/random\u7684\u94fe\u63a5\uff0c\u4f46mac\u4e0ebsd\u5185\u6838\u5e94\u8be5\u662f\u76f8\u8fd1\u7684\uff0c\/dev\/random\u4e5f\u662f\u975e\u963b\u585e\u7684\uff0c\/dev\/urandom\u662f\u7528\u6765\u517c\u5bb9linux\u7cfb\u7edf\u7684\uff0c\u8fd9\u4e24\u4e2a\u968f\u673a\u6570\u751f\u6210\u5668\u7684\u884c\u4e3a\u662f\u4e00\u81f4\u7684\u3002<a href=\"https:\/\/developer.apple.com\/library\/mac\/documentation\/Darwin\/Reference\/ManPages\/man4\/random.4.html\" target=\"_blank\" rel=\"noopener\">\u53c2\u8003\u8fd9\u91cc<\/a>\u3002<\/p><\/blockquote>\n<p>\u7136\u540e\u518d\u5230\u4e00\u53f0ubuntu\u7cfb\u7edf\u4e0a\u6d4b\u8bd5\uff1a<\/p>\n<p>% time java -Djava.security.egd=file:\/dev\/urandom JRand<br \/>\nOk: 6677107889555365492<br \/>\njava -Djava.security.egd=file:\/dev\/urandom JRand<br \/>\n0.14s user 0.02s system 9% cpu 1.661 total<\/p>\n<p>% time java -Djava.security.egd=file:\/dev\/.\/urandom JRand<br \/>\nOk: 5008413661952823775<br \/>\njava -Djava.security.egd=file:\/dev\/.\/urandom JRand<br \/>\n0.12s user 0.02s system 99% cpu 0.145 total<br \/>\n\u8fd9\u56de\u5dee\u5f02\u5c31\u5b8c\u5168\u4f53\u73b0\u51fa\u6765\u4e86\uff0c\u963b\u585e\u6a21\u5f0f\u7684\u71b5\u6c60\u8017\u65f6\u7528\u4e861.6\u79d2\uff0c\u800c\u975e\u963b\u585e\u6a21\u5f0f\u5219\u53ea\u7528\u4e860.14\u79d2\uff0c\u5dee\u4e86\u4e00\u4e2a\u6570\u91cf\u7ea7\uff0c\u5f53\u7136\u4ee3\u4ef7\u662f\u8f6c\u6362\u4e3a\u5bf9cpu\u7684\u5f00\u9500\u4e86\u3002<\/p>\n<p>\/\/ \u8865\u5145\uff0c\u8fde\u7eed\u5728ubuntu\u4e0a\u6d4b\u8bd5\u51e0\u6b21\/dev\/random\u65b9\u5f0f\u4e4b\u540e\uff0c\u5bfc\u81f4\u71b5\u6c60\u88ab\u7528\u7a7a\uff0c\u88ab\u963b\u585e\u4e8660\u79d2\u5de6\u53f3\u3002\u5e94\u7528\u670d\u52a1\u5668\u7aef\u8981\u907f\u514d\u8fd9\u79cd\u65b9\u5f0f\u3002<\/p>\n<p>\u672c\u6761\u76ee\u53d1\u5e03\u4e8e2014-06-25\u3002\u5c5e\u4e8ejava\u3001programming\u5206\u7c7b\uff0c\u88ab\u8d34\u4e86 freebsd\u3001java\u3001linux\u3001mac\u3001os\u3001random\u3001tomcat \u6807\u7b7e\u3002<\/p>\n<p>\u539f\u6587\uff1a\u00a0<a href=\"http:\/\/hongjiang.info\/jvm-random-and-entropy-source\/\" target=\"_blank\" rel=\"noopener\">http:\/\/hongjiang.info\/jvm-random-and-entropy-source\/<\/a><\/p>\n<p>\u8865\u5145\uff1a\u672c\u4eba\u5728Centos7.2\u4e0b\u642d\u5efa\u7684tomcat8,\u542f\u52a8\u5f88\u6162\uff0c\u662f\u4e0a\u8ff0\u539f\u56e0\u5bfc\u81f4\uff0c\u4f46\u91c7\u7528\u4e0a\u8ff0\u7b56\u7565\u6ca1\u6709\u89e3\u51b3tomcat\u542f\u52a8\u6162\u7684\u95ee\u9898\uff0c<\/p>\n<p>\u56e0\u4e3acatalina.sh\u6dfb\u52a0\u76f8\u5e94\u4ee3\u7801\u540e\u63d0\u793a\u627e\u4e0d\u5230-Djava.security.egd=file:\/dev\/.\/urandom<\/p>\n<p>\u540e\u6765\u76f4\u63a5\u914d\u7f6ejdk\u00a0securerandom.source\u4e3aurandom\u89e3\u51b3\uff1a<\/p>\n<p>\u6253\u5f00$JAVA_PATH\/jre\/lib\/security\/java.security\u8fd9\u4e2a\u6587\u4ef6\uff0c\u627e\u5230securerandom.source\u914d\u7f6e\u9879<\/p>\n<p>\u4fee\u6539\u4e3a\uff1a<\/p>\n<pre><code>securerandom.source=file:\/dev\/.\/urandom<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. CentOS7 Tomcat \u542f\u52a8\u8fc7\u7a0b\u5f88\u6162 \u5728centos\u542f\u52a8\u5b98\u65b9\u7684tomcat\u65f6\uff0c\u542f\u52a8\u8fc7\u7a0b\u5f88\u6162\uff0c\u9700\u8981\u51e0\u5206\u949f\uff0c\u7ecf\u8fc7\u67e5\u770b\u65e5\u5fd7\uff0c\u53d1\u73b0\u8017\u65f6\u5728\u8fd9\u91cc\uff1a\u662fsession\u5f15\u8d77\u7684\u968f\u673a\u6570\u95ee\u9898\u5bfc\u81f4\u7684\uff1a &lt;code class=&#8221;hljs css has-numbering&#8221; style=&#8221;display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: &#8216;Source Code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-548","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=548"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/548\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}