text: (window.webpackJsonp=window.webpackJsonp||[]).push([[40],{411:function(t,s,a){"use strict";a.r(s);var n=a(12),e=Object(n.a)({},(function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"常用配置"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#常用配置"}},[t._v("#")]),t._v(" 常用配置")]),t._v(" "),a("p",[t._v("常用配置")]),t._v(" "),a("h2",{attrs:{id:"software-collections"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#software-collections"}},[t._v("#")]),t._v(" software collections")]),t._v(" "),a("p",[t._v("devtools-7 "),a("a",{attrs:{href:"https://www.softwarecollections.org",target:"_blank",rel:"noopener noreferrer"}},[t._v("网站"),a("OutboundLink")],1)]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 1. Install a package with repository for your system:")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# On CentOS, install package centos-release-scl available in CentOS repository:")]),t._v("\n$ "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" yum "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" centos-release-scl\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# On RHEL, enable RHSCL repository for you system:")]),t._v("\n$ "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" yum-config-manager --enable rhel-server-rhscl-7-rpms\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 2. Install the collection:")]),t._v("\n$ "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("sudo")]),t._v(" yum "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("install")]),t._v(" devtoolset-7\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 3. Start using software collections:")]),t._v("\n$ scl "),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("enable")]),t._v(" devtoolset-7 "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("bash")]),t._v("\n")])])]),a("h2",{attrs:{id:"sudo"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#sudo"}},[t._v("#")]),t._v(" sudo")]),t._v(" "),a("blockquote",[a("p",[t._v("免输密码 /etc/sudoers.d/sudoers battery ALL=(ALL) NOPASSWD : ALL")])]),t._v(" "),a("h2",{attrs:{id:"自签名证书"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#自签名证书"}},[t._v("#")]),t._v(" 自签名证书")]),t._v(" "),a("blockquote",[a("p",[a("a",{attrs:{href:"https://www.cnblogs.com/hnxxcxg/p/7610582.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("原文"),a("OutboundLink")],1)])]),t._v(" "),a("p",[t._v("X.509 证书包含三个文件：key，csr，crt")]),t._v(" "),a("ul",[a("li",[t._v("key 是服务器上的私钥文件，用于对发送给客户端数据的加密，以及对从客户端接收到数据的解密")]),t._v(" "),a("li",[t._v("csr 是证书签名请求文件，用于提交给证书颁发机构（CA）对证书签名")]),t._v(" "),a("li",[t._v("crt 是由证书颁发机构（CA）签名后的证书，或者是开发者自签名的证书，包含证书持有人的信息，持有人的公钥，以及签署者的签名等信息")])]),t._v(" "),a("blockquote",[a("p",[t._v("备注：在密码学中，X.509 是一个标准，规范了公开秘钥认证、证书吊销列表、授权凭证、凭证路径验证算法等")])]),t._v(" "),a("h3",{attrs:{id:"生成私钥"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#生成私钥"}},[t._v("#")]),t._v(" 生成私钥")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v(" openssl genrsa -des3 -out private.key "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2048")]),t._v("\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# des|-des3|-idea")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 默认1024位 最好2048以上")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#-des            encrypt the generated key with DES in cbc mode")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -idea           encrypt the generated key with IDEA in cbc mode")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -seed")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#                 encrypt PEM output with cbc seed")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -aes128, -aes192, -aes256")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#                 encrypt PEM output with cbc aes")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -camellia128, -camellia192, -camellia256")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#                 encrypt PEM output with cbc camellia")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -out file       output the key to 'file")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -passout arg    output file pass phrase source")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -f4             use F4 (0x10001) for the E value")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -3              use 3 for the E value")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -engine e       use engine e, possibly a hardware device.")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -rand file:file:...")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#                 load the file (or the files in the directory) into")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#                 the random number generator")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n")])])]),a("h3",{attrs:{id:"生成-csr-证书签名请求"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#生成-csr-证书签名请求"}},[t._v("#")]),t._v(" 生成 CSR（证书签名请求）")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v(" openssl req -new -key private.key -out server.csr -config openssl.cfg\n "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# config默认--/etc/ssl/openssl.cnf")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#  [new/x509]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 当使用-new选取的时候，说明是要生成证书请求，当使用x509选项的时候，说明是要生成自签名证书")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# [/key/newkey/keyout]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# key和newkey是互斥的，key是指定已有的密钥文件，而newkey是指在生成证书请求或者自签名证书的时候自动生成密钥，然后生成的密钥名称有keyout参数指定。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 当指定newkey选项时，后面指定rsa:bits说明产生rsa密钥，位数由bits指定。指定dsa:file说明产生dsa密钥，file是指生成dsa密钥的参数文件(由dsaparam生成)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# [in/out/inform/outform/keyform]")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# in选项指定证书请求文件，当查看证书请求内容或者生成自签名证书的时候使用")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# out选项指定证书请求或者自签名证书文件名，或者公钥文件名(当使用pubkey选项时用到)，以及其他一些输出信息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# inform、outform、keyform分别指定了in、out、key选项指定的文件格式，默认是PEM格式。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -batch 从配置文件读取主体信息，或者配合-subj来指定主体信息")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -nodes 秘钥文件不用口令加密")]),t._v("\n")])])]),a("h3",{attrs:{id:"删除私钥中的密码"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#删除私钥中的密码"}},[t._v("#")]),t._v(" 删除私钥中的密码")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v("openssl rsa -in private.key -out private.key\n")])])]),a("h3",{attrs:{id:"生成自签名证书-rootca"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#生成自签名证书-rootca"}},[t._v("#")]),t._v(" 生成自签名证书(RootCA)")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v("openssl req -x509 -days "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3650")]),t._v(" -in server.csr -key private.key -out server.crt\n")])])]),a("h3",{attrs:{id:"生成证书链"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#生成证书链"}},[t._v("#")]),t._v(" 生成证书链")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("rm")]),t._v(" -rf /etc/pki/CA/*.old\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("touch")]),t._v(" /etc/pki/CA/index.txt\n\n"),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("touch")]),t._v(" /etc/pki/CA/index.txt.attr\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"unique_subject = no"')]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" index.txt.attr\n\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" 01 "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /etc/pki/CA/serial\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("echo")]),t._v(" 02 "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" /etc/pki/CA/serial\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 二级证书 chain")]),t._v("\nopenssl ca -extensions v3_ca -in server.csr -days "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3650")]),t._v(" -out chain.crt -cert server.crt -keyfile private.key\n\n")])])]),a("h2",{attrs:{id:"openssl-对称加密"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#openssl-对称加密"}},[t._v("#")]),t._v(" openssl 对称加密")]),t._v(" "),a("blockquote",[a("p",[t._v("基于 key iv salt 的加密解密")])]),t._v(" "),a("h2",{attrs:{id:"openssl-非对称加密解密"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#openssl-非对称加密解密"}},[t._v("#")]),t._v(" openssl 非对称加密解密")]),t._v(" "),a("blockquote",[a("p",[t._v("密钥对,公钥加密/私钥解密 私钥签名/公钥验证")])]),t._v(" "),a("ul",[a("li",[t._v("生成私钥: openssl genrsa .....")]),t._v(" "),a("li",[t._v("提取公钥: openssl rsa -in rsa_private_key.pem -pubout -out rsa_public_key.pem")])]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#公钥加密")]),t._v("\nopenssl rsautl -encrypt -in readme.txt -inkey rsa_public_key.pem -pubin -out hello.en\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#私钥解密")]),t._v("\nopenssl rsautl -decrypt -in hello.en -inkey rsa_private_key.pem -out hello.de\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -in file        input file")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -out file       output file")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -inkey file     input key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -keyform arg    private key format - default PEM")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -pubin          input is an RSA public")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -certin         input is a certificate carrying an RSA public key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -ssl            use SSL v2 padding")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -raw            use no padding")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -pkcs           use PKCS#1 v1.5 padding (default)")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -oaep           use PKCS#1 OAEP")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -sign           sign with private key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -verify         verify with public key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -encrypt        encrypt with public key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -decrypt        decrypt with private key")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -hexdump        hex dump output")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -engine e       use engine e, possibly a hardware device.")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -passin arg    pass phrase source")]),t._v("\n")])])]),a("h3",{attrs:{id:"smime"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#smime"}},[t._v("#")]),t._v(" smime")]),t._v(" "),a("blockquote",[a("p",[t._v("主要用于邮件协议")])]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 签名")]),t._v("\nopenssl smime -sign -in company.mobileconfig -out signed.mobileconfig -signer server.crt -inkey server.key -certfile cert-chain.crt -outform der -nodetach\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# 验证")]),t._v("\nopenssl smime -verify -in signed.mobileconfig -inform der -certfile chain.crt -CAfile server.crt\n\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -encrypt：用给定的接受者的证书加密邮件信息。输入文件是一个消息值，用于加密。输出文件是一个已经被加密了的MIME格式的邮件信息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -decrypt：用提供的证书和私钥值来解密邮件信息值。从输入文件中获取到已经加密了的MIME格式的邮件信息值。解密的邮件信息值被保存到输出文件中。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -sign：用提供的证书和私钥值来签名邮件信息值。输入文件是一个消息值，用于签名。输出文件是一个已经被签名了的MIME格式的邮件信息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -verify：验证已经签名了的邮件信息值。输入文件和输出文件都是已经签名了的邮件信息值。同时支持清除文本以及不透明的签名。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -pk7out：将一个PEM格式的输入信息转换为PKCS#7结构。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -nointern：对签名者来说，不从消息中查找证书。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -nosigs：不去验证签名值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -noverify：不去验证签名者的证书信息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -nocerts：当签名的时候不包含签名者的证书信息值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -nodetach：用不透明的签名。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -binary：不转换二进制消息到文本消息值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -in file：输入消息值，它一般为加密了的以及签名了的MINME类型的消息值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -inform SMIME|PEM|DER：输入消息的格式。一般为SMIME|PEM|DER三种。默认的是SMIME。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -certfile filename：添加filename中所有的证书信息值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -signer file：一个签名证书，当签名或放弃一个签名数据时使用。这个选项可以被用多次。如果一个消息已经被验证并验证通过，则将签名者的证书放到file中。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -recip file：存放提供者的证书，主要用于解密消息值。这个证书必须匹配多个提供者的消息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -passin arg：私钥保护口令来源。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -inkey file：私钥存放地址，主要用于签名或解密数据。这个私钥值必须匹配相应的证书信息。如果这个选项没有被指定，私钥必须包含到证书路径中（-recip、-signer）。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -keyform PEM |ENGINE：私钥格式。一般为PEM 、ENGINE格式。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -out file：已经被解密或验证通过的数据的保存位置。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -outform SMIME|PEM|DER：输出格式。一般为SMIME、PEM、DER三种。默认的格式是SMIME。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -content file：包含分离的上下文路径，它仅仅只能用于verify操作。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -to addr：有关的邮件信息值头部。接收的地址。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -from ad：有关的邮件信息值头部。发送的地址。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -subject s：颁发者信息值。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -text：打印出S/MIME邮件的各个部件。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -CApath directory：设置信任CA文件所在路径，此路径中的ca文件名采用特殊的形式：xxx.0，其中xxx为CA证书持有者的哈希值，它通过x509 -hash命令获得。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -CAfile filename：某文件，里面是所有你信任的CA的证书的内容。当你要建立client的证书链的时候也需要用到这个文件。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -crl_check、-crl_check_all：检查客户端的证书是否在CA的废除列表中。CRL（s）在证书文件中。crl_check_all表示要检查所有的CA证书中的废除列表。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -indef、-stream：这两个选项对I/O流进行编码操作。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -noindef：不对数据进行编码操作。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -md digest：当签名或放弃签名操作时用的摘要算法。默认的摘要算法为sha1。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -rand file(s)：指定随机数种子文件，多个文件间用分隔符分开，windows用“;”，OpenVMS用“,“，其他系统用“：”。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# cert.pem：提供者的证书信息。")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("#")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("# -des, -des3, -seed, -rc2-40, -rc2-64, -rc2-128, -aes128, -aes192, -aes256，-camellia128, -camellia192, -camellia256：指定的私钥保护加密算法。默认的算法是rc2-40")]),t._v("\n\n\n")])])]),a("h2",{attrs:{id:"p12-格式"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#p12-格式"}},[t._v("#")]),t._v(" p12 格式")]),t._v(" "),a("div",{staticClass:"language- extra-class"},[a("pre",{pre:!0,attrs:{class:"language-text"}},[a("code",[t._v("openssl genrsa -out ios.key 2048\nopenssl req -new -sha256 -key ios.key -out ios.csr\n\nopenssl x509 -in ios_development.cer -inform DER -outform PEM -out ios_distribution.pem\nopenssl pkcs12 -export -inkey ios.key -in ios_distribution.pem -out ios_distribution.p12\n")])])]),a("h2",{attrs:{id:"docker"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#docker"}},[t._v("#")]),t._v(" Docker")]),t._v(" "),a("p",[t._v("修改 docker 时区")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token function"}},[t._v("cp")]),t._v(" /usr/share/zoneinfo/Asia/Shanghai /etc/localtime\n")])])]),a("h2",{attrs:{id:"snowflake"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#snowflake"}},[t._v("#")]),t._v(" SnowFlake")]),t._v(" "),a("p",[t._v("摘自: "),a("a",{attrs:{href:"https://www.cnblogs.com/relucent/p/4955340.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("cnblogs"),a("OutboundLink")],1)]),t._v(" "),a("p",[t._v("分布式场景下 (workerId, datacenterId)保证唯一")]),t._v(" "),a("div",{staticClass:"language-java extra-class"},[a("pre",{pre:!0,attrs:{class:"language-java"}},[a("code",[a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/**\n * Twitter_Snowflake<br>\n * SnowFlake的结构如下(每部分用-分开):<br>\n * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>\n * 1位标识，由于long基本类型在Java中是带符号的，最高位是符号位，正数是0，负数是1，所以id一般是正数，最高位是0<br>\n * 41位时间截(毫秒级)，注意，41位时间截不是存储当前时间的时间截，而是存储时间截的差值（当前时间截 - 开始时间截)\n * 得到的值），这里的的开始时间截，一般是我们的id生成器开始使用的时间，由我们程序来指定的（如下下面程序IdWorker类的startTime属性）。41位的时间截，可以使用69年，年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>\n * 10位的数据机器位，可以部署在1024个节点，包括5位datacenterId和5位workerId<br>\n * 12位序列，毫秒内的计数，12位的计数顺序号支持每个节点每毫秒(同一机器，同一时间截)产生4096个ID序号<br>\n * 加起来刚好64位，为一个Long型。<br>\n * SnowFlake的优点是，整体上按照时间自增排序，并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分)，并且效率较高，经测试，SnowFlake每秒能够产生26万ID左右。\n */")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("public")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("class")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SnowflakeIdWorker")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ==============================Fields===========================================")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 开始时间截 (2015-01-01) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" twepoch "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1420041600000L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 机器id所占的位数 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" workerIdBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 数据标识id所占的位数 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" datacenterIdBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 支持的最大机器id，结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" maxWorkerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("^")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" workerIdBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 支持的最大数据标识id，结果是31 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" maxDatacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("^")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" datacenterIdBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 序列在id中占的位数 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" sequenceBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("12L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 机器ID向左移12位 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" workerIdShift "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" sequenceBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 数据标识id向左移17位(12+5) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" datacenterIdShift "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" sequenceBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" workerIdBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 时间截向左移22位(5+5+12) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" timestampLeftShift "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" sequenceBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" workerIdBits "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" datacenterIdBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 生成序列的掩码，这里为4095 (0b111111111111=0xfff=4095) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("final")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" sequenceMask "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("^")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" sequenceBits"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 工作机器ID(0~31) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" workerId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 数据中心ID(0~31) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" datacenterId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 毫秒内序列(0~4095) */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" sequence "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 上次生成ID的时间截 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("private")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" lastTimestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//==============================Constructors=====================================")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/**\n     * 构造函数\n     * @param workerId 工作ID (0~31)\n     * @param datacenterId 数据中心ID (0~31)\n     */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("public")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SnowflakeIdWorker")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" workerId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" datacenterId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("workerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" maxWorkerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("||")]),t._v(" workerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("throw")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("IllegalArgumentException")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("String")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("format")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"worker Id can\'t be greater than %d or less than 0"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" maxWorkerId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("datacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v(" maxDatacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("||")]),t._v(" datacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("throw")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("IllegalArgumentException")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("String")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("format")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"datacenter Id can\'t be greater than %d or less than 0"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" maxDatacenterId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("this")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("workerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" workerId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("this")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("datacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" datacenterId"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("// ==============================Methods==========================================")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/**\n     * 获得下一个ID (该方法是线程安全的)\n     * @return SnowflakeId\n     */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("public")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("synchronized")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("nextId")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("timeGen")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n        "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//如果当前时间小于上一次ID生成的时间戳，说明系统时钟回退过这个时候应当抛出异常")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" lastTimestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("throw")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("RuntimeException")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("\n                    "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("String")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("format")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Clock moved backwards.  Refusing to generate id for %d milliseconds"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" lastTimestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),t._v(" timestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n        "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//如果是同一时间生成的，则进行毫秒内序列")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("lastTimestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" timestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            sequence "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("sequence "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("+")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("&")]),t._v(" sequenceMask"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//毫秒内序列溢出")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("if")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("sequence "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n                "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//阻塞到下一个毫秒,获得新的时间戳")]),t._v("\n                timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tilNextMillis")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("lastTimestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//时间戳改变，毫秒内序列重置")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("else")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            sequence "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0L")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n        "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//上次生成ID的时间截")]),t._v("\n        lastTimestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" timestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n\n        "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//移位并通过或运算拼到一起组成64位的ID")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("return")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("-")]),t._v(" twepoch"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" timestampLeftShift"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//")]),t._v("\n                "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("datacenterId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" datacenterIdShift"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//")]),t._v("\n                "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("workerId "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<<")]),t._v(" workerIdShift"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//")]),t._v("\n                "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("|")]),t._v(" sequence"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/**\n     * 阻塞到下一个毫秒，直到获得新的时间戳\n     * @param lastTimestamp 上次生成ID的时间截\n     * @return 当前时间戳\n     */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("protected")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("tilNextMillis")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" lastTimestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("timeGen")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("while")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<=")]),t._v(" lastTimestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            timestamp "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("timeGen")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("return")]),t._v(" timestamp"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/**\n     * 返回以毫秒为单位的当前时间\n     * @return 当前时间(毫秒)\n     */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("protected")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("timeGen")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("return")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("System")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("currentTimeMillis")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("//==============================Test=============================================")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token comment"}},[t._v("/** 测试 */")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("public")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("static")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("void")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("main")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("String")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("[")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("]")]),t._v(" args"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SnowflakeIdWorker")]),t._v(" idWorker "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("new")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("SnowflakeIdWorker")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(",")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("for")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("int")]),t._v(" i "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("0")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" i "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1000")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v(" i"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("++")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("long")]),t._v(" id "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(" idWorker"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("nextId")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("System")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("out"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("println")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("Long")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("toBinaryString")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("id"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n            "),a("span",{pre:!0,attrs:{class:"token class-name"}},[t._v("System")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),t._v("out"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(".")]),a("span",{pre:!0,attrs:{class:"token function"}},[t._v("println")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("id"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n        "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n    "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("h2",{attrs:{id:"jenkins"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#jenkins"}},[t._v("#")]),t._v(" Jenkins")]),t._v(" "),a("p",[t._v("shell 脚本保持状态, 加载环境变量:")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("BUILD_ID")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("DONTKILLME\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v(".")]),t._v(" /etc/profile\n")])])]),a("h2",{attrs:{id:"filder"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#filder"}},[t._v("#")]),t._v(" Filder")]),t._v(" "),a("p",[t._v("显示 IP, 输出 websocket 日志:")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v("Main"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(": FiddlerObject.UI.lvSessions.AddBoundColumn"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"ServerIP"')]),t._v(", "),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("120")]),t._v(", "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"X-HostIP"')]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\nclass Handlers:\nstatic "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("function")]),t._v(" OnWebSocketMessage"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("oMsg: WebSocketMessage"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("{")]),t._v("\n        // Log Message to the LOG tab\n        FiddlerApplication.Log.LogString"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("oMsg.ToString"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("))")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("}")]),t._v("\n")])])]),a("h3",{attrs:{id:"内置命令"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#内置命令"}},[t._v("#")]),t._v(" 内置命令")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1")]),t._v(". "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("select")]),t._v(" xxx:  选择xxx类型的,  例如 "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("select")]),t._v(" html , "),a("span",{pre:!0,attrs:{class:"token keyword"}},[t._v("select")]),t._v(" image ,select video"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("..")]),t._v(" , content-type的类型\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("2")]),t._v(". allbut xxxx: allbut image--"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("只选择图片类型的, 会把其它捕获都删除"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("!")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("3")]),t._v(". ?xxx: 选择url中包含xxx的\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("4")]),t._v(". "),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),t._v("size "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("<")]),t._v("size: 过滤响应内容大小, 只能写数字 "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v(">")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("40000")]),t._v("   单位"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("(")]),t._v("b"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(")")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("5")]),t._v(". @host: 请求url包含xxx的, 例如:  @oschina.net\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("6")]),t._v(". "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("status: "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("200")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("404")]),t._v(" 过滤响应码\n"),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("7")]),t._v(". Bpafter， Bps, bpv, bpm, bpu: 断点命令,  也可以在filters中设置\n   Bpafter xxx: 中断 URL 包含指定字符的全部 session 响应\n    Bps xxx: 中断 HTTP 响应状态为指定字符的全部 session 响应。\n    Bpv xxx: 中断指定请求方式的全部 session 响应\n    Bpm xxx: 中断指定请求方式的全部 session 响应。等同于bpv xxx\n    Bpu xxx:与bpafter类似。\n")])])]),a("h2",{attrs:{id:"远程调试"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#远程调试"}},[t._v("#")]),t._v(" 远程调试")]),t._v(" "),a("ol",[a("li",[a("p",[t._v("Tomcat "),a("code",[t._v("startup.sh")]),t._v(" 开头")]),t._v(" "),a("blockquote",[a("p",[t._v('declare -x CATALINA_OPTS="-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3316"')])])]),t._v(" "),a("li",[a("p",[t._v("Jar")]),t._v(" "),a("blockquote",[a("p",[t._v("java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3316 xxx.jar")])])])]),t._v(" "),a("h2",{attrs:{id:"firewalld"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#firewalld"}},[t._v("#")]),t._v(" Firewalld")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[t._v("firewall-cmd --zone"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("public --add-port"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("80")]),t._v("-9000/tcp --permanent\n\nfirewall-cmd --zone"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("public --remove-port"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("80")]),t._v("/tcp --permanent\n\nfirewall-cmd --permanent --add-rich-rule"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"rule family="')]),t._v("ipv4"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" source address="')]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1.1")]),t._v(".1.1"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" port protocol="')]),t._v("tcp"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" port="')]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("8080")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" accept"')]),t._v("\nfirewall-cmd --permanent --remove-rich-rule"),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"rule family="')]),t._v("ipv4"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" source address="')]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("1.1")]),t._v(".1.1"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" port protocol="')]),t._v("tcp"),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" port="')]),a("span",{pre:!0,attrs:{class:"token number"}},[t._v("8080")]),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('" accept"')]),t._v("\n")])])]),a("h2",{attrs:{id:"jdk-环境变量"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#jdk-环境变量"}},[t._v("#")]),t._v(" JDK 环境变量")]),t._v(" "),a("p",[t._v("Windows:")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("JAVA_HOME")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v("D:"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("dev"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("Java"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("jdk1.6.0_12"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("classpath")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v("."),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("%JAVA_HOME%"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("lib"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("%JAVA_HOME%"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("lib"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("tools.jar\n"),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("path")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("==")]),t._v("%JAVA_HOME%"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("bin"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v(";")]),t._v("%JAVA_HOME%"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("jre"),a("span",{pre:!0,attrs:{class:"token punctuation"}},[t._v("\\")]),t._v("bin\n")])])]),a("p",[t._v("Linux: /etc/profile")]),t._v(" "),a("div",{staticClass:"language-bash extra-class"},[a("pre",{pre:!0,attrs:{class:"language-bash"}},[a("code",[a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("JAVA_HOME")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v("/home/jdk1.8.0_152\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[a("span",{pre:!0,attrs:{class:"token environment constant"}},[t._v("PATH")])]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$JAVA_HOME")]),t._v("/bin:"),a("span",{pre:!0,attrs:{class:"token environment constant"}},[t._v("$PATH")]),t._v("\n"),a("span",{pre:!0,attrs:{class:"token builtin class-name"}},[t._v("export")]),t._v(" "),a("span",{pre:!0,attrs:{class:"token assign-left variable"}},[t._v("CLASSPATH")]),a("span",{pre:!0,attrs:{class:"token operator"}},[t._v("=")]),t._v(".:"),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$JAVA_HOME")]),t._v("/lib/dt.jar:"),a("span",{pre:!0,attrs:{class:"token variable"}},[t._v("$JAVA_HOME")]),t._v("/lib/tools.jar\n")])])])])}),[],!1,null,null,null);s.default=e.exports}}]);