最近csf 在用csf -u更新的时候,总是会收到报警邮件,说 Protocol scheme ‘https’ is not supported (IO::Socket::SSL not installed)
解决方案很简单,对于RPM based 的系统,
sudo yum install perl-Crypt-SSLeay
对于APT based的系统
sudo apt-get install libcrypt-ssleay-perl
最近csf 在用csf -u更新的时候,总是会收到报警邮件,说 Protocol scheme ‘https’ is not supported (IO::Socket::SSL not installed)
解决方案很简单,对于RPM based 的系统,
sudo yum install perl-Crypt-SSLeay
对于APT based的系统
sudo apt-get install libcrypt-ssleay-perl
很多网络问题都跟路由有关,那么首先必须学会看懂路由表,本文将讲述如何读懂路由及如何决策.
在命令行下输入route -n 或 netstat -rn,就可以打印本机的路由表,我的如下:
Destination Gateway Netmask Flags Metric Ref Use Iface
192.168.161.0 192.168.161.1 255.255.255.0 UG 0 0 0 em1
192.168.161.0 0.0.0.0 255.255.255.0 U 0 0 0 em1
192.168.61.0 0.0.0.0 255.255.255.0 U 0 0 0 em2
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 em1
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 em2
192.168.0.0 192.168.61.1 255.255.0.0 UG 0 0 0 em2
0.0.0.0 192.168.61.1 0.0.0.0 UG 0 0 0 em2
0.0.0.0 192.168.161.1 0.0.0.0 UG 0 0 0 em1
PS:我的电脑是双网卡,分别在192.168.61.0和192.168.161.0两个网段
————————————————–
1 字段解释
Destination 目的网段,最长匹配192.168.161.0 > 192.168.0.0 > 0.0.0.0,0可匹配任意数值
Gateway 所走网关,0.0.0.0表示无网关,即与本机IP同一网段,不需要经过网关(同一个局域网内2台主机通信不需要经过网关)
Genmask 掩码
Flags 标志,U – Up表示有效
G – Gateway表示连接路由,若无这个字段表示直连目的地址
H – Host表示目标是具体主机,而不是网段
2 路由匹配
路由表的作用就是指定下一级网关,那么根据路由表怎么确定下一级网关,这里就有一个匹配过程,匹配规则
*(1)优先级匹配(暂不讨论)
*(2)最长匹配
3 实例讲解
还是针对上面的路由表,为了方便表述,加上条目号字段
条目号 Destination Gateway Genmask Flags Metric Ref Use Iface
1 192.168.161.0 192.168.161.1 255.255.255.0 UG 0 0 0 em1
2 192.168.161.0 0.0.0.0 255.255.255.0 U 0 0 0 em1
3 192.168.61.0 0.0.0.0 255.255.255.0 U 0 0 0 em2
4 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 em1
5 169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 em2
6 192.168.0.0 192.168.61.1 255.255.0.0 UG 0 0 0 em2
7 0.0.0.0 192.168.61.1 0.0.0.0 UG 0 0 0 em2
8 0.0.0.0 192.168.161.1 0.0.0.0 UG 0 0 0 em1
192.168.61.35 – 匹配条目3,即不需要经过网关
192.168.60.150 – 匹配条目6,需要经过网关192.168.60.1
www.baidu.com – 匹配条目7,这里需要说明下为何不匹配8?这是我实践的结果,后加的默认网关会在列表前面,即优先匹配。这个规则应该用于所有Destination一致的情况
192.168.161.113 – 匹配条目1,不是匹配条目2
家里的Win 2016 Server datacenter KMS 激活马上就要到期了,这才想起来KMS 的命令早就忘的一干二净…哎。。。这里做个记录,以后也好查找
KMS 只适用于VL 版本,不适用于旗舰版
一般来说,只要确保的下载的是VL批量版本并且没有手动安装过任何key, 你只需要使用管理员权限运行cmd执行一句命令就足够:
slmgr /skms you.ip.address.or.domain
然后去计算机属性或者控制面板其他的什么的地方点一下激活就好了。
在老的centos 6 和 debian 7 中,monit 是通过对 pid 的监控来判断程序是否die 或者有问题的, 但是在 centos 7 和 debian 8 和debian 9下,只要service 不是以forking 的形式启动,systemd 就不会让service 创建 pid file,即使你在service 的配置文件中创建了 PidFile 的命令,这个命令是会被忽略的
因为在由systemd 控制的linux 系统中,monit 无法通过pid 的形式来监控程序,在这里我们就需要用到monit 的的match 命令,比如说nginx 来可以match ‘nginx’, 来完成对nginx 的监控
守护进程是在后台运行不受终端控制的进程(如输入、输出等),一般的网络服务都是以守护进程的方式运行。守护进程脱离终端的主要原因有两点:(1)用来启动守护进程的终端在启动守护进程之后,需要执行其他任务。(2)(如其他用户登录该终端后,以前的守护进程的错误信息不应出现)由终端上的一些键所产生的信号(如中断信号),不应对以前从该终端上启动的任何守护进程造成影响。要注意守护进程与后台运行程序(即加&启动的程序)的区别。
我是一个很老套的人,一直在坚持使用centos 6 和 debian 7,但是无奈很多软件已经取消了对centos 6 和debian 8 的支持,现在只能加班加点开始适应debian 8 和 centos 7.
在centos 6 和debian 7中,脚本一直使用的是/etc/init.d/xxx, 在系统升级到Centos 7 和 Debian 8后,虽然以前的启动脚本仍然可以使用,但是在centos 7 和 debian8中, 系统的service 已经由sysvinit 转向了systemd,进而也有了很多的变化
CentOS 7 集成了 RHEL 7 的新特性,systemd的使用也大幅提高了系统服务的运行效率,同时也变的简单而易用了许多.
Unit 的文件位置,一般主要有三个目录:
/lib/systemd/system
/run/systemd/system
/etc/systemd/system
这三个目录的配置文件优先级一次从低到高,如果同意选项三个地方都配置了,优先级高的会覆盖优先级低的.
对于第三方或者自己定义的service 来说,我们一般放在/etc/systemd/service下面。
这是新开的一台DNS 的服务器,正好拿来测试比较一下
Benchmark started on Mon Jul 17 13:19:13 UTC 2017 Full benchmark log: /root/bench.log System Info ----------- Processor : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz CPU Cores : 1 Frequency : 2799.988 MHz Memory : 988 MB Swap : MB Uptime : 7 min, OS : \S Arch : x86_64 (64 Bit) Kernel : 4.9.15-x86_64-linode81 Hostname : xx.xxxx.xxx Speedtest (IPv4 only) --------------------- Your public IPv4 is 162.xx.xx.xxx Location Provider Speed CDN Cachefly 105MB/s Atlanta, GA, US Coloat 49.0MB/s Dallas, TX, US Softlayer 27.7MB/s Seattle, WA, US Softlayer 18.8MB/s San Jose, CA, US Softlayer 12.4MB/s Washington, DC, US Softlayer 50.1MB/s Tokyo, Japan Linode 10.9MB/s Singapore Softlayer 3.64MB/s Rotterdam, Netherlands id3.net 6.50MB/s Haarlem, Netherlands Leaseweb 73.5MB/s Disk Speed ---------- I/O (1st run) : 210 MB/s I/O (2nd run) : 611 MB/s I/O (3rd run) : 607 MB/s Average I/O : 476 MB/s
NFS 可以把NFS server 上的文件及文件共享给NFS client 服务器
两个概念,NFS Server(Master) 和 NFS Client
NFS Server 可以把本服务器上的文件和文件夹共享给NFS Client, NFS Client 可以在共享的文件和文件夹上进行读写操作,并且实时返回给NFS Master
NFS Server 一般作为存储服务器,常见为使用RAID 5 和 RAID 10 的存储服务器,容量比较大. 对于一些图片站和网盘站点,网站所在的服务器一般为NFS Client,NFS Client 把图片和文件直接存储在NFS Server上
为了方便对NFS进行user id 和 group id 进行统一管理,我们一般需要NFS Server 和 NFS Client 使用同一种操作系统, 比如说centos 和 centos. 当然了,分别使用不同的操作系统,比如说centos 和 debian 也是可以的,就是有点麻烦而已.
下面进行详细的安装步骤:
无论是CentOS 6 和 CentOS 7, 安装步骤基本都一致,这里推荐CentOS 7. RHEL系的操作系统越新越好用
服务器配置:
NFS Server Hostname: server.unixmen.local NFS Server IP Address: 192.168.1.101/24
NFS Client Hostname: client.unixmen.local NFS Client IP Address: 192.168.1.102/24
NFS服务器端配置:
CentOS 6:
yum install nfs-utils nfs-utils-lib chkconfig nfs on service rpcbind start service nfs start
CentOS 7:
yum install nfs-utils nfs-utils-lib systemctl enable rpcbind systemctl enable nfs-server systemctl enable nfs-lock systemctl enable nfs-idmap systemctl start rpcbind systemctl start nfs-server systemctl start nfs-lock systemctl start nfs-idmap
因为CentOS 7 在系统上改了好多,所以安装稍微有点不同,其实都是同一个库
下面配置共享目录,假设我们需要共享/home 目录给client
vi /etc/exports
然后添加下面:
/home 192.168.0.102 (rw,sync,no_root_squash,no_subtree_check)
参数的解释:
rw: 这个选项允许client server 在共享目录上进行读和写的操作
ro: 只读
sync: 将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
no_root_squash: 登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!
root_squash: 在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者,通常他的 UID 与 GID 都会变成 nobody 那个系统账号的身份
all_squash: 将远程访问的所有普通用户及所属组都映射为匿名用户或用户组 (nfsnobody)
no_all_squash: 与all_squash 相反, 默认配置
anonuid=xxx: 将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx);
anongid=xxx: 将远程访问的所有用户组都映射为匿名用户组账户,并指定该匿名用户组账户为本地用户组账户(GID=xxx);
这里需要注意的, NFS 进行映射的时候,用的是uid 和 gid, 而非是用户名和group 的名字. 所以通常的做法是, 在NFS server 和 NFS client 上使用相同的用户名和用户组,以及相同UID和 GID
相同的用户名和用户组这个好解决, UID 和 GID不同的话,需要update uid 和 gid以使他们相同. 在centos 上我们经常使用军哥的lnmp,用户名和用户组都为www,加入uid 为501, gid 为501, 则我们可以用
(rw, sync, no_subtree_check, all_squash, anonuid=501, anongid=501)
async: 将数据先保存在内存缓冲区中,必要时才写入磁盘;
subtree: 若输出目录是一个子目录,则nfs服务器将检查其父目录的权限(默认设置);
no_subtree:即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;
配置完成以后,我们需要export这个配置来时他生效:
exportfs -a
下面我们需要配置NFS Client
安装NFS:
yum install nfs-utils nfs-utils-lib
mount 共享目录给 /home
mount -t nfs 192.168.1.101:/home /home
然后我们就可以通过df -h 看到mount 的目录或者mount 来查看
如果需要开机启动时自动mount,我们需要编辑/etc/fstab
192.168.1.101:/home /home nfs rw,sync,hard,intr 0 0
移除NFS mount
umount /home
最近把mysql 升级到了5.7.18 然后就发现了一个很明显的变化, ONLY_FULL_GROUP_BY 这个mysql mode 被加了进来, 按照sql 99 的标准这是好事.
但是实际上, mysql 的这个版本只能说almost identical or very close to, 不能说完全相等
简单的说,就是
That is, MySQL 5.7.5m15 will by default reject only those GROUP BY-queries that include non-aggregated expressions in the SELECT-list that are not functionally dependent upon the GROUP BY-list. This not only means that you cannot mess up your GROUP BY-queries anymore (as MySQL will now reject an improper GROUP BY query), it will also not require you to write non-sensical "dummy" aggregates over expressions that can only have one value per aggregated result row. Hurrah!
详细的解释请看这篇文章:
http://rpbouman.blogspot.nl/2014/09/mysql-575-group-by-respects-functional.html
这是无意中在stackoverflow上看到的,以前还真没有注意到.
Question:
I was trying to block an ip of ( network stresser tool – a ddos websites selling ddos bots by seconds online ) the first one i was trying to block with iptables :
iptables -A INPUT -d 173.193.26.73 -j DROP iptables -A INPUT -s 173.193.26.73 -j DROP however i still see the ip and bandwidth still up on iftop. also still see the ip going on tcpdump.
is that normal? what’s the problem in here?
Answer:
Yes, it’s normal. iptables doesn’t stop inbound traffic turning up on your physical interface, thus notching up your iftop counts, and it doesn’t stop the kernel seeing that it’s there, hence the tcpdump output. It does, however, stop the kernel passing the traffic on to anything that might be listening for it.
If you see any output traffic in response to those input packets, something’s wrong. But otherwise, no, that’s normal.
iptables 工作在5个链上, prerouting, input, forward, output, postrouting
prerouting 和 postrouting 一般是在NAT上使用,所以traffic 会流经CPU,也即是说iptables 无法阻止真实网卡的流入流量, 因此itfop 和 tcpdump 都能看到流入的流量,但是在用iptables block了这个IP的情况下,是不会有流出的流量的.