• 获取active nn并替换hue.ini


    namenodelists="nnip1,nnip2"
    nn1=$(echo $namenodelists | cut -d "," -f 1)
    nn2=$(echo $namenodelists | cut -d "," -f 2)
    nn1state=$(curl "http://$nn1:50070/jmx?qry=Hadoop:service=NameNode,name=NameNodeStatus"|grep -c active)
    nn2state=$(curl "http://$nn2:50070/jmx?qry=Hadoop:service=NameNode,name=NameNodeStatus"|grep -c active)
    
    source /etc/profile
    source /root/.profile
    curr_nn=$(grep -Po -m1 "http://(.*):50070" /usr/share/hue/desktop/conf/hue.ini |cut -d ':' -f 2|cut -d "/" -f 3)
    echo $curr_nn
    if [ $nn1state -eq 1 ]; then
    activenn=$nn1
       if [ "X$curr_nn" != "X$activenn" ]; then 
           echo "nn change, now active is $activenn"
           sed -i "s|fs_defaultfs=.*|webhdfs_url=http://$activenn:50070/webhdfs/v1|" /usr/share/hue/desktop/conf/hue.ini 
           sed -i "s|webhdfs_url=.*|webhdfs_url=http://$activenn:50070/webhdfs/v1|" /usr/share/hue/desktop/conf/hue.ini
           ps -ef|grep hue |grep -v grep |awk '{print $2}' |xargs kill -9 2>/dev/null
           /usr/bin/nohup /usr/share/hue/build/env/bin/hue runserver 0.0.0.0:8888 > /usr/share/hue/hue.log 2>&1 &
       fi
    fi
    if [ $nn2state -eq 1 ]; then
    activenn=$nn2
       if [ "X$curr_nn" != "X$activenn" ]; then 
           echo "nn change, now active is $activenn"
           sed -i "s|fs_defaultfs=.*|webhdfs_url=http://$activenn:50070/webhdfs/v1|" /usr/share/hue/desktop/conf/hue.ini 
           sed -i "s|webhdfs_url=.*|webhdfs_url=http://$activenn:50070/webhdfs/v1|" /usr/share/hue/desktop/conf/hue.ini
           ps -ef|grep hue |grep -v grep |awk '{print $2}' |xargs kill -9 2>/dev/null
           /usr/bin/nohup /usr/share/hue/build/env/bin/hue runserver 0.0.0.0:8888 > /usr/share/hue/hue.log 2>&1 &
       fi
    fi
    #start it if not start 
    live=`ps -ef|grep runserver|grep -v -c grep`
    if [ $live -eq 0 ];  then
    /usr/bin/nohup /usr/share/hue/build/env/bin/python2.7 /usr/share/hue/build/env/bin/hue runserver 0.0.0.0:8888 2>&1 &
    fi

    当前使用hdp3.1,安装namenode ha,配置hue使用的时候需要安装httpfs,但这个版本的httpfs是空的包,安装后很多目录都没有,不能用,

    所以采用了上面的方法,配置一个crontab * * * * * /xxx.sh 一分钟检查一次,如果active nn和配置文件中的active nn不一致,则就更新配置,

    然后重启hue.

    遇到的一个问题是配置在crontab 中不会把hue拉起来,测了很久发现`` $()有问题,改成``的方式是可以的。

    上网查找相关的内容,也没有得到很好的解析,有一种说法是``中的内容本身就是经过转义的(和此也 无关的)

  • 相关阅读:
    sql server 2000 “因为选定的用户拥有对象,所以无法除去该用户。”问题(含图说明)
    关于datalength函数,解决ntext等无法比较空值的问题
    Analysis service的manager无法连接,不能连接服务器(xxxxx)注册表,或者还不是olap Administrator组成员
    数据库查询问题int型字段对应以Int型数值+','组成的nvarchar型字段
    Asp与Asp.net共用cookie
    什么是SPSS
    TransactSQL语言提供的日期和时间函数(以备后用)
    关于sql语句的执行效率测试
    sqlserver数据仓库学习第一课(含资料)
    理解collate Chinese_PRC_CI_AS NULL
  • 原文地址:https://www.cnblogs.com/huaxiaoyao/p/11220667.html
Copyright © 2020-2023  润新知