停止hiveserver2的正确方法是什么?

t3psigkw  于 2021-06-02  发布在  Hadoop
关注(0)|答案(2)|浏览(1006)

我已经在hadoop2.6.0之上安装了hive0.14。
设置主要涉及提取tar.bin文件。
我按照这个指南做了设置。
http://www.ishaanguliani.com/content/hive-0140-setup-ubuntu
我使用命令行启动hiveserver2:

( $HIVE_HOME/bin/hiveserver2 &> hiveserver.log & )

现在,我想知道停止hiveserver2的正确方法是什么。我可以杀了它,但我怀疑这是否提供了一个优雅的出口。

ih99xse1

ih99xse11#

$ sudo service hive-server2 stop

请参阅此链接:http://www.cloudera.com/documentation/archive/cdh/4-x/4-2-0/cdh4-installation-guide/cdh4ig_topic_18_8.html

eoigrqb6

eoigrqb62#

编写一个小的shell脚本来查找hiveserver2进程并停止它。我使用了below shell脚本来停止hiveserver2和hive metastore进程。希望这有帮助。

hive2_pid=`pgrep -f org.apache.hive.service.server.HiveServer2`

    if [[ -n "$hive2_pid" ]]
    then
        echo "Found hivesevrer2 PID-- "$hive2_pid
        kill $hive2_pid
        # if process is still around, use kill -9
        if ps -p $hive2_pid > /dev/null ; then
            echo "Initial kill failed, killing with -9 "
            kill -9 $hive2_pid
        fi
    echo "Hive server2 stopped successfully"
    else
        echo "Hiveserver2 process not found , HIveserver2 is not running !!!"
    fi

    meta_pid=`pgrep -f org.apache.hadoop.hive.metastore.HiveMetaStore`

    if [[ -n "$meta_pid" ]]
    then
        echo "Found hivesevrer2 PID-- "$meta_pid
        kill $meta_pid
        # if process is still around, use kill -9
        if ps -p $meta_pid > /dev/null ; then
            echo "Initial kill failed, killing with -9 "
            kill -9 $meta_pid
        fi
    echo "Hive metastore stopped successfully"
    else
        echo "Hive metastore process not found , Hive metastore is not running !!!"
    fi

相关问题