一、GIT 学习与整理

1、 git log –stat  可以看到每次提交都修改了哪些文件
   有时候查看的时候需要显示全路径 git log –stat-name-width=100
2、 git show  06b91520bc66715415315165b892d187c066659f  filename  可以看到每次具体做了哪些修改
3、 merge操作一般从本地分枝merge到master分枝之后 再提交到远端master
   如

4、在同一台机器可以直接pull对方的代码如  git pull /home/user/code master


二、关于 tcp_timestamps和tcp_tw_recycle 导致TCP连接有问题

RFC1323中有如下一段描述:

An additional mechanism could be added tothe TCP,aper-host cache of the last timestamp received from any connection.Thisvalue could thenbe used inthe PAWS mechanism toreject old duplicate segments from earlier incarnations of the connection,ifthe timestamp clock can be guaranteed tohave ticked at least once since the old connection was open.Thiswould require that the TIME-WAIT delay plus the RTT together must be at least one tick of the senderstimestamp clock.Such an extension isnotpart of the proposal of thisRFC.

大概意思是说TCP有一种行为,可以缓存每个连接最新的时间戳,后续请求中如果时间戳小于缓存的时间戳,即视为无效,相应的数据包会被丢弃。


Linux是否启用这种行为取决于tcp_timestamps和tcp_tw_recycle,因为tcp_timestamps缺省就是开启的,所以当tcp_tw_recycle被开启后,实际上这种行为就被激活了。

现在很多公司都用LVS做负载均衡,通常是前面一台LVS,后面多台后端服务器,以NAT方式构建,当请求到达LVS后,它修改地址数据后便转发给后端服务器,但不会修改时间戳数据,对于后端服务器来说,请求的源地址就是LVS的地址,加上端口会复用,所以从后端服务器的角度看,原本不同客户端的请求经过LVS的转发,就可能会被认为是同一个连接,加之不同客户端的时间可能不一致,所以就会出现时间戳错乱的现象,于是后面的数据包就被丢弃了,具体的表现通常是是客户端明明发送的SYN,但服务端就是不响应ACK,还可以通过下面命令来确认数据包不断被丢弃的现象: