>

美洲杯在线投注_2019美洲杯外围投注[投注官网]

热门关键词: 美洲杯在线投注,2019美洲杯外围投注[投注官网]

RHEL6.0 csync2双向同步

- 编辑:美洲杯在线投注 -

RHEL6.0 csync2双向同步

系统环境:RHEL6.0 iptables and selinux off
server1: server26.example.com
server2:desktop26.example.com

####Nagios部署(一) #####1) 安装准备

---->安装必要的软件(每台server上执行类似操作)
yum install gcc-* libgpg-error libgpg-error-devel libgcrypt-devel -y

系统:redhat7.1(监控端)、centos6.5(被监控端)

####按顺序安装一下源码
tar -zxf   librsync-0.9.7.tar.gz
cd librsync-0.9.7
./configure
make
make install

软件:nagios-cn-3.2.3.tar.bz2、gd-devel-2.0.35-26.el7.x86_64.rpm、nagios-plugins-2.1.1.tar.gz | 主机名 | IP地址 | 角色 | | ------------------| -------------- |-------------------| | host.mystudy.com | 192.168.1.183 | 监控端 | | chunlin | 139.199.181.155| 被监控端1(远程) | | client5 | 192.168.1222.15| 被监控端2(同网段)| 防火墙:关闭 SELinux:Disabled 时间:保持同步

tar -zxf  sqlite-2.8.17.tar.gz
cd sqlite-2.8.17
./configure
make
make install

#####2) 安装nagios

tar -zxf libgpg-error-1.7.tar.gz
cd libgpg-error-1.7
./configure
make
make install

[root@host ~]# yum install -y httpd [root@host ~]# yum install -y gd-devel-2.0.35-26.el7.x86_64.rpm [root@host ~]# mkdir /usr/local/nagios [root@host ~]# useradd -s /sbin/nologin nagios [root@host ~]# groupadd nagcmd #使外部操作能够在Web界面上提交 root@host ~]# usermod -aG nagcmd nagios root@host ~]# usermod -aG nagcmd apache

[root@host nagios]# tar -jxf nagios-cn-3.2.3.tar.bz2 [root@host nagios-cn-3.2.3]# ./configure
--with-command-group=nagcmd --prefix=/usr/local/nagios [root@host nagios-cn-3.2.3]# make all [root@host nagios-cn-3.2.3]# make install [root@host nagios-cn-3.2.3]# make install-init #创建Nagios启动脚本 [root@host nagios-cn-3.2.3]# make install-config #安装Nagios示例配置文件 [root@host nagios-cn-3.2.3]# make install-commandmode #配置目录权限 [root@host nagios-cn-3.2.3]# make install-webconf #创建/etc/httpd/conf.d/nagios.conf [root@host nagios-cn-3.2.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin #创建Nagios的Web界面登录账号和密码 [root@host nagios-cn-3.2.3]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg #检查Nagios配置文件正确性 [root@host etc]# systemctl restart httpd [root@host etc]# systemctl start nagios #在浏览器中输入http://localhost/nagios/即可看到Web监控界面 #####3) 安装nagios-plugin

[root@client5 nagios-plugins-2.2.0]# yum install -y
perl-ExtUtils-MakeMaker [root@host nagios]# yum install -y openssl-devel [root@host nagios]# yum install -y mariadb-devel [root@host nagios]# tar -zxf nagios-plugins-2.2.0.tar.gz [root@host nagios-plugins-2.2.0]# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-extra-opts --enable-libtap --enable-perl-modules

tar -zxf   libgcrypt-1.4.4.tar.gz
cd libgcrypt-1.4.4
./configure
make
make install

configure过程的输出结果如下: 篮球世界杯在线投注 1

tar -jxf gnutls-2.6.6.tar.bz2
cd gnutls-2.6.6
./configure
make
make install

#支持mysql监控、支持SSL加密、支持extra-opts、perl-modules、libtap

tar -zxf libtasn1-2.1.tar.gz
cd libtasn1-2.1
./configure
make
make install

[root@host nagios-plugins-2.2.0]# make [root@host nagios-plugins-2.2.0]# make install

echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig /usr/local/lib        #使上面导入生效

#####4) 配置监控实例

####安装此软件,编辑inotify的触发脚本,实现实时同步
tar -zxf inotify-tools-3.13.tar.gz
cd inotify-tools-3.13
./configure
make
make install

  • 本地监控:

####配置csync2安装环境
yum install byacc flex -y
tar -zxf csync2-1.34.tar.gz
cd csync2-1.34
./configure
make
make install
make cert
csync2 -k /etc/csync2.key            #生成key速度比较慢,可移动鼠标加快

