http://pan.baidu.com/s/1bnyVnSb
DevOps
http://pan.baidu.com/s/1bnyVnSb
查看配置:
查看使用情况:
Qcache_free_blocks: 表示查询缓存中目前还有多少剩余的blocks,如果该值显示较大,则说明查询缓存中的内存碎片过多了,可能在一定的时间进行整理
Qcache_free_memory: 查询缓存的内存大小,通过这个参数可以很清晰的知道当前系统的查询内存是否够用,是多了,还是不够用,DBA可以根据实际情况做出调整
Qcache_hits: 命中多少
Qcache_inserts: 写入多少
Qcache_lowmem_prunes: 空间不够,挤出多少 (?)
Qcache_not_cached: 有多少查询因不符合条件而没有被写入cache (如:结果集太大、sql条件中使用了函数、select 1等等)
Qcache_queries_in_cache: 当前缓存了多少查询
Qcache_total_blocks: 当前缓存的block数量
参考:
参考: https://www.myssl.cn/products/
使用chrome浏览器测试:(更新:好像现在都不显示为绿色了)
2. 访问 https://www.beebank.com/ 地址栏显示锁,不显示公司名称,绿色说明页面中没有引用非https的资源
3. 访问 https://login.sina.com.cn/ 下面是已登录状态, 没有 锁,也不显示公司名称,(说明页面中包含了非https的资源)
未登录状态: 显示 锁, 不显示公司名称 (奇怪不?)
https证书有DV,EV
DV 免费SSL证书(DV KuaiSSL)属于 Domain Validation SSL 或 DV SSL。是 WoSign 基础级 (Class 1) SSL证书产品,只验证域名所有权, 10分钟颁发,保证了网站的机密信息从用户浏览器到服务器之间的传输是高强度加密传输的,是不会被非法窃取和非法篡改的。
从 SSL 证书的诞生史可以看出:标准型 SSL 证书就是 Organization Validation SSL(OV SSL) , DV SSL 证书是由于市场恶性竞争而形成的怪胎产品,已经严重伤害了用户对电子商务的在线信任 ( 有安全锁都不可信! ) 。
为了解决 DV SSL 被欺诈网站滥用的问题, Comodo 牵头全球各大证书颁发机构和各大主流浏览器厂商成立了一个 CA/浏览器论坛,推出了一个新的 SSL 证书产品来增强电子商务用户的在线信任和保证在线交易的安全,这就是 Extended Validation SSL Certificate, 简称为: EV SSL 证书。 EV SSL 证书采用全球统一严格验证身份标准来颁发 SSL 证书,不仅能像其他 OV SSL 证书一样能高强度加密在线用户的机密交易信息,而且还会非常显著地 ( 浏览器地址栏为绿色 ) 向在线用户表明他们 / 她们确实是正在与一个经过严格身份验证的网站进行在线交易,而不是一个假冒网站。 EV SSL 让浏览器地址栏变成绿色,绿色安全通道,增强在线信任,打造诚信网络,促成更多在线销售!
所以,推荐所有电子商务网站都部署 OV SSL 证书或 EV SSL 证书,特别推荐 EV SSL ,绿色地址栏,让用户更加信任您的网站,从而获得更多在线订单。
赛门铁克的EV证书还附带有每日网站而已软件扫描服务
难道EV类型不提供通配符证书?
关于单域名ssl证书需要注意:
1、当您位 www 前缀的域名申请证书的时候,默认是可以保护不带 www 的主域名,例如您位 www.sslzhengshu.com 申请证书,则 sslzhengshu.com 也默认会被保护;
2、当您位其他前缀的子域名申请证书时,则只能保护当前子域名不能保护不带前缀的主域名。
https是一种加密传输协议,网站使用https后可以避免敏感信息被第三方获取。所以我们经常看见很多银行网站或电子邮箱等等安全级别较高的服务都会采用https协议,具体表现为,https开头、显示绿色安全锁、某些浏览器地址栏变成绿色。那么具体https是怎么工作的呢?一张图读懂https加密协议。
https加密协议简介
https其实是有两部分组成:http + SSL / TLS,也就是在http上又加了一层处理加密信息的模块。服务端和客户端的信息传输都会通过TLS进行加密,所以传输的数据都是加密后的数据。具体是如何进行加密,解密,验证的,且看下图。
1. 客户端发起https请求
客户端发起https请求就是指用户在浏览器里输入一个https网址,然后连接到server的443端口。
2. 服务器端的配置
采用https协议的服务器必须要有一套SSL数字证书,需要向CA组织(如WoSign沃通CA)申请。这套SSL证书其实就是一对公钥和私钥。如果对公钥和私钥不太理解,可以想象成一把钥匙和一个锁头,只是全世界只有你一个人有这把钥匙,你可以把锁头给别人,别人可以用这个锁把重要的东西锁起来,然后发给你,因为只有你一个人有这把钥匙,所以只有你才能看到被这把锁锁起来的东西。SSL证书是网站实现https加密协议的先决条件,可以向CA机构申请免费SSL证书,也可以付费购买高级别的SSL证书。目前沃通CA提供3年期免费SSL证书申请http://freessl.wosign.com。
3. 传送证书
这个证书其实就是公钥,只是包含了很多信息,如证书的颁发机构,证书过期时间等等。
4. 客户端解析证书
这部分工作是有客户端的TLS来完成的,首先会验证公钥是否有效,比如颁发机构,过期时间等等,如果发现异常,则会弹出一个警告框,提示证书存在问题。如果证书没有问题,那么就生成一个随机值。然后用证书对该随机值进行加密。就好像上面说的,把随机值用锁头锁起来,这样除非有钥匙,不然看不到被锁住的内容。
5. 传送加密信息
这部分传送的是用SSL证书加密后的随机值,目的就是让服务端得到这个随机值,以后客户端和服务端的通信就可以通过这个随机值来进行加密解密了。
6. 服务段解密信息
服务端用私钥解密后,得到了客户端传过来的随机值(私钥),然后把内容通过该值进行对称加密。所谓对称加密就是,将信息和私钥通过某种算法混合在一起,这样除非知道私钥,不然无法获取内容,而正好客户端和服务端都知道这个私钥,所以只要加密算法够彪悍,私钥够复杂,数据就够安全。
7. 传输加密后的信息
这部分信息是服务段用私钥加密后的信息,可以在客户端被还原。
8. 客户端解密信息
客户端用之前生成的私钥解密服务段传过来的信息,于是获取了解密后的内容。整个过程第三方即使监听到了数据,也束手无策。
来自: http://freessl.wosign.com/https-xy.html (文章不错,也顺便给人家做个广告吧)
问题: 30个虚拟机一下子全死光光了,而且/var/log/message 中没有任何遗言;莫不是被攻击了?
不要瞎猜,查一下吧
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# dmesg |grep "Out of" Out of memory: Kill process 1732 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1290 (portreserve) score 1 or sacrifice child Out of memory: Kill process 1297 (rsyslogd) score 1 or sacrifice child Out of memory: Kill process 1336 (dbus-daemon) score 1 or sacrifice child Out of memory: Kill process 1350 (modem-manager) score 1 or sacrifice child Out of memory: Kill process 28704 (mysqld) score 22 or sacrifice child Out of memory: Kill process 31695 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1040 (mysqld) score 22 or sacrifice child Out of memory: Kill process 21474 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1371 (hald) score 1 or sacrifice child Out of memory: Kill process 1407 (hald-addon-rfki) score 1 or sacrifice child Out of memory: Kill process 1431 (hald-addon-inpu) score 1 or sacrifice child Out of memory: Kill process 1435 (hald-addon-acpi) score 1 or sacrifice child Out of memory: Kill process 1528 (mysqld_safe) score 1 or sacrifice child Out of memory: Kill process 23326 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1779 (crond) score 1 or sacrifice child Out of memory: Kill process 28153 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1845 (login) score 1 or sacrifice child Out of memory: Kill process 28247 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1847 (mingetty) score 1 or sacrifice child Out of memory: Kill process 1849 (mingetty) score 1 or sacrifice child Out of memory: Kill process 1851 (mingetty) score 1 or sacrifice child Out of memory: Kill process 28367 (mysqld) score 22 or sacrifice child Out of memory: Kill process 28431 (mysqld) score 22 or sacrifice child Out of memory: Kill process 1853 (mingetty) score 1 or sacrifice child Out of memory: Kill process 1855 (mingetty) score 1 or sacrifice child Out of memory: Kill process 2060 (VBoxXPCOMIPCD) score 1 or sacrifice child Out of memory: Kill process 2066 (VBoxSVC) score 1 or sacrifice child |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
#ifdef LINUX_OOM_ADJUST /* * The magic "don't kill me" values, old and new, as documented in eg: * http://lxr.linux.no/#linux+v2.6.32/Documentation/filesystems/proc.txt * http://lxr.linux.no/#linux+v2.6.36/Documentation/filesystems/proc.txt */ static int oom_adj_save = INT_MIN; static char *oom_adj_path = NULL; struct { char *path; int value; } oom_adjust[] = { {"/proc/self/oom_score_adj", -1000}, /* kernels >= 2.6.36 */ {"/proc/self/oom_adj", -17}, /* kernels <= 2.6.35 */ {NULL, 0}, }; /* * Tell the kernel's out-of-memory killer to avoid sshd. * Returns the previous oom_adj value or zero. */ void oom_adjust_setup(void) { int i, value; FILE *fp; debug3("%s", __func__); for (i = 0; oom_adjust[i].path != NULL; i++) { oom_adj_path = oom_adjust[i].path; value = oom_adjust[i].value; if ((fp = fopen(oom_adj_path, "r+")) != NULL) { if (fscanf(fp, "%d", &oom_adj_save) != 1) verbose("error reading %s: %s", oom_adj_path, strerror(errno)); else { rewind(fp); if (fprintf(fp, "%d\n", value) <= 0) verbose("error writing %s: %s", oom_adj_path, strerror(errno)); else debug("Set %s from %d to %d", oom_adj_path, oom_adj_save, value); } fclose(fp); return; } } oom_adj_path = NULL; } /* Restore the saved OOM adjustment */ void oom_adjust_restore(void) { FILE *fp; debug3("%s", __func__); if (oom_adj_save == INT_MIN || oom_adj_path == NULL || (fp = fopen(oom_adj_path, "w")) == NULL) return; if (fprintf(fp, "%d\n", oom_adj_save) <= 0) verbose("error writing %s: %s", oom_adj_path, strerror(errno)); else debug("Set %s to %d", oom_adj_path, oom_adj_save); fclose(fp); return; } #endif /* LINUX_OOM_ADJUST */ |
参考资料: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
题记:是否输出居然和是否和行尾换行有关系
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
package main /* #include <stdio.h> #include <stdlib.h> void myprint(char* s) { printf("%s", s); } */ import "C" import "unsafe" func main() { cs := C.CString("Hello world\n") //把这里的 \n 去掉试试,居然没有输出了 C.myprint(cs) C.free(unsafe.Pointer(cs)) } |
why? …
因为printf是行缓冲的,不看到换行就不输出,可以在printf后面刷新标准输出:
1 |
fflush(stdout); |
另,在C的printf后面使用Go的fmt.Println(“^_^”)来输出一些东西,是不是就可以把C要打印的东西给输出来了呢?
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
package main /* #include <stdio.h> #include <stdlib.h> void myprint(char* s) { printf("%s", s); } */ import "C" import "unsafe" import "fmt" func main() { cs := C.CString("Hello world") C.myprint(cs) C.free(unsafe.Pointer(cs)) fmt.Println("\nEnd\n") } |
结果发现,End 输出了,Hello world还是没输出。
原因:C的输出buffer和Go的不是一个
思考:
亲,你见过用C写的一个Hello world程序是必须有换行的吗?如下:
呃,这个确实没问题,why? C在退出的时候刷新输出缓冲了呗
说明:
To access a symbol originating from the C side, use the package name C
. That is, if you want to call the C function printf()
from Go code, you write C.printf()
. Since variable argument methods like printf aren’t supported yet (issue 975)
翻译:如果你想调用C中的printf,那就是 C.printf(). 但是,向pringf这种可变参数个数的函数穿残还没有被支持,所以还不能直接写C.printf(). 只好自己包一下了
缘起:
yum安装了libvirt后,机器上就多了一块(虚拟)网卡:virbr0,ifdown没法控制这个家伙,怎么干掉呢?
1 |
virsh net-destroy default |
virsh是libvirt-client包中的命令,为什么是default?
1 |
/usr/bin/virsh net-list |
参考: http://www.cyberciti.biz/faq/linux-kvm-disable-virbr0-nat-interface/
环境:
mysql数据库表设置字符集为utf8;console终端显示字符集为utf8;如下:
mysql 命令查询的结果显示都是“问号”,解决办法:
1 |
set character_set_results=utf8; |
缘起:
曾经在nginx(1.7.4)两个地方配置过unix socket;一个是nginx日志,一个是fastcgi;但是,这两个地方有所不同。
关于日志的配置,通过unix socket (/dev/log) 写到本地的syslogd,如果syslogd重启了,则/dev/log 其实是被更新了的,但是nginx却不会自动重连,然后nginx就写log失败了。 如此,重启syslogd就得重启nginx,是多么“2”的一件事情啊!
关于fastcgi的配置,通过unix socket访问本地的php-fpm,如果php-fpm重启,则 unix socket不更新,自然影响不到nignx; 如果fpm stop then start,则unix socket会更新,但是,nginx却知道自动重连,也不会影响到nginx。(难道是因为该socket走的是stream的原因?)
注: 如果你不小心将socket文件配到了/tmp 下面,则socket文件可能是660的权限,nginx(用户如果和php-fpm不同)可能就没有权限连接该unix socket
问题: 默认情况下,nginx会自动failover,即: 其中一个上游服务器处理失败时会自动将请求转发到下一个上游服务器;有些情况下是不期望如此的;
但是这里没有区分上游服务器的失败原因,如果是连接失败,则自动fail_over 基本是没问题的;如果是已经发送了数据然后等待响应超时失败,可能并不想fail_over
避免failover的办法:
如果把 proxy_next_upstream 写到fastcgi_pass 中是不会有效果的,虽然不会报错
可能在应用层来避免重复处理才是正道