<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="http://hsly-xiaowen.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="http://hsly-xiaowen.github.io/" rel="alternate" type="text/html" /><updated>2020-03-15T21:40:08+08:00</updated><id>http://hsly-xiaowen.github.io/feed.xml</id><title type="html">Sea-fishing salt</title><subtitle>Sea-fishing salt blog</subtitle><author><name>Xiao Wen</name></author><entry><title type="html">Java指令手册</title><link href="http://hsly-xiaowen.github.io/2020/03/14/equip-JAVA-Java%E6%8C%87%E4%BB%A4%E6%89%8B%E5%86%8C/" rel="alternate" type="text/html" title="Java指令手册" /><published>2020-03-14T00:00:00+08:00</published><updated>2020-03-14T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/14/equip-JAVA-Java%E6%8C%87%E4%BB%A4%E6%89%8B%E5%86%8C</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/14/equip-JAVA-Java%E6%8C%87%E4%BB%A4%E6%89%8B%E5%86%8C/">&lt;p&gt;使用javap -c test.class &amp;gt; test.txt&lt;/p&gt;

&lt;p&gt;得到反编译的底层代码。记录栈和局部变量操作。&lt;a href=&quot;https://www.cnblogs.com/lsy131479/p/11201241.html&quot;&gt;资料来源请参考&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;将常量压入栈的指令&quot;&gt;将常量压入栈的指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;aconst_null 将null对象引用压入栈
iconst_m1 将int类型常量-1压入栈
iconst_0 将int类型常量0压入栈
iconst_1 将int类型常量1压入栈
iconst_2 将int类型常量2压入栈
iconst_3 将int类型常量3压入栈
iconst_4 将int类型常量4压入栈
iconst_5 将int类型常量5压入栈
lconst_0 将long类型常量0压入栈
lconst_1 将long类型常量1压入栈
fconst_0 将float类型常量0压入栈
fconst_1 将float类型常量1压入栈
dconst_0 将double类型常量0压入栈
dconst_1 将double类型常量1压入栈
bipush 将一个8位带符号整数压入栈
sipush 将16位带符号整数压入栈
ldc 把常量池中的项压入栈
ldc_w 把常量池中的项压入栈（使用宽索引）
ldc2_w 把常量池中long类型或者double类型的项压入栈（使用宽索引）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;从栈中的局部变量中装载值的指令&quot;&gt;从栈中的局部变量中装载值的指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iload 从局部变量中装载int类型值
lload 从局部变量中装载long类型值
fload 从局部变量中装载float类型值
dload 从局部变量中装载double类型值
aload 从局部变量中装载引用类型值（refernce）
iload_0 从局部变量0中装载int类型值
iload_1 从局部变量1中装载int类型值
iload_2 从局部变量2中装载int类型值
iload_3 从局部变量3中装载int类型值
lload_0 从局部变量0中装载long类型值
lload_1 从局部变量1中装载long类型值
lload_2 从局部变量2中装载long类型值
lload_3 从局部变量3中装载long类型值
fload_0 从局部变量0中装载float类型值
fload_1 从局部变量1中装载float类型值
fload_2 从局部变量2中装载float类型值
fload_3 从局部变量3中装载float类型值
dload_0 从局部变量0中装载double类型值
dload_1 从局部变量1中装载double类型值
dload_2 从局部变量2中装载double类型值
dload_3 从局部变量3中装载double类型值
aload_0 从局部变量0中装载引用类型值
aload_1 从局部变量1中装载引用类型值
aload_2 从局部变量2中装载引用类型值
aload_3 从局部变量3中装载引用类型值
iaload 从数组中装载int类型值
laload 从数组中装载long类型值
faload 从数组中装载float类型值
daload 从数组中装载double类型值
aaload 从数组中装载引用类型值
baload 从数组中装载byte类型或boolean类型值
caload 从数组中装载char类型值
saload 从数组中装载short类型值
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;将栈中的值存入局部变量的指令&quot;&gt;将栈中的值存入局部变量的指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;istore 将int类型值存入局部变量
lstore 将long类型值存入局部变量
fstore 将float类型值存入局部变量
dstore 将double类型值存入局部变量
astore 将将引用类型或returnAddress类型值存入局部变量
istore_0 将int类型值存入局部变量0
istore_1 将int类型值存入局部变量1
istore_2 将int类型值存入局部变量2
istore_3 将int类型值存入局部变量3
lstore_0 将long类型值存入局部变量0
lstore_1 将long类型值存入局部变量1
lstore_2 将long类型值存入局部变量2
lstore_3 将long类型值存入局部变量3
fstore_0 将float类型值存入局部变量0
fstore_1 将float类型值存入局部变量1
fstore_2 将float类型值存入局部变量2
fstore_3 将float类型值存入局部变量3
dstore_0 将double类型值存入局部变量0
dstore_1 将double类型值存入局部变量1
dstore_2 将double类型值存入局部变量2
dstore_3 将double类型值存入局部变量3
astore_0 将引用类型或returnAddress类型值存入局部变量0
astore_1 将引用类型或returnAddress类型值存入局部变量1
astore_2 将引用类型或returnAddress类型值存入局部变量2
astore_3 将引用类型或returnAddress类型值存入局部变量3
iastore 将int类型值存入数组中
lastore 将long类型值存入数组中
fastore 将float类型值存入数组中
dastore 将double类型值存入数组中
aastore 将引用类型值存入数组中
bastore 将byte类型或者boolean类型值存入数组中
castore 将char类型值存入数组中
sastore 将short类型值存入数组中
wide指令
wide 使用附加字节扩展局部变量索引
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;通用无类型栈操作&quot;&gt;通用(无类型）栈操作&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nop 不做任何操作
pop 弹出栈顶端一个字长的内容
pop2 弹出栈顶端两个字长的内容
dup 复制栈顶部一个字长内容
dup_x1 复制栈顶部一个字长的内容，然后将复制内容及原来弹出的两个字长的内容压入栈
dup_x2 复制栈顶部一个字长的内容，然后将复制内容及原来弹出的三个字长的内容压入栈
dup2 复制栈顶部两个字长内容
dup2_x1 复制栈顶部两个字长的内容，然后将复制内容及原来弹出的三个字长的内容压入栈
dup2_x2 复制栈顶部两个字长的内容，然后将复制内容及原来弹出的四个字长的内容压入栈
swap 交换栈顶部两个字长内容
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;类型转换&quot;&gt;类型转换&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;i2l 把int类型的数据转化为long类型
i2f 把int类型的数据转化为float类型
i2d 把int类型的数据转化为double类型
l2i 把long类型的数据转化为int类型
l2f 把long类型的数据转化为float类型
l2d 把long类型的数据转化为double类型
f2i 把float类型的数据转化为int类型
f2l 把float类型的数据转化为long类型
f2d 把float类型的数据转化为double类型
d2i 把double类型的数据转化为int类型
d2l 把double类型的数据转化为long类型
d2f 把double类型的数据转化为float类型
i2b 把int类型的数据转化为byte类型
i2c 把int类型的数据转化为char类型
i2s 把int类型的数据转化为short类型
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;整数运算&quot;&gt;整数运算&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iadd 执行int类型的加法
ladd 执行long类型的加法
isub 执行int类型的减法
lsub 执行long类型的减法
imul 执行int类型的乘法
lmul 执行long类型的乘法
idiv 执行int类型的除法
ldiv 执行long类型的除法
irem 计算int类型除法的余数
lrem 计算long类型除法的余数
ineg 对一个int类型值进行取反操作
lneg 对一个long类型值进行取反操作
iinc 把一个常量值加到一个int类型的局部变量上
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;移位操作&quot;&gt;移位操作&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ishl 执行int类型的向左移位操作
lshl 执行long类型的向左移位操作
ishr 执行int类型的向右移位操作
lshr 执行long类型的向右移位操作
iushr 执行int类型的向右逻辑移位操作
lushr 执行long类型的向右逻辑移位操作
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;按位布尔运算&quot;&gt;按位布尔运算&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;iand 对int类型值进行“逻辑与”操作
land 对long类型值进行“逻辑与”操作
ior 对int类型值进行“逻辑或”操作
lor 对long类型值进行“逻辑或”操作
ixor 对int类型值进行“逻辑异或”操作
lxor 对long类型值进行“逻辑异或”操作
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;浮点运算&quot;&gt;浮点运算&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;fadd 执行float类型的加法
dadd 执行double类型的加法
fsub 执行float类型的减法
dsub 执行double类型的减法
fmul 执行float类型的乘法
dmul 执行double类型的乘法
fdiv 执行float类型的除法
ddiv 执行double类型的除法
frem 计算float类型除法的余数
drem 计算double类型除法的余数
fneg 将一个float类型的数值取反
dneg 将一个double类型的数值取反
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;对象操作指令&quot;&gt;对象操作指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;new 创建一个新对象
checkcast 确定对象为所给定的类型
getfield 从对象中获取字段
putfield 设置对象中字段的值
getstatic 从类中获取静态字段
putstatic 设置类中静态字段的值
instanceof 判断对象是否为给定的类型
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;数组操作指令&quot;&gt;数组操作指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;newarray 分配数据成员类型为基本上数据类型的新数组
anewarray 分配数据成员类型为引用类型的新数组
arraylength 获取数组长度
multianewarray 分配新的多维数组
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;条件分支指令&quot;&gt;条件分支指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;feq 如果等于0，则跳转
ifne 如果不等于0，则跳转
iflt 如果小于0，则跳转
ifge 如果大于等于0，则跳转
ifgt 如果大于0，则跳转
ifle 如果小于等于0，则跳转
if_icmpcq 如果两个int值相等，则跳转
if_icmpne 如果两个int类型值不相等，则跳转
if_icmplt 如果一个int类型值小于另外一个int类型值，则跳转
if_icmpge 如果一个int类型值大于或者等于另外一个int类型值，则跳转
if_icmpgt 如果一个int类型值大于另外一个int类型值，则跳转
if_icmple 如果一个int类型值小于或者等于另外一个int类型值，则跳转
ifnull 如果等于null，则跳转
ifnonnull 如果不等于null，则跳转
if_acmpeq 如果两个对象引用相等，则跳转
if_acmpnc 如果两个对象引用不相等，则跳转
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;比较指令&quot;&gt;比较指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;lcmp 比较long类型值
fcmpl 比较float类型值（当遇到NaN时，返回-1）
fcmpg 比较float类型值（当遇到NaN时，返回1）
dcmpl 比较double类型值（当遇到NaN时，返回-1）
dcmpg 比较double类型值（当遇到NaN时，返回1）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;无条件转移指令&quot;&gt;无条件转移指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;goto 无条件跳转
goto_w 无条件跳转（宽索引）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;表跳转指令&quot;&gt;表跳转指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tableswitch 通过索引访问跳转表，并跳转
lookupswitch 通过键值匹配访问跳转表，并执行跳转操作
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;### 异常&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;athrow 抛出异常或错误
finally子句
jsr 跳转到子例程
jsr_w 跳转到子例程（宽索引）
rct 从子例程返回
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;### 方法调用指令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;invokcvirtual 运行时按照对象的类来调用实例方法
invokespecial 根据编译时类型来调用实例方法
invokestatic 调用类（静态）方法
invokcinterface 调用接口方法
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;方法返回指令&quot;&gt;方法返回指令&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ireturn 从方法中返回int类型的数据
lreturn 从方法中返回long类型的数据
freturn 从方法中返回float类型的数据
dreturn 从方法中返回double类型的数据
areturn 从方法中返回引用类型的数据
return 从方法中返回，返回值为void
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;线程同步&quot;&gt;线程同步&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;montiorenter 进入并获取对象监视器
monitorexit 释放并退出对象监视器
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;jvm指令助记符&quot;&gt;JVM指令助记符&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;变量到操作数栈：iload,iload_,lload,lload_,fload,fload_,dload,dload_,aload,aload_
操作数栈到变量：istore,istore_,lstore,lstore_,fstore,fstore_,dstore,dstor_,astore,astore_
常数到操作数栈：bipush,sipush,ldc,ldc_w,ldc2_w,aconst_null,iconst_ml,iconst_,lconst_,fconst_,dconst_
加：iadd,ladd,fadd,dadd
减：isub,lsub,fsub,dsub
乘：imul,lmul,fmul,dmul
除：idiv,ldiv,fdiv,ddiv
余数：irem,lrem,frem,drem
取负：ineg,lneg,fneg,dneg
移位：ishl,lshr,iushr,lshl,lshr,lushr
按位或：ior,lor
按位与：iand,land
按位异或：ixor,lxor
类型转换：i2l,i2f,i2d,l2f,l2d,f2d(放宽数值转换)
i2b,i2c,i2s,l2i,f2i,f2l,d2i,d2l,d2f(缩窄数值转换)
创建类实便：new
创建新数组：newarray,anewarray,multianwarray
访问类的域和类实例域：getfield,putfield,getstatic,putstatic
把数据装载到操作数栈：baload,caload,saload,iaload,laload,faload,daload,aaload
从操作数栈存存储到数组：bastore,castore,sastore,iastore,lastore,fastore,dastore,aastore
获取数组长度：arraylength
检相类实例或数组属性：instanceof,checkcast
操作数栈管理：pop,pop2,dup,dup2,dup_xl,dup2_xl,dup_x2,dup2_x2,swap
有条件转移：ifeq,iflt,ifle,ifne,ifgt,ifge,ifnull,ifnonnull,if_icmpeq,if_icmpene,
if_icmplt,if_icmpgt,if_icmple,if_icmpge,if_acmpeq,if_acmpne,lcmp,fcmpl
fcmpg,dcmpl,dcmpg
复合条件转移：tableswitch,lookupswitch
无条件转移：goto,goto_w,jsr,jsr_w,ret
调度对象的实便方法：invokevirtual
调用由接口实现的方法：invokeinterface
调用需要特殊处理的实例方法：invokespecial
调用命名类中的静态方法：invokestatic
方法返回：ireturn,lreturn,freturn,dreturn,areturn,return
异常：athrow
finally关键字的实现使用：jsr,jsr_w,ret
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Xiao Wen</name></author><summary type="html">使用javap -c test.class &amp;gt; test.txt</summary></entry><entry><title type="html">找工作一周总结</title><link href="http://hsly-xiaowen.github.io/2020/03/07/equip-Daily-%E6%89%BE%E5%B7%A5%E4%BD%9C%E5%BF%83%E5%BE%97/" rel="alternate" type="text/html" title="找工作一周总结" /><published>2020-03-07T00:00:00+08:00</published><updated>2020-03-07T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/07/equip-Daily-%E6%89%BE%E5%B7%A5%E4%BD%9C%E5%BF%83%E5%BE%97</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/07/equip-Daily-%E6%89%BE%E5%B7%A5%E4%BD%9C%E5%BF%83%E5%BE%97/">&lt;p&gt;受疫情影响，公司业务受阻，复工遥遥无期，只要另谋出路了。面试了一周左右，收获了3,4份offer。&lt;/p&gt;

&lt;h3 id=&quot;技术栈准备&quot;&gt;技术栈准备&lt;/h3&gt;
&lt;p&gt;1 面试前一定要多刷刷题，面试前熟悉自己简历里写的技术栈并适当想一些自己的心得。
各种优化的知识点，jvm优化、sql优化、代码优化等等。&lt;/p&gt;

&lt;p&gt;2 温故之前写的项目，清楚地描述，侧重说明难点以及怎么解决的，本身存在说明问题并提出优化方案。&lt;/p&gt;

&lt;p&gt;3 准备自己想学的技术栈，并构思好技术成长。&lt;/p&gt;

&lt;p&gt;4 面试前认真查看构思jd，针对性进行突击&lt;/p&gt;

&lt;h3 id=&quot;面试过程&quot;&gt;面试过程&lt;/h3&gt;
&lt;p&gt;1 个人介绍，更多突出自己的优势。&lt;/p&gt;

&lt;p&gt;2 技术面试，知道就是知道，别不懂装懂，在遇到问题的时候可以主动请教面试官（这也是个学习的过程）&lt;/p&gt;

&lt;p&gt;3 人事面，更多是离职原因、未来规划、福利待遇等。在这个阶段要问清楚公司情况！！！
谈薪资可以适当的说自己有别的选择。&lt;/p&gt;

&lt;h3 id=&quot;面试结束之后&quot;&gt;面试结束之后&lt;/h3&gt;
&lt;p&gt;1 及时总结本次面试回答不上来的问题。&lt;/p&gt;

&lt;p&gt;2 不要主动咨询面试结果或者咨询也不能放低姿态。&lt;/p&gt;</content><author><name>Xiao Wen</name></author><summary type="html">受疫情影响，公司业务受阻，复工遥遥无期，只要另谋出路了。面试了一周左右，收获了3,4份offer。</summary></entry><entry><title type="html">Windows搭建Java开发环境</title><link href="http://hsly-xiaowen.github.io/2020/03/07/equip-Windows-Java%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" rel="alternate" type="text/html" title="Windows搭建Java开发环境" /><published>2020-03-07T00:00:00+08:00</published><updated>2020-03-07T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/07/equip-Windows-Java%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/07/equip-Windows-Java%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/">&lt;p&gt;入职新公司再搭建新的Java开发环境浪费了大量的时间，写篇博文记录资源、破解方案、安装方式等。
主要安装jdk+git+maven+idea+xshell+navicat premium+redis图形化界面。&lt;/p&gt;

&lt;h3 id=&quot;安装jdk&quot;&gt;安装JDK&lt;/h3&gt;
&lt;p&gt;Windows环境jdk1.8资源链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1rknMxHYy7Xf4P252cZSgwA 提取码：obhu
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1、选择“计算机»单击右键»属性»高级系统设置»高级»环境变量”&lt;/p&gt;

&lt;p&gt;2、创建新的系统变量命名为JAVA_HOME，变量值为JAVA安装路径&lt;/p&gt;

&lt;p&gt;3、修改系统变量path的值，再最前面添加：%JAVA_HOME%\bin;&lt;/p&gt;

&lt;h3 id=&quot;安装配置git&quot;&gt;安装配置Git&lt;/h3&gt;
&lt;p&gt;Git-2.14.1-64下载链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1cntw1TVjQt_ub239q-kMMA 提取码：674f 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1 创建私服账号，已创建GitLab为例子&lt;/p&gt;

&lt;p&gt;2 桌面右键打开Git Bash界面，检查是否存在密钥对：cat ~/.ssh/id_rsa.pub&lt;/p&gt;

&lt;p&gt;3 创建新的SSH密钥对，执行以下命令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ssh-keygen -t rsa -C &quot;example@qq.com&quot; -b 4096
example@qq.com:表示在Gitlab上注册的账号
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4 一直回车，入如下图&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/windows/git_success.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;5 登录Gitlab服务器，点击右上角头像»Settings，添加SSH Keys:&lt;/p&gt;

&lt;p&gt;6 进入git bash界面，拉取代码git clone url即可&lt;/p&gt;

&lt;h3 id=&quot;maven环境搭建&quot;&gt;Maven环境搭建&lt;/h3&gt;
&lt;p&gt;maven3.6.1资源链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1XxjmtH97VLdGPfsEwfbFeQ 提取码：fdmx 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1 解压资源文件，进入高级属性配置MAVEN_HOME指向maven解压目录&lt;/p&gt;

&lt;p&gt;2 修改path变量，添加%MAVEN_HOME%/bin&lt;/p&gt;

&lt;p&gt;3 进入cmd，mvn -version校验是否成功&lt;/p&gt;

&lt;p&gt;4 修改用户目录下的.m2目录下的setting.xml文件&lt;/p&gt;

&lt;h3 id=&quot;安装破解idea&quot;&gt;安装破解Idea&lt;/h3&gt;
&lt;p&gt;idea2018.3.2链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/13EObikOzWshjeN8IE6cYmw 提取码：miqa 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;idea破解包JetbrainsIdesCrack-4.2-release.jar链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1KrOOnd7Q79V9oXHp_bXQnw 提取码：bjo1 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1 下载安装idea，将JetbrainsIdesCrack-4.2-release.jar放到idea安装命令的bin包里面&lt;/p&gt;

&lt;p&gt;2 对bin下的idea.exe.vmoptions和idea64.exe.vmoptions这两个文件进行修改，打开文件在末尾添加如下配置指令：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;-javaagent:D:/idea/bin/JetbrainsIdesCrack-4.2-release.jar（为包路径）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3 保存成功后启动idea，输入注册码&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ThisCrackLicenseId-{
&quot;licenseId&quot;:&quot;ThisCrackLicenseId&quot;,
&quot;licenseeName&quot;:&quot;Rover12421&quot;,
&quot;assigneeName&quot;:&quot;&quot;,
&quot;assigneeEmail&quot;:&quot;rover12421@163.com&quot;,
&quot;licenseRestriction&quot;:&quot;For Rover12421 Crack, Only Test! Please support genuine!!!&quot;,
&quot;checkConcurrentUse&quot;:false,
&quot;products&quot;:[
{&quot;code&quot;:&quot;II&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;DM&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;AC&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;RS0&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;WS&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;DPN&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;RC&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;PS&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;DC&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;RM&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;CL&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;},
{&quot;code&quot;:&quot;PC&quot;,&quot;paidUpTo&quot;:&quot;9998-12-31&quot;}
],
&quot;hash&quot;:&quot;2911276/0&quot;,
&quot;gracePeriodDays&quot;:7,
&quot;autoProlongated&quot;:false}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;更多方式&lt;a href=&quot;https://blog.csdn.net/java_zyq/article/details/88532526&quot;&gt;参考链接教程&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;安装xshell工具&quot;&gt;安装xShell工具&lt;/h3&gt;
&lt;p&gt;xShell6链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/15hzesXYDuz-qjuFk99ceKA 提取码：uyo9
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1 一直下一步到结束为止&lt;/p&gt;

&lt;p&gt;2 添加公司服务器地址，配置账号&amp;amp;密码（区分开发、测试、线上环境）&lt;/p&gt;

&lt;h3 id=&quot;安装数据库图形化界面&quot;&gt;安装数据库图形化界面&lt;/h3&gt;
&lt;p&gt;navicat premium支持各种数据库图形化界面操作&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/13NBCc9Cg2A89IZP-T1yTtQ 提取码：6yk8 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;navicat premium破解包链接：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1YQoqPvWSwGXw07m3Fg4jxA 提取码：egui 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;破解方式:安装navicat后，请根据自己安装Navicat Premium 12的语言（简体中文、繁体中文、英文）和版本位数（32位、64位），
将对应文件夹里的所有文件拷贝至Navicat Premium 12安装位置的根目录（即能看到navicat.exe的那个目录）。&lt;/p&gt;

&lt;h3 id=&quot;jmeter工具以及&quot;&gt;Jmeter工具以及&lt;/h3&gt;
&lt;p&gt;压测工具Jmeter以及插件
将JmterPlugins的两个插件放到jmeter解压包lib/ext目录下可以统计tps，响应时间等&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/17QXPJT8KeXOe8fiXbKknOg 提取码：ny3y

Jmeter插件方便查看Tps等指标
https://pan.baidu.com/s/1JrCqLE4hZ2TWS5a7gwoxFw 提取码：infp
https://pan.baidu.com/s/1n2D8lh3QCvToZzM-RDgB6w 提取码：dj5f
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;其他辅助工具&quot;&gt;其他辅助工具&lt;/h3&gt;
&lt;p&gt;redis图形化界面资源链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1pA9G0Wx06IG3PbHmYrxI-A 提取码：kezf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;postman工具链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1Y0IY33ayefG6Fxye_yQVmg 提取码：zyo0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;jca461.jar用于分析线程栈dump信息，分析线程dump情况（http://spotify.github.io/threaddump-analyzer 在线分析线程dump情情况&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1JAvPoNfkoalS0Cq5k22QQQ 提取码：hlsh 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ha456.jar用于分析堆dump，分析堆内存使用对象情况&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1nyZWnjDR_2tyBn_lcy9QtA 提取码：p9ed
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;jar包反编译工具&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://pan.baidu.com/s/1J5qzINlcmiajrNsC_T2tTQ 提取码：lz3f
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;谷歌访问外网插件链接&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; https://pan.baidu.com/s/1NG-krcGjMowWgL7W1hzmIQ 提取码：cqwc 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Xiao Wen</name></author><summary type="html">入职新公司再搭建新的Java开发环境浪费了大量的时间，写篇博文记录资源、破解方案、安装方式等。 主要安装jdk+git+maven+idea+xshell+navicat premium+redis图形化界面。</summary></entry><entry><title type="html">Nginx为什么那么快？</title><link href="http://hsly-xiaowen.github.io/2020/03/06/equip-Nginx-Nginx%E4%B8%BA%E4%BB%80%E4%B9%88%E9%82%A3%E4%B9%88%E5%BF%AB/" rel="alternate" type="text/html" title="Nginx为什么那么快？" /><published>2020-03-06T00:00:00+08:00</published><updated>2020-03-06T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/06/equip-Nginx-Nginx%E4%B8%BA%E4%BB%80%E4%B9%88%E9%82%A3%E4%B9%88%E5%BF%AB</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/06/equip-Nginx-Nginx%E4%B8%BA%E4%BB%80%E4%B9%88%E9%82%A3%E4%B9%88%E5%BF%AB/">&lt;p&gt;Nginx 是一款轻量级的Web服务器、反向代理服务器，由于它的内存占用少，启动极快，高并发能力强，在互联网项目中广泛应用。
采用的是多进程（单线程） &amp;amp; 多路IO复用模型，使用的epoll模型的并发时间驱动型服务器。&lt;/p&gt;

&lt;h3 id=&quot;nginx的工作模式&quot;&gt;Nginx的工作模式&lt;/h3&gt;
&lt;p&gt;Nginx是多进程模式，master-worker模式。一个master多个worker。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/nginx/master-worker.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;master进程&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;读取并验证配置文件nginx.conf
监控 worker 进程的运行状态，当 worker 进程退出后(异常情况下)，会自动启动新的 worker 进程。
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;worker进程&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; 每一个Worker进程都维护一个线程（避免线程切换），处理连接和请求；
 注意Worker进程的个数由配置文件决定，一般和CPU个数相关（避免进程切换），配置几个就有几个Worker进程。
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;当一个 worker 进程在 accept() 这个连接之后，就开始读取请求，解析请求，处理请求，产生数据后，再返回给客户端，最后才断开连接，一个完整的请求。一个请求，
   完全由 worker 进程来处理，而且只能在一个 worker 进程中处理。&lt;/p&gt;

&lt;p&gt;采用io多路复用epoll模型。epoll模型基于事件驱动机制，它可以监控多个事件是否准备完毕，
   如果OK，那么放入epoll队列中，这个过程是异步的。worker只需要从epoll队列循环处理即可。&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;epoll模型 与 select模型 相比最大的优点是不会随着 sockfd 数目增长而降低效率，使用 select() 时，内核采用轮训的方法来查看是否有fd 准备好，
   其中的保存 sockfd 的是类似数组的数据结构 fd_set，key 为 fd，value 为 0 或者 1。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;基于该工作模式，有以下的优点：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;nginx的多进程以及io多路复用epoll模型，保证了nginx可以处理10w+(理论上取决于内存而不是linux文件句柄)的用户请求。
   
master-worker模式保证了nginx的高可靠性。当其中一个worker退出时候，master马上会重新启动新的worker进程。多个worker相不影响。
   
nginx 处理请求是异步非阻塞的，一个请求全程由一个进程一个线程完成，多路复用

高度模块化的设计，编写模块相对简单；
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;nginx的热部署&quot;&gt;Nginx的热部署&lt;/h3&gt;
&lt;p&gt;修改配置文件nginx.conf后，重新生成新的worker进程，当然会以新的配置进行处理请求，而且新的请求必须都交给新的worker进程，
   至于老的worker进程，等把那些以前的请求处理完毕后，kill掉即可。&lt;/p&gt;

&lt;h3 id=&quot;nginx的高可用&quot;&gt;Nginx的高可用&lt;/h3&gt;
&lt;p&gt;Keepalived+Nginx实现高可用。使用keepalived主要是用来防止服务器单点发生故障，可以通过和Nginx配合来实现Web服务的高可用&lt;/p&gt;

&lt;h3 id=&quot;apache-和-nginx对比&quot;&gt;Apache 和 Nginx对比&lt;/h3&gt;

&lt;p&gt;1 nginx和Apache的核心区别：Apache是同步多进程模式，一个连接一个进程，采用select模型，受文件句柄限制。
   nginx是异步的，多个连接（万级别）可以对应一个进程&lt;/p&gt;

&lt;p&gt;2 nginx的配置比apache简单&lt;/p&gt;

&lt;p&gt;3 相比 Apache，Nginx 使用更少的资源，支持更多的并发连接，体现更高的效率。&lt;/p&gt;

&lt;p&gt;4 Apache在动态请求方面比nginx好，nginx在静态请求方方面比apach好&lt;/p&gt;

&lt;p&gt;5 &lt;a href=&quot;https://www.cnblogs.com/cunkouzh/p/5410154.html&quot;&gt;更多参考&lt;/a&gt;&lt;/p&gt;</content><author><name>Xiao Wen</name></author><summary type="html">Nginx 是一款轻量级的Web服务器、反向代理服务器，由于它的内存占用少，启动极快，高并发能力强，在互联网项目中广泛应用。 采用的是多进程（单线程） &amp;amp; 多路IO复用模型，使用的epoll模型的并发时间驱动型服务器。</summary></entry><entry><title type="html">面试题目汇总</title><link href="http://hsly-xiaowen.github.io/2020/03/03/equip-%E9%9D%A2%E8%AF%95-%E9%9D%A2%E8%AF%95%E9%A2%98%E7%9B%AE%E6%B1%87%E6%80%BB/" rel="alternate" type="text/html" title="面试题目汇总" /><published>2020-03-03T00:00:00+08:00</published><updated>2020-03-03T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/03/equip-%E9%9D%A2%E8%AF%95-%E9%9D%A2%E8%AF%95%E9%A2%98%E7%9B%AE%E6%B1%87%E6%80%BB</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/03/equip-%E9%9D%A2%E8%AF%95-%E9%9D%A2%E8%AF%95%E9%A2%98%E7%9B%AE%E6%B1%87%E6%80%BB/">&lt;p&gt;2019年03月03日面试题目汇总&lt;/p&gt;

&lt;h3 id=&quot;常见分布式全局唯一id生成策略以及优缺点&quot;&gt;常见分布式全局唯一ID生成策略以及优缺点&lt;/h3&gt;
&lt;p&gt;方法一：用数据库自带的 auto_increment 来生成，&lt;/p&gt;

&lt;p&gt;优点：&lt;/p&gt;

&lt;p&gt;1 此方法使用数据库原有的功能，所以相对简单&lt;/p&gt;

&lt;p&gt;2 能够保证唯一性，数据库唯一控制、为了保证唯一性，大量添加时候性能不佳&lt;/p&gt;

&lt;p&gt;3 能够保证递增性，对数据库索引结构变更影响较小。&lt;/p&gt;

&lt;p&gt;4 id之间的步长是固定且可自定义的&lt;/p&gt;

&lt;p&gt;缺点：&lt;/p&gt;

&lt;p&gt;1 该方式与数据库耦合，不同数据库的实现不一样，当切换数据库时候工作量较大。&lt;/p&gt;

&lt;p&gt;2 扩展性差，性能有上限：因为写入是单点，数据库主库的写性能决定ID的生成性能上限，并且 难以扩展&lt;/p&gt;

&lt;p&gt;3 自增的方式，数据是连续的。非常容易被恶意用户爬取数据&lt;/p&gt;

&lt;p&gt;方法二： 使用uuid，uuid是一种常见的本地生成ID的方法。UUID uuid = UUID.randomUUID()&lt;/p&gt;

&lt;p&gt;优点：&lt;/p&gt;

&lt;p&gt;1 本地生成ID，不需要进行远程调用，时延低&lt;/p&gt;

&lt;p&gt;2 扩展性好，与数据库无关，基本可以认为没有性能上限&lt;/p&gt;

&lt;p&gt;缺点：&lt;/p&gt;

&lt;p&gt;1 无法保证趋势递增，无序。增删的时候索引变更影响较大&lt;/p&gt;

&lt;p&gt;2 uuid过长(不推荐主键过长，占用空间)，往往用字符串表示，作为主键建立索引查询效率低&lt;/p&gt;

&lt;p&gt;方法三：Twitter 开源的 Snowflake 算法，核心思想：使用41bit作为毫秒数，10bit作为机器的ID（5个bit是数据中心，5个bit的机器ID），
 12bit作为毫秒内的流水号（意味着每个节点在每毫秒可以产生 4096 个 ID），最后还有一个符号位，永远是0。&lt;/p&gt;

&lt;p&gt;优点：&lt;/p&gt;

&lt;p&gt;1 速度快，保证唯一性。性能好&lt;/p&gt;

&lt;p&gt;2 没有啥依赖，实现也特别简单。与数据库无关&lt;/p&gt;

&lt;p&gt;缺点：&lt;/p&gt;

&lt;p&gt;1 只能趋势递增。字段较长，作为主键建立索引查询效率低&lt;/p&gt;

&lt;p&gt;2 依赖机器时间，如果发生回拨会导致可能生成id重复&lt;/p&gt;

&lt;h3 id=&quot;缓存穿透缓存击穿缓存雪崩区别和解决方案&quot;&gt;缓存穿透、缓存击穿、缓存雪崩区别和解决方案&lt;/h3&gt;
&lt;p&gt;缓存：将一些常用但不常修改、非强一致性的数据缓存起来加快查询，减轻数据库压力，&lt;/p&gt;

&lt;p&gt;缓存穿透：缓存和数据库中都没有的数据，而用户不断发起请求，如发起为id为“-1”的数据或id为特别大不存在的数据。这时的用户很可能是攻击者，攻击会导致数据库压力过大。&lt;/p&gt;

&lt;p&gt;解决方案&lt;/p&gt;

&lt;p&gt;1 接口层增加校验，如用户鉴权校验，id做基础校验，id&amp;lt;=0的直接拦截；&lt;/p&gt;

&lt;p&gt;2 从缓存取不到的数据，在数据库中也没有取到，这时也可以将key-value对写为key-null，缓存有效时间可以设置短点。&lt;/p&gt;

&lt;p&gt;缓存击穿：缓存中没有但数据库中有的数据（一般是缓存时间到期），大量并发用户同时读缓存没读到数据，
 又同时去数据库去取数据，引起数据库压力瞬间增大，造成过大压力。(指并发查同一条数据)&lt;/p&gt;

&lt;p&gt;解决方案&lt;/p&gt;

&lt;p&gt;1 对于一些数据设置永久过期、过期时间设置在人流量少（推荐）的时候&lt;/p&gt;

&lt;p&gt;2 加互斥锁，防止同一数据并发访问数据库。&lt;/p&gt;

&lt;p&gt;缓存雪崩：缓存中数据大批量到过期时间，很多数据都查不到从而查数据库，而查询数据量巨大，引起数据库压力过大甚至down机。&lt;/p&gt;

&lt;p&gt;解决方案&lt;/p&gt;

&lt;p&gt;1 缓存过期时间分散或者集中在人流量很少的时候&lt;/p&gt;

&lt;p&gt;2 一主多重，分表分库，读写分离。热点数据分布式部署。&lt;/p&gt;

&lt;p&gt;注：缓存雪崩和缓存击穿不同的是缓存击穿指并发查同一条数据，缓存雪崩是不同数据都过期了，很多数据都查不到从而查数据库。&lt;/p&gt;

&lt;h3 id=&quot;谈谈分布式事务和分布式锁&quot;&gt;谈谈分布式事务和分布式锁&lt;/h3&gt;
&lt;p&gt;分布式锁：控制分布式系统有序的去对共享资源进行操作，通过互斥来保持一致性。一个资源同一时间只能被一个线程使用
高可用高性能的获取、释放锁。具备失效机制避免死锁。解决的是多进程的并发问题。&lt;/p&gt;

&lt;p&gt;实现的三种方式：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; 1. 基于数据库实现分布式锁； 
 2. 基于缓存（Redis等）实现分布式锁；
 3. 基于Zookeeper实现分布式锁
 Redis与Zookeeper对比：Redis基于内存，性能比Zookeeper好。但是Redis的有效时间控制有延迟，可靠性Zookeeper更佳
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;分布式事务:事务是达到以下目的的最好方法即保证执行结果的正确性；保证数据的一致性；ACID&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;在CAP定理中，一致性、可用性、分区容错性是不可能同时存在的。但在实际的应用场景中，数据的一致性是需要保证的。&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;实现方案：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TCC 方案
消息队列
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;说一下hashmapconcurrenthashmap-17和18的区别&quot;&gt;说一下HashMap，ConCurrentHashMap 1.7和1.8的区别&lt;/h3&gt;
&lt;p&gt;HashMap的区别&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1 数据结构不一样了， 1.7是数组+链表，1.8是数组+链表+红黑树（当链长超过8时候转化为红黑树，小于等于6时，树结构还原成链表形式。）
2 扩容的时机：1.7在插入数据之前扩容，而1.8插入数据成功之后扩容。
3 扩容后数据存储位置的计算方式也不一样：
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ConCurrentHashMap的区别&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; 1.7基于Segment + HashEntry实现，对segment加锁
 1.8基于Node + CAS + Synchronized实现
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Xiao Wen</name></author><summary type="html">2019年03月03日面试题目汇总</summary></entry><entry><title type="html">Docker简单入门</title><link href="http://hsly-xiaowen.github.io/2020/03/02/equip-Docker-Docker-Command-Notes/" rel="alternate" type="text/html" title="Docker简单入门" /><published>2020-03-02T00:00:00+08:00</published><updated>2020-03-02T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/02/equip-Docker-Docker%20Command%20Notes</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/02/equip-Docker-Docker-Command-Notes/">&lt;p&gt;Docker 是一个开源的应用容器引擎，让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中，
然后发布到任何流行的 Linux或Windows 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。&lt;/p&gt;

&lt;h2 id=&quot;docker简单入门&quot;&gt;Docker简单入门&lt;/h2&gt;
&lt;p&gt;docker简单入门的命令&lt;/p&gt;

&lt;p&gt;下载安装docker&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;开启docker服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl start docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;关闭docker服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl stop docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启docker服务&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl restart docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;设置docker为开机自启&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl enable docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;查看docker的版本信息&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker version
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;从远程下载镜像文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker pull +镜像地址（从网易蜂巢查找）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;删除本地车库的镜像&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker rmi -f +镜像ID
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;查看本机所有的镜像文件：docker images&lt;/p&gt;

&lt;p&gt;开启一个镜像容器：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;1 docker run +镜像名称(在前台进行）
2 docker run -t +镜像ID
docker run -d -p 端口号：端口号 镜像名称（开启应用用于外界访问镜像）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;关闭镜像容器&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker stop +镜像ID（可以是容器ID）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;清理所有已经停止的容器：docker rm $(docker ps -a -q)&lt;/p&gt;

&lt;p&gt;进去容器（相当于一台主机）：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker exec -it 容器id bash
 docker attach &amp;lt;ContainerID&amp;gt; （启动时后缀加了/bin/bash）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;查看正在运行的镜像容器&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker ps
 docker ps -a 查看所有镜像容器包括已经停止
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启已经停止的镜像容器&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; docker start ContainerID
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;创建镜像文件Dockerfile格式：from +镜像（表示以该镜像为基础镜像）&lt;/p&gt;

&lt;p&gt;MAINTAINER +用户名 +邮箱&lt;/p&gt;

&lt;p&gt;COPY 源文件 指定目录（把源文件拷贝到指定目录下）&lt;/p&gt;

&lt;p&gt;COPY 源文件 指定目录（可以有多个）&lt;/p&gt;

&lt;p&gt;RUN  在创建镜像时候要执行的软件安装命令（比如安装vim,允许多个）&lt;/p&gt;

&lt;p&gt;例如：Tomcat镜像为基础镜像，要把web项目拷贝到tomcat的WebApps目录下&lt;/p&gt;

&lt;p&gt;docker build .给当前目录的Dockerfile创建一个镜像&lt;/p&gt;

&lt;p&gt;docker build -t +name .给当前镜像定义一个名称&lt;/p&gt;

&lt;p&gt;docker commit ID new_image_name  保存对容器的修改（例如：修改了tomcat的配置文件会永远保存）&lt;/p&gt;

&lt;p&gt;防火墙对docker的影响：docker开启的容器相当于虚拟机，使用网络桥接的方式和主机使用相同的网络
CentOS-7 中介绍了 firewalld，firewall的底层是使用iptables进行数据过滤，建立在iptables之上，这可能会与 Docker 产生冲突。
当 firewalld 启动或者重启的时候，将会从 iptables 中移除 DOCKER 的规则，从而影响了 Docker 的正常工作。
当你使用的是 Systemd 的时候， firewalld 会在 Docker 之前启动，但是如果你在 Docker 启动之后再启动 或者重启 firewalld ，
你就需要重启 Docker 进程了。&lt;/p&gt;

&lt;h2 id=&quot;安装一个centos-系统&quot;&gt;安装一个centos 系统&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker run -d -i -t &amp;lt;imageID&amp;gt; /bin/bash 启动一个一直停留在后台运行的Centos了。
如果少了/bin/bash的话，Docker会生成一个Container但是马上就停止了，
不会一致运行即使有了-d参数。
docker attach &amp;lt;ContainerID&amp;gt; 进入安装的centos系统 如果没有ifconfig
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;yum search ifconfig  查询所需程序&lt;/p&gt;

&lt;p&gt;yum install net-tools.x86_64 安装ifconfig&lt;/p&gt;

&lt;p&gt;安装SSL协议&lt;/p&gt;

&lt;p&gt;yum install -y openssh-server&lt;/p&gt;

&lt;p&gt;/usr/sbin/sshd -D  启动SSL服务&lt;/p&gt;</content><author><name>Xiao Wen</name></author><summary type="html">Docker 是一个开源的应用容器引擎，让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中， 然后发布到任何流行的 Linux或Windows 机器上，也可以实现虚拟化。容器是完全使用沙箱机制，相互之间不会有任何接口。</summary></entry><entry><title type="html">FastDFS安装笔记</title><link href="http://hsly-xiaowen.github.io/2020/03/02/equip-FastDFS-FastDFS-Installation-Command-Notes/" rel="alternate" type="text/html" title="FastDFS安装笔记" /><published>2020-03-02T00:00:00+08:00</published><updated>2020-03-02T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/02/equip-FastDFS-FastDFS%20Installation%20Command%20Notes</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/02/equip-FastDFS-FastDFS-Installation-Command-Notes/">&lt;p&gt;FastDFS：是一个开源的轻量级分布式文件系统，由跟踪服务器（tracker server）、存储服务器（storage server）和客户端（client）三个部分组成，
主要解决了海量数据存储问题&lt;/p&gt;

&lt;p&gt;Tracker主要做调度工作，相当于mvc中的controller的角色，在访问上起负载均衡的作用。
跟踪器和存储节点都可以由一台或多台服务器构成，跟踪器和存储节点中的服务器均可以随时增加或下线而
不会影响线上服务，其中跟踪器中的所有服务器都是对等的，可以根据服务器的压力情况随时增加或减少。&lt;/p&gt;

&lt;p&gt;Tracker负责管理所有的Storage和group，每个storage在启动后会连接Tracker，告知自己所属的group等信息，并保持周期性的心跳，tracker根据storage的心跳信息，建立group==&amp;gt;[storage server list]的映射表，Tracker需要管理的元信息很少，会全部存储在内存中；另外tracker上的元信息都是由storage汇报的信息生成的，本身不需要持久化任何数据，这样使得tracker非常容易扩展，直接增加tracker机器即可扩展为tracker cluster来服务，cluster里每个tracker之间是完全对等的，所有的tracker都接受stroage的心跳信息，生成元数据信息来提供读写服务。&lt;/p&gt;

&lt;p&gt;Storage采用了分卷[Volume]（或分组[group]）的组织方式，存储系统由一个或多个组组成，
组与组之间的文件是相互独立的，所有组的文件容量累加就是整个存储系统中的文件容量。
一个卷[Volume]（组[group]）可以由一台或多台存储服务器组成，
一个组中的存储服务器中的文件都是相同的，组中的多台存储服务器起到了冗余备份和负载均衡的作用，
数据互为备份，存储空间以group内容量最小的storage为准，所以建议group内的多个storage尽量配置相同，
以免造成存储空间的浪费。&lt;/p&gt;

&lt;h2 id=&quot;安装步骤&quot;&gt;安装步骤&lt;/h2&gt;
&lt;p&gt;资源下载：https://github.com/happyfish100/fastdfs/releases&lt;/p&gt;

&lt;p&gt;需要文件：libfastcommon-master.zip,fastdfs-5.*.tar.gz&lt;/p&gt;

&lt;h3 id=&quot;安装libfastcommon&quot;&gt;安装libfastcommon&lt;/h3&gt;

&lt;p&gt;1 解压libfastcommon-master.zip文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; unzip libfastcommon-master.zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;如果报没有unzip command，使用yum install -y unzip下载unzip命令库&lt;/p&gt;

&lt;p&gt;2 进入解压后的文件：cd libfastcommon-master&lt;/p&gt;

&lt;p&gt;执行ll命令会发现可执行文件make.sh&lt;/p&gt;

&lt;p&gt;3 执行make.sh编译程序：./make.sh。如果编译失败，可能缺少gcc编译器：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install -y gcc-c++
if make common not find ：yum install -y make
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3 安装libfastcommon：./make.sh install&lt;/p&gt;

&lt;p&gt;libfastcommon.so 默认安装到了/usr/lib64/libfastcommon.so。&lt;/p&gt;

&lt;p&gt;因为fastdfs的主程序设置安装到/usr/lib/下：cp /usr/lib64/libfastcommon.so /usr/bin/ (如果已有可以不要复制)&lt;/p&gt;

&lt;p&gt;到此libfastcommon安装完毕&lt;/p&gt;

&lt;h3 id=&quot;安装fastdfs&quot;&gt;安装fastdfs&lt;/h3&gt;
&lt;p&gt;1 解压文件：tar -zxvf fastdfs-5.*.tar.gz&lt;/p&gt;

&lt;p&gt;2 进入解压文件：cd fastdfs-5.*
  执行ll 会看到configure可执行文件&lt;/p&gt;

&lt;p&gt;3 编译文件：./configure&lt;/p&gt;

&lt;p&gt;4 安装：./configure install&lt;/p&gt;

&lt;p&gt;安装会创建三个文件：/usr/local/fastdfs-5.05/(解压文件夹)，/etc/fdfs/(fastdfs配置文件)，
                      /usr/lib/（fastdfs主程序命令所在地）&lt;/p&gt;

&lt;p&gt;5 把解压文件下conf文件夹下的文件拷贝到/etc/fdfs/下（图片可以不用）&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /usr/local/fastdfs-5.05/conf/*.conf /etc/fdfs/
cp /usr/local/fastdfs-5.05/conf/mime.types /etc/fdfs/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装fastDFS安装完成&lt;/p&gt;

&lt;h2 id=&quot;fastdfs-trackerstorageclient配置&quot;&gt;fastdfs tracker，storage，client配置&lt;/h2&gt;
&lt;p&gt;Tracker配置:修改/etc/fdfs/tracker.conf文件&lt;/p&gt;

&lt;p&gt;1 创建用于存储Tracker的数据文件和日志文件的文件夹&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir -p /usr/local/fdfs/tracker (-p递归创建文件夹)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2 vim /etc/fdfs/tracker.conf&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;需要做的修改：port=22122 #设置tracker的端口号，通常采用22122这个默认端口
            base_path=/usr/local/fdfs/tracker #设置tracker的数据文件和日志目录
	http.server_port=6666 #设置http端口号，默认为8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;修改后保存退出&lt;/p&gt;

&lt;p&gt;3 启动tracker&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启tracker /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart&lt;/p&gt;

&lt;p&gt;停止tracker /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf stop&lt;/p&gt;

&lt;p&gt;确认启动 如果有fdfs_trackerd说明启动成功&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ps -aux |grep fdfs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;storage配置配置etcfdfsstorageconf&quot;&gt;storage配置：配置/etc/fdfs/storage.conf&lt;/h3&gt;
&lt;p&gt;1 创建storage需要的文件夹&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /usr/local/fdfs/storage       用于storage日志文件存储地址
mkdir /usr/local/fdfs/storage_data  真正的文件存储路径
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2 vim /etc/fdfs/storage.conf&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;修改文件：disabled=false #启用配置文件（默认启用）
group_name=group1 #组名，根据实际情况修改
port=23000 #设置storage的端口号，默认是23000，同一个组的storage端口号必须一致
base_path=/usr/local/fdfs/storage #设置storage数据文件和日志目录
store_path_count=1 #存储路径个数，需要和store_path个数匹配
store_path0=/usr/local/fdfs/storage_data #实际文件存储路径
tracker_server=192.168.111.11(公网ip地址):22122 # tracker服务器的 IP地址和端口号，如果是单机搭建，IP不要写127.0.0.1，否则启动不成功（此处的ip是我的CentOS虚拟机ip）
http.server_port=8888 #设置 http 端口号
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3 启动tracker /usr/bin/fdfs_storaged /etc/fdfs/storage.conf 必须先启动tracker,storage才能启动成功&lt;/p&gt;

&lt;p&gt;重启tracker /usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart&lt;/p&gt;

&lt;p&gt;停止tracker /usr/bin/fdfs_storaged /etc/fdfs/storage.conf stop&lt;/p&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;ps -aux&lt;/td&gt;
      &lt;td&gt;grep fdfs 确认启动 如果有fdfs_storaged说明启动成功&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;client配置etcfdfsclientconf&quot;&gt;client配置:/etc/fdfs/client.conf&lt;/h2&gt;

&lt;p&gt;1 创建client所需的日志文件保存路径：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /usr/local/fdfs/client/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2 vim /etc/fdfs/client.conf&lt;/p&gt;

&lt;p&gt;base_path=/usr/local/fdfs/client/&lt;/p&gt;

&lt;p&gt;tracker_server=192.168.111.11（公网地址）:22122 #tracker服务器IP地址和端口号&lt;/p&gt;

&lt;p&gt;3 测试文件上传 /usr/bin/fdfs_upload_file  /etc/fdfs/client.conf  /opt/BLIZZARD.jpg
  返回一个上传图片的url地址&lt;/p&gt;

&lt;p&gt;fastDFS 不支持http服务，nginx上使用FastDFS的模块fastdfs-nginx-module提供http服务&lt;/p&gt;

&lt;p&gt;下载fastdfs-nginx-module源码包 https://github.com/happyfish100&lt;/p&gt;

&lt;p&gt;1 wget https://github.com/happyfish100/xxxx&lt;/p&gt;

&lt;p&gt;2 解压压缩文件&lt;/p&gt;

&lt;p&gt;3 进入解压文件，cd fastdfs-nginx-module&lt;/p&gt;

&lt;p&gt;4 把fastdfs-nginx-module/src/mod_fastdfs.conf 拷贝到/etc/fdfs/下&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /mod_fastdfs.conf/src/mod_fastdfs.conf /etc/fdfs/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;5 把mod_fastdfs.conf安装到nginx。&lt;/p&gt;

&lt;p&gt;如果已经安装好了nginx：进入nginx解压文件下，执行./configure –add-module=/src(src路径)&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                     make 编译 make install安装（相当重新安装一遍nginx）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;如果没有安装过nginx ：见其他文档，解压好文件后。&lt;/p&gt;

&lt;p&gt;进入nginx解压文件下，执行./configure –add-module=/src(src路径)&lt;/p&gt;

&lt;p&gt;6 修改/etc/mod_fastdfs.conf&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;base_path=/opt/fastdfs_storage #保存日志目录
tracker_server=192.168.111.11:22122 #tracker服务器的IP地址以及端口号
storage_server_port=23000 #storage服务器的端口号
url_have_group_name = true #文件 url 中是否有 group 名
store_path0=/opt/fastdfs_storage_data # 存储路径
group_count = 3 #设置组的个数，事实上这次只使用了group1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;#配置完了还不能正常访问文件服务系统的话，多半是端口没有开放&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;firewall-cmd --zone=public --add-port=22122/tcp --permanent

firewall-cmd --zone=public --add-port=23000/tcp --permanent

firewall-cmd --reload 重启防火墙
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;简化tracker，storage的启动。编写脚本文件，把要执行的命令放到
一个单独的文件中，并设置该文件为可执行&lt;/p&gt;

&lt;h3 id=&quot;报错处理&quot;&gt;报错处理：&lt;/h3&gt;

&lt;p&gt;fdfs_monitor /etc/fdfs/client.conf 命令查看storage的状态是offline正常为active&lt;/p&gt;

&lt;p&gt;fdfs_monitor /etc/fdfs/client.conf delete group1 storage的IP地址。 #先在tracker上删除storage的信息&lt;/p&gt;</content><author><name>Xiao Wen</name></author><summary type="html">FastDFS：是一个开源的轻量级分布式文件系统，由跟踪服务器（tracker server）、存储服务器（storage server）和客户端（client）三个部分组成， 主要解决了海量数据存储问题</summary></entry><entry><title type="html">Keepalived+Nginx安装笔记</title><link href="http://hsly-xiaowen.github.io/2020/03/02/equip-Nginx-Ngin-Installation-Notes/" rel="alternate" type="text/html" title="Keepalived+Nginx安装笔记" /><published>2020-03-02T00:00:00+08:00</published><updated>2020-03-02T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/02/equip-Nginx-Ngin%20Installation%20Notes</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/02/equip-Nginx-Ngin-Installation-Notes/">&lt;p&gt;使用nginx实现负载均衡，使用Keepalived搭建高可用nginx集群&lt;/p&gt;

&lt;h2 id=&quot;nginx安装步骤&quot;&gt;Nginx安装步骤&lt;/h2&gt;
&lt;p&gt;1、前置环境安装
安装gcc&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install -y gcc-c++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装pcre 是用正则表达式库，http需要使用pcre解析正则表达式&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install -y pcre prce-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装zlib zlib提供多种压缩方式，nginx使用的zlib对http内容进行压缩&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install -y zlib zlib-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装openSSL 安全套接字层密码库&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;yum install -y openssl opensll-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2、 安装Nginx
下载nginx安装包&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://nginx.org/download/nginx-1.9.14.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;解压nginx安装包&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tar -zxvf nginx-1.9.14.tar.gz
cd nginx-1.9.14 进入nginx解压文件
./configure --prefix=/usr/local/nginx  运行解压文件下的configure文件安装
                                   --prefix安装文件前缀，文件安装目录下
make       编译 （make的过程是把各种语言写的源码文件，变成可执行文件和各种库文件）
make install 安装 （make install是把这些编译出来的可执行文件和库文件复制到合适的地方）
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;启动nginx&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;安装目录下/sbin/nginx 启动nginx
安装目录下/sbin/nginx -s reload 重启nginx
安装目录下/sbin/nginx -s stop   关闭nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;配置nginx
安装目录下/conf/nginx/conf&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;http {
include       mime.types;
default_type  application/octet-stream;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;
//配置负载均衡点，指定的ip集合负载均衡提高服务
upstream tomcats{
  server 118.89.29.12:88 weight=2;
  server 118.89.29.12:90;
}

server {
    //监听端口
    listen       80;
//服务器名称
    server_name  localhost;
   
    location / {
        proxy_pass  http://tomcats;//反向代理，由该指定的ip提高服务
    index  index.html index.htm;//初始化界面
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;keepalived:1 定时检查nginx是否在使用
           2 虚拟出一个ip地址共多台nginx服务器使用，达到高可用作用
	     一台为master，一台为backup 一台宕机另一台顶上&lt;/p&gt;

&lt;p&gt;基于centos7.3安装keepalived
keepalived源码文件下载：http://www.keepalived.org/software/keepalived-1.2.20.tar.gz&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://www.keepalived.org/software/keepalived-1.2.20.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;1 解压文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tar -zxvf keepalived-1.2.20.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2 进入解压文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd keepalived-1.2.20
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3 执行文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./configure --prefix=/usr/local/keepalived/ 指定安装程序位置
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4 编译与安装&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;make &amp;amp;&amp;amp; make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装完成，进行相关配置
创建文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir /etc/keepalived/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;拷贝文件：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf
cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/rc.d/init.d/keepalived
cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;编写-nginx-状态检测脚本&quot;&gt;编写 Nginx 状态检测脚本&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  /etc/keepalived/nginx_check.sh
  !/bin/bash
  A=`ps -C nginx ὀ~Sno-header |wc -l`
  if [ $A -eq 0 ];then
      /usr/local/nginx/sbin/nginx #nginx启动文件的位置
      sleep 2
  if [ `ps -C nginx --no-header |wc -l` -eq 0 ];then
    killall keepalived
     fi
  fi
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;修改etckeepalivedkeepalivedconf&quot;&gt;修改/etc/keepalived/keepalived.conf&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; global_defs {
  router_id 118.89.29.12
 }
 vrrp_script chk_nginx {
 script &quot;/etc/keepalived/nginx_check.sh&quot;
 interval 2
 weight -20
}
vrrp_instance VI_1 {
     state MASTER #主nginx配置master ，从nginx服务器配置为backup
     interface eth0#网卡位置，eth0/eth1/eth2
     virtual_router_id 11 #任意给，主从nginx服务器该值要保持一致
     mcast_src_ip 118.89.29.12 #本机ip地址，公网地址
     priority 100 #优先级
     advert_int 1
     authentication {
  auth_type PASS
  auth_pass 1111
 }
track_script {
  chk_nginx #nginx检测脚本信息
}
virtual_ipaddress {
  118.89.29.12 #keepalived虚拟出来的ip地址，必须同一网段下有效
   }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;keepalived命令&quot;&gt;keepalived命令&lt;/h2&gt;
&lt;p&gt;启动keepalived&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl start keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;关闭keepalived&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl stop keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;重启keepalived&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl restart keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;设置为开机自启&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;systemctl enable keepalived
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;注意启动keepalived时候会检测nginx是否启动如果没有启动就自动启动nginx&quot;&gt;注意：启动keepalived时候会检测nginx是否启动，如果没有启动就自动启动nginx&lt;/h4&gt;</content><author><name>Xiao Wen</name></author><summary type="html">使用nginx实现负载均衡，使用Keepalived搭建高可用nginx集群</summary></entry><entry><title type="html">Redis安装笔记</title><link href="http://hsly-xiaowen.github.io/2020/03/02/equip-Redis-Redis-Installation-Notes/" rel="alternate" type="text/html" title="Redis安装笔记" /><published>2020-03-02T00:00:00+08:00</published><updated>2020-03-02T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/03/02/equip-Redis-Redis%20Installation%20Notes</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/03/02/equip-Redis-Redis-Installation-Notes/">&lt;h2 id=&quot;redis安装使用&quot;&gt;Redis安装使用&lt;/h2&gt;
&lt;p&gt;Redis安装使用&lt;/p&gt;

&lt;p&gt;1 下载安装包（出现wget命令不存在时:安装wget，yum install wget）&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget http://download.redis.io/releases/redis-4.0.6.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2 解压安装包&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;tar -zxvf redis-4.0.6.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3 进入解压文件&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd redis-4.0.6 4 编译安装文件：

make

make指令执行失败的时，安装配置环境：yum -y install gcc gcc-c++ libstdc++-devel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;redis配置成服务启动：&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; vim /usr/lib/systemd/system/redis.service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;添加一下内容&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Description=Redis
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/redis/redis-4.0.6/src/redis-server /usr/local/redis/redis-4.0.6/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID 
ExecStop=/bin/kill -s QUIT $MAINPID 
PrivateTmp=true
 
 [Install]
 WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;启动redis&quot;&gt;启动redis：&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/redis-4.0.6/src/redis-server 以守护线程的方式启动（保护当前进程，不能进行其他操作）
/redis-4.0.6/src/reids-cli    打开redis客户端
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;远程访问linux需要修改redis的配置文件&quot;&gt;远程访问linux需要修改redis的配置文件&lt;/h3&gt;

&lt;p&gt;1 打开redis端口，端口在redis.conf文件查看&lt;/p&gt;

&lt;p&gt;2 注释掉redis.conf里面的bind 127.0.0.1&lt;/p&gt;

&lt;p&gt;3 必须设置密码 打redis.conf 把requiredpass 注释去掉并后面加上密码&lt;/p&gt;

&lt;p&gt;4 启动redis时后面跟上redis.conf配置文件&lt;/p&gt;

&lt;p&gt;redis操作指令&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;http://www.redis.net.cn/order
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;flushall 清空redis内的所有键值对&lt;/p&gt;

&lt;p&gt;redis性能测试:redis自带了性能测试&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;在redis../src/执行./redis-benchmark -n 1000 1000表示要操作的数据量
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Xiao Wen</name></author><summary type="html">Redis安装使用 Redis安装使用</summary></entry><entry><title type="html">SARA期间的模糊记忆</title><link href="http://hsly-xiaowen.github.io/2020/02/04/equip-Diary-SARS-Memory/" rel="alternate" type="text/html" title="SARA期间的模糊记忆" /><published>2020-02-04T00:00:00+08:00</published><updated>2020-02-04T00:00:00+08:00</updated><id>http://hsly-xiaowen.github.io/2020/02/04/equip-Diary-SARS%20Memory</id><content type="html" xml:base="http://hsly-xiaowen.github.io/2020/02/04/equip-Diary-SARS-Memory/">&lt;p&gt;庚子年伊始，武汉新型冠状病毒席卷全国，愿灾难早日过去。闲来无事，把儿时SARS相关模糊的记忆记录下来。
已经是17年的事了，模糊且零散。&lt;/p&gt;

&lt;h2 id=&quot;sars杂记&quot;&gt;SARS杂记&lt;/h2&gt;
&lt;p&gt;03年的时候我还小，对非典有些许模糊的记忆。
  那年我8岁了，在上小学。那时候的校门口的黑板上还是八荣八耻。因为非典的缘故，学校i进行了封闭式管理，但是只对进出校门的非学员进行体温检测。对学生而言就是往日敞开的校门变成的紧闭了，有种囚禁的感觉，那个时候也不懂。
日常的课间打也只能在内操场进行了。对儿时的影响甚微
  让我最为影响深刻的是家中挤鸭的处理，那个时候认为鸡鸭可能携带病毒并大量的捕杀活埋。为了保存家中的鸡鸭。我与母亲天天把鸡鸭藏东藏西。
那年是印象中唯一一次白雪皑皑的，非典的疫情让本有的喜悦戛然而止。ba&lt;/p&gt;</content><author><name>Xiao Wen</name></author><summary type="html">庚子年伊始，武汉新型冠状病毒席卷全国，愿灾难早日过去。闲来无事，把儿时SARS相关模糊的记忆记录下来。 已经是17年的事了，模糊且零散。</summary></entry></feed>