本帖最后由 ltz 于 2015-8-31 14:38 编辑
我在hdfs-site.xml 中设置dfs.ha.fencing.methods的值如下所示:<property>
<!-- sshfence,shell -->
<name>dfs.ha.fencing.methods</name>
<value>shell(/usr/local/testsh/hashell.sh)</value>
</property>
问题出现,重启 主节点 namenode后,当前服务节点状态可以由active切换到standby,但并未执行/usr/local/testsh/hashell.sh中的内容,请帮忙分析下原因,谢谢!
hashell.sh
[mw_shl_code=python,true]#!/bin/bash
`python notify_email.py`
/bin/true[/mw_shl_code]
notify_email.py 如下:
[mw_shl_code=python,true]#!/usr/bin/env python
#coding: utf-8
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.MIMEImage import MIMEImage
from email.header import Header
import sys
import smtplib
import socket
smtp_user ='liu.tz@qq.com'
strFrom = 'liu.tz@qq.com'
strTo = ['ll@163.com','liu.tz@qq.com']
smtp_server='smtp.exmail.qq.com'
smtp_pass='1234'
cur_hostname = socket.getfqdn(socket.gethostname())
cur_hostaddr = socket.gethostbyname(cur_hostname)
mail_title='[info]Hadoop HA Warning '
mail_body_plain='Hadoop HA has a change,please check !'
mail_body_html='<b><font color=red>'+'Warning!\n['+cur_hostname+':'+cur_hostaddr+'] \t namenode change! </font></b>'
msgRoot = MIMEMultipart('related')
msgRoot['Subject'] =Header(mail_title,'utf-8')
msgRoot['From'] = strFrom
#msgRoot['To'] = strTo
msgRoot['To'] = ",".join(strTo)
msgAlternative = MIMEMultipart('alternative')
msgRoot.attach(msgAlternative)
msgText = MIMEText(mail_body_plain, 'plain', 'utf-8')
msgAlternative.attach(msgText)
msgText = MIMEText(mail_body_html, 'html','utf-8')
msgAlternative.attach(msgText)
smtp = smtplib.SMTP()
smtp.connect(smtp_server)
smtp.login(smtp_user,smtp_pass)
smtp.sendmail(strFrom, strTo, msgRoot.as_string())
smtp.quit()[/mw_shl_code]
|