[root@host ~]# cd /usr/local/nagios/etc/objects [root@host objects]# cp -p localhost.cfg hosts.cfg [root@host objects]# cp -p localhost.cfg services.cfg [root@host objects]# vim ../nagios.cfg #cfg_file处添加如下两行: cfg_file=/usr/local/nagios/etc/objects/hosts.cfg cfg_file=/usr/local/nagios/etc/objects/services.cfg #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg #将localhost.cfg这一项注释掉 [root@host objects]# vim hosts.cfg

scp /etc/csync2*  server26:/etc/          #将一台服务器生成的key直接同步到另一台服务器

define host{
     use                     linux-server
     host_name               host.mystudy.com
     alias                   Manager
     address                 127.0.0.1
     icon_image              server.gif
     statusmap_image         server.gd2
     2d_coords               500,200
     3d_coords               500,200,200
     }
define hostgroup{
     hostgroup_name  linux-servers 
     alias           Linux Servers
     members         *   
    }

####配置csync2
yum install xinetd -y

#定义主机和主机组 [root@host objects]# vim services.cfg

cp /etc/xinetd.d/rsync /etc/xinetd.d/csync2
vim /etc/xinetd.d/csync2
service rsync
{
        disable              = no
        protocol           = tcp
        flags                  = REUSE
        socket_type     = stream
        wait                   = no
        user                   = root
        group                = root
        server               = /usr/local/sbin/csync2
        server_args      = -i
}

define servicegroup{
      servicegroup_name Local_Check
      alias Load_Check
      members host.mystudy.com,local_disk,host.mystudy.com,local_user_login,host.mystudy.com,local_load,host.mystudy.com,local_swap,host.mystudy.com,local_process,host.mystudy.com,PING
    }

####配置csync2服务端口
vim /etc/services
csync2                 30865/tcp

#定义资源组和资源,资源的定义默认都给出了就不在这一一列出了

mkdir /opt/csync       #创建同步目录

  • 远程监控:

####编辑csync2配置文件
vim /etc/csync2.cfg
group mygroup
{
         host    desktop26.example.com  server26.example.com    #host后只能写主机名
         #host host4@host4-eth2;
  
         key  /etc/csync2.key;
         #include /var/www/html;                 #默认同步的目录
         include /opt/csync;                            #指定新建目录为同步目录,两台server上同步目录的名称和路径一样
         #include %/homedir%/bob;
         #exclude %homedir%/bob/temp    #不同步指定目录下的文件或目录
         #exclude *~.*;                                   #排除以点开头的文件
      
         #action
         #{
             # pattern /etc/apache/httpd.conf
             # pattern /etc/apache/sites-available/*;   
             # exec "/usr/sbin/apache2ctl graceful"
             # logfile "/var/log/csync2_action.log";
             # do-local;
         #}
 
        backup-directory /var/csync2;           #防选错备份目录,根据自己的需求设置,每台主机都有
        back-generation 3;

[root@host objects]# vim hosts.cfg # 新增如下主机定义

        auto younger;                                      #同步以最新的文件为标准更新
 
        #prefix  homedir
        #{
               #on host[12]:/export/users;
               #on*:      /home;
        #}
}

define host{
    use                     linux-server
    host_name               chunlin
    alias                   Web
    address                 139.199.181.155
    icon_image              server.gif
    statusmap_image         server.gd2
    2d_coords               500,100
    3d_coords               500,100,200
    }

篮球世界杯在线投注,/etc/init.d/xinetd restart
chkconfig xinetd on
netstat -antlp                     #csync2端口是否被监听
tcp       0       0 :::30865            :::*                       LISTEN            2896/xinetd

  • check_mysql

####(可选)配置inotify触发脚本(需安装inotify-tools-3.13.tar.gz)
vim /use/local/sbin/csync2.sh
#!/bin/sh
src=/opt/csync        #指定同步目录
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f'  
--exclude ".swp$"    
-e close_write,modify,delete,create,attrib    
${src}   
| while read file
do
csync2 -x > /dev/null 2>&1     #没有参数v在界面不显示详细
#csync2 -xv
#echo "${src} was csynced...."
done

[root@host objects]# vim commands.cfg

chmod x /usr/loca/sbin/csync2.sh
csync2.sh &        #每台主机上执行

define command{
    command_name    check_mysql
    command_line    $USER1$/check_mysql -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -d $ARG3$
    }

本文由计算机教程发布,转载请注明来源:RHEL6.0 csync2双向同步