简体   繁体   中英

What is the proper way to stop hiveserver2?

I've installed hive 0.14 on top of hadoop 2.6.0.

The setup mainly involved just extracting the tar.bin file.

I followed this guide to do the setup.

http://www.ishaanguliani.com/content/hive-0140-setup-ubuntu

I start hiveserver2 with a command line:

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

Now, I am wondering what is the proper to stop hiveserver2. I can kill it but I doubt that provides a graceful exit.

write a small shell script to find hiveserver2 process and stop it. I used below shell script to stop hiveserver2 and hive metastore process. Hope this helps.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM