excel数据对比—–查找两列(表)的相同数据

http://xueli.blog.51cto.com/3325186/920592

excel数据对比—–查找两列(表)的相同数据

数据少的列放在A,数据多的放在B
在C1上执行 =IF(COUNTIF(A:A,B1)=1,”1″,”N/A”)
即拿B1跟A列做对比,如果相同的个数为1,则显示1,否则就显示N/A

VLOOKUP(B1,A:A,1,0)
在A列搜索与B相同的值,搜索到的话就返回A列的数字。

Smokeping

参考

https://czero000.github.io/2015/12/20/install-smokeping.html

http://blog.coocla.org/smokeping-slave.html

yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel libidn libidn-devel httpd httpd-devel apr-util-devel apr-devel perl perl-Net-Telnet perl-Net-DNS perl-LDAP perl-libwww-perl perl-RadiusPerl perl-IO-Socket-SSL perl-Socket6 perl-CGI-SpeedyCGI perl-FCGI perl-CGI-SpeedCGI perl-Time-HiRes perl-ExtUtils-MakeMaker perl-RRD-Simple rrdtool rrdtool-perl curl fping echoping httpd httpd-devel gcc make wget libxml2-devel libpng-devel glib pango pango-devel freetype freetype-devel fontconfig cairo cairo-devel libart_lgpl libart_lgpl-devel mod_fastcgi -y

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
tar -zxf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
./configure –prefix=/usr/local/rrdtool
make && make install

/usr/local/rrdtool/bin/rrdtool
RRDtool 1.4.7 Copyright 1997-2012 by Tobias Oetiker
Compiled May 21 2013 13:42:05

Usage: rrdtool [options] command command_options
Valid commands: create, update, updatev, graph, graphv, dump, restore,
last, lastupdate, first, info, fetch, tune,
resize, xport, flushcached

RRDtool is distributed under the Terms of the GNU General
Public License Version 2. (www.gnu.org/copyleft/gpl.html)

For more information read the RRD manpages

需要注意
1. 防火墙
2. selinux
3. 后端程序是否启动,否则没曲线

nginx 代理和cache

nginx代理和cache

代理
[root@jack03 conf.d]# cat default.conf
#
# The default server
#

upstream web01 {
server 10.21.252.18:80;
keepalive 2000;
}

server {
listen 80 default_server;
server_name 10.21.252.20;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location / {
proxy_pass http://web01/;
proxy_set_header Host $host:$server_port;

}

error_page 404 /404.html;
location = /40x.html {
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
}

}

这样,访问10.21.252.20的时候,会访问到10.21.252.18

NGINX作为Cache服务器时将资源内容以文件形式进行缓存,缓存元信息存储于共享内存中,组织成一棵红黑树。红黑树中的每个节点代表一个Cache元信息。NGINX将Cache Key的HASH值作为红黑树节点的KEY。内容缓存文件以该HASH值作为文件名存储在磁盘上。

cache设置

nginx.conf 设置
在http的设置中,添加
proxy_buffering on;
proxy_cache_path /data levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=10g;

在default.conf中添加

location / {
proxy_pass http://web01/;
proxy_set_header Host $host:$server_port;

# proxy_redirect off;
# proxy_set_header Host $host;
proxy_cache cache_one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 301 1d;
proxy_cache_valid any 1m;
expires 30d;
}

这样,访问10.21.252.20的时候,文件会给缓存在/data目录下

wordpress 提示建立数据库连接时出错 但是在服务器上可以连上数据库

<?php
$link = mysql_connect('数据库服务器地址', '数据库用户名', '数据库密码');
if (!$link) {
       die('WordPress中文网提醒您,不能链接数据库: ' . mysql_error());
}
echo 'WordPress中文网提示:连接数据库成功!';
mysql_close($link);
?>

WordPress中文网提醒您,不能链接数据库: /var/lib/mysql/mysql.sock
修改my.cnf
[mysqld]
bind-address = 10.0.97.90
port = 3306
#socket = /tmp/mysql.sock
socket = /var/lib/mysql/mysql.sock
重启mysql,恢复正常

高可用haproxy+keepalived(三)

实现后端web检测,需要修改haproxy.cfg文件,加上检测

backend honidmaster
        server ms01 192.168.1.92:80  maxconn 700
        server ms02 192.168.1.93:80  maxconn 700
改成
backend honidmaster
        server ms01 10.0.97.92:80  check port 80 maxconn 700
        server ms02 10.0.97.93:80  check port 80 maxconn 700

通过监听端口进行健康检测 。这种检测方式,haproxy只会去检查后端server的端口,并不能保证服务的真正可用。(不推荐)
具体可以参考 http://www.jianshu.com/p/eb4d07ff1189

也可以检测状态码

        http-check expect status 200
        server web01 10.0.97.92:80 check maxconn 700
        server web02 10.0.97.93:80 check maxconn 700

或者更多

# only accept status 200 as valid
http-check expect status 200

# consider SQL errors as errors
http-check expect ! string SQL\ Error

# consider status 5xx only as errors
http-check expect ! rstatus ^5

# check that we have a correct hexadecimal tag before /html
http-check expect rstring <!--tag:[0-9a-f]*</html>

https://cbonte.github.io/haproxy-dconv/configuration-1.4.html#1.3

高可用haproxy+keepalived(二)

上一篇写了haproxy+keepalived,这边文章将写keepalived的高可用

首先,创建一个脚本 checkha.sh

# cat /tmp/checkha.sh
#!/bin/bash
count=`ps aux | grep -v grep | grep haproxy | wc -l`
echo $count
if [ $count -eq 1 ]; then
   echo "is work"
else
    echo "is not work"
    /etc/init.d/keepalived stop
fi

keepalived判断haproxy进程,如果进程不在,就自动把keepalived服务停掉,这样Vip就会漂移到另外一台机器上. 也就是从90漂移到91

同时,keepalived.conf也需要修改

keepalived.conf

! Configuration File for keepalived

global_defs {
   notification_email {
   jack.zou@jingle.cn
   }
   notification_email_from jackzou19@163.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_script checkhaproxy {
    script "/tmp/checkha.sh"
    interval 2
    weight  -10
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    192.168.1.136
    }
    track_script {
        checkhaproxy
    }
}

首先是添加了
vrrp_script checkhaproxy {
script “/tmp/checkha.sh”
interval 2
weight -10
}

其次在instance里添加了
track_script {
checkhaproxy
}

这样,就达到了效果.当你把haproxy停掉后,keepalived会自动的停掉,这样,Vip漂移到91上面.
当90的haproxy和keepalived起来后,Vip会漂移回90

我觉得在这种情况下,91是不需要做这个判断的. 因为默认的master会接管Vip
除非你将state都设置为Backup,然后在90那台设置参数nopreempt.这样,当90恢复后,是不会自动接管的.这个就有必要在91也设置一个检查脚本,当发现异常的时候,将keepavlied停掉,然后90才会接管Vip

高可用haproxy+keepalived(一)

首先是haproxy,在192.168.1.90和91上分别安装haproxy和设置haproxy.cfg

[root@node0190 keepalived]# cat /etc/haproxy/haproxy.cfg
global
        log /dev/log    local0
        log /dev/log    local1 notice
        user haproxy
        group haproxy
        daemon
        maxconn 100000
        spread-checks 5
        pidfile /etc/haproxy/logs/haproxy.pid
defaults
        log     global
        mode    http
        balance roundrobin
       contimeout 5000
       clitimeout 50000
       srvtimeout 50000
       option abortonclose
                 option httpclose
                 option forwardfor
frontend http-in
        bind *:10001
       option forwardfor except 127.0.0.1
       option http-server-close
       option httplog
       option dontlognull
       #option redispatch
       monitor-uri /hamon # Returns 200 if it's up
        #capture request header Host len 500
       #capture request header Content-Length len 500
        #capture request header Referer len 500
        default_backend honidmaster
        maxconn 100000

