zoukankan      html  css  js  c++  java
  • CDH预警配置QQ邮箱

    一、 在QQ邮箱中开启POP

    屏幕快照 2019-04-29 23.25.19

    屏幕快照 2019-04-29 23.22.03


    二 、关闭主机的sendmail,开启postfix

    (本机若没有两个服务,就需要先安装)本地安装sendmail和postfix

    [root@Slave1 ~]#
    # yum -y install sendmail
    # yum -y install postfix
    
    //sendmail
    # service sendmial stop
    # chkconfig sendmail off
    
    //postfix
    # service postfix start
    # chkconfig postfix on
    

    三、创建证书文件

    # mkdir -p /root/.certs
    # echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
    # certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    # certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    # certutil -L -d /root/.certs
    
    # certutil -A -n "GeoTrush SSL CA - G6" -t "Pu,Pu,Pu" -d ./ -i qq.crt
    

    四、在/etc/mail.rc文件末尾添加一下内容

    set from=873505960@qq.com
    set smtp=smtp.qq.com
    set smtp-auth-user=873505960
    
    # 授权码
    set smtp-auth-password=yqbuiutisplabcdb
    set smtp-auth=login
    set smtp-use-starttls
    set ssl-verify=ignore
    set nss-config-dir=/root/.certs
    

    五、命令行验证邮件服务

    # echo Hi~~ | mail -s "ruozebigdata" 873505960@qq.com
    
    //查看邮件日志
    # tail -f /var/log/maillog
    

    六、shell脚本发送邮件:

    mail_noattachment.sh (不带附件)

    #!/bin/bash
    
    JOB_NAME="TEST"
    FROM_EMAIL="873505960@qq.com"
    TO_EMAIL="873505960@qq.com"
    
    RUNNINGNUM=1
    
    echo -e "`date "+%Y-%m-%d %H:%M:%S"` : The current running $JOB_NAME job num is $RUNNING in 192.168.1.100......" | mail -r "From: alertAdmin <${FROM_EMAIL}>" -s "Warn: Skip the new $JOB_NAME spark job." ${TO_EMAIL}
    

    mail_attachment.sh (带附件)

    #!/bin/bash
    
    FROM_EMAIL="873505960@qq.com"
    TO_EMAIL="873505960@qq.com"
    
    LOG=/root/shell/ruozebigdata.log
    
    echo -e "`date "+%Y-%m-%d %H:%M:%S"` : Please to check the fail sql attachement." | mailx -r "From: alertAdmin <${FROM_EMAIL}>" -a ${LOG} -s "Critical:DSHS fail sql." ${TO_EMAIL}
    

    屏幕快照 2019-04-30 00.30.24


    六、 CDH配置邮件,测试(待测试)

    1. 先单机Edit,输入873505960@qq.com,然后保存重启生效服务配置
    2. 再单击Send Test Alert

    在Liunx中查看邮件日志
    $ tail -F /var/log/cloudera-scm-alertpublicsher/mgmt-cmf-mgmt-ALERTPUBLISHER-hadoop35.log.out


    注意时区:

    1. 查看当前时区
      命令 : "date -R"
    2. 修改设置Linux服务器时区(Centos7.0)
      命令 : "tzselect"
    3. 复制相应的时区文件,替换系统时区文件;
      cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime



    发送一个html表格到qq邮箱中:

    table.html

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>My test page</title>
        </head>
        
        <body> 
    
            <table border="1">
                <tr>
                    <td>100</td>
                    <td>200</td>
                    <td>300</td>
                </tr>
                <tr>
                    <td>400</td>
                    <td>500</td>
                    <td>600</td>
                </tr>
            </table>
            
        </body>
    </html>
    

    mail_attachment.sh (带附件)

    #!/bin/bash
    
    FROM_EMAIL="873505960@qq.com"
    TO_EMAIL="873505960@qq.com"
    
    LOG=/root/shell/table.html
    
    echo -e "`date "+%Y-%m-%d %H:%M:%S"` : Please to check the fail sql attachement." | mailx -r "From: alertAdmin <${FROM_EMAIL}>" -a ${LOG} -s "Critical:DSHS fail sql." ${TO_EMAIL}
    
    $ chmod +x mail_attachment.sh
    $ ./mail_attachment.sh
    

    屏幕快照 2019-04-30 00.37.50

  • 相关阅读:
    document.body.clientHeight 和 document.documentElement.clientHeight 的区别
    Javascript操作div及其内含对象示例
    面向对象分析设计的经验原则
    翻页控件示例代码
    C#的6种常用集合类示例
    UML基础知识
    重温OSI和TCP/IP网络分层
    设计模式总结
    活用设计模式
    GridView当数据源为空时仍显示表头
  • 原文地址:https://www.cnblogs.com/suixingc/p/cdh-yu-jing-pei-zhiqq-you-xiang.html
Copyright © 2011-2022 走看看