backend honidmaster
        server ms01 192.168.1.92:80  maxconn 700
        server ms02 192.168.1.93:80  maxconn 700

listen stats :1936
        mode http
       stats enable
       stats uri /
       stats realm Haproxy\ Statistics
       stats auth admin:admin

访问192.168.1.90或者91,正确的话可以轮询到92和93的web上.

现在,来设置keepalived,通过一个Vip来访问. Vip为 192.168.1.136
90作为keepalived的master,91作为backup

90设置

# cat keepalived.conf
! Configuration File for keepalived

global_defs {
   notification_email {
   jack.zou@jingle.cn
   }
   notification_email_from jackzou19@163.com
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    192.168.1.136
    }

91的设置就是将state MASTER 改成state BACKUP,将priority 100改成99

ip -o -f inet addr show #查看IP
ip -f inet addr delete 192.168.1.136/32 dev eth0 #删除Vip
/sbin/ifconfig tunl0 180.97.80.136 broadcast 180.97.80.136 netmask 255.255.255.0 up

/sbin/ifconfig tunl0 180.97.80.136 broadcast 180.97.80.136 netmask 255.255.255.0 down #这种down的方式是不行的,ifconfig 看不到Vip了,但是ip -o -f inet addr show还是能查看到的,需要通过ip -f inet addr delete 192.168.1.136/32 dev eth0 #删除Vip

经测试,同时开启90和91,Vip在90上面. 如果stop 90的keepalived,136的IP会漂移到91上面,期间web访问不受影响
如果90的keepalived恢复,IP会漂移回来,期间web访问不受影响

OK,达到了haproxy高可用的目的,那么还有2点要测试
1. 后端web出故障了,haproxy自动剔除
2. keepalived自动检测异常后切换keepalived的服务. 上面测试是我手动启动keepalived来测试效果的.比如90的haproxy出问题了,keepalived应该将Vip漂移到91上面,继续提供web服务.

一次性批量修改密码

#!/bin/bash
#jackzou
echo > /tmp/a.log
ip="
ip1
ip2
"
for i in $ip
do
    echo $i >>/tmp/a.log
    ps=`date +%s | sha256sum | base64 | head -c 32 ; echo`
    echo $ps>>/tmp/a.log
    sshpass -p '123456'  ssh root@$i "echo root:$ps| chpasswd"
    sleep 1
done

ip1,ip2 初始密码为123456,现在修改一个随机的密码并保存在a.log里边.

fedora24 安装搜狗输入法

#Install fcitx
yum install fcitx

#下载 搜狗输入法 for Linux v1.1.0.0037

http://pinyin.sogou.com/linux/

firo@f downloads$ mkdir s;cd s
firo@f s$ cp ../sogou_pinyin_linux_1.1.0.0037_amd64.deb .
firo@f s$ ar vx sogou_pinyin_linux_1.1.0.0037_amd64.deb
x – debian-binary
x – control.tar.gz
x – data.tar.xz

#安装搜狗输入法
firo@f s$ sudo tar -Jxvf data.tar.xz -C /

#用sogou的库!
sudo cp /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/

#这步之前忘记写了
yum install dpkg

切换到fcitx即可. 在fedora24测试成功
参考 http://blog.chinaunix.net/uid-23851468-id-4215194.html

em改成eth

# cp –preserve=context /etc/grub.conf /etc/grub.bak
1. Add biosdevname=0 to the kernel boot arguments in /etc/grub.conf.

[root@lvs-02 ~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sdc2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sdc
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS 6 (2.6.32-573.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-573.el6.x86_64 ro root=UUID=2fc718d1-a706-4c3d-97f3-fddd63ae5b0d rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM biosdevname=0 rhgb quiet
    initrd /initramfs-2.6.32-573.el6.x86_64.img

2. Rename /etc/sysconfig/network-scripts/ifcfg-em1 to /etc/sysconfig/network-scripts/ifcfg-eth0, changing the line
DEVICE=”em1″
to
DEVICE=”eth0″
3. Delete /etc/udev/rules.d/70-persistent-net.rules
4. Reboot.