通过脚本来启动/关闭presto的服务端和客户端服务
Posted Mr.zhou_Zxy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过脚本来启动/关闭presto的服务端和客户端服务相关的知识,希望对你有一定的参考价值。
通过脚本来启动/关闭presto的服务端和客户端服务
- 需求
使用一个脚本来启动presto的server和cli服务,并支持关闭server服务
启动presto命令:launcher start
关闭presto命令:launcher stop
开启客户端命令:resto --server 192.168.130.111:8080 --catalog hive --schema ods_news
当然可以这样直接启动是有条件的,需要配置presto的环境变量
- vim /etc/profile
export PRESTO_SERVER_HOME=/data/apps/presto-server-0.236
export PRESTO_CLI_HOME=/data/apps/presto-cli-0.236
export PATH=$PATH:$PRESTO_SERVER_HOME/bin:$PRESTO_CLI_HOME
- presto_server_cli.sh
#!/bin/bash
# filename:presto_server_cli.sh
# autho:zxy
# date:2021-07-19
# PRESTO的路径
PRESTO_SERVER_HOME=/data/apps/presto-server-0.236
PRESTO_CLI_HOME=/data/apps/presto-cli-0.236
# 接受参数
CMD=$1
## 帮助函数
usage() {
echo "usage:"
echo "presto_server_cli.sh server/cli/stop"
echo "description:"
echo " server:start presto_server"
echo " cli:start presto_cli"
echo " stop:stop presto_server"
exit 0
}
if [ ${CMD} == "server" ];then
# 启动presto的server服务
launcher start
ps -aux | grep PrestoServer
elif [ ${CMD} == "cli" ];then
# 启动presto的客户端
presto --server 192.168.130.111:8080 --catalog hive --schema ods_news
elif [ ${CMD} == "stop" ];then
# 关闭presto的server服务
launcher stop
ps -aux | grep PrestoServer
else
usage
fi
- 测试
[root@hadoop scripts]# sh presto_server_cli.sh server
Started as 8502
root 8502 0.0 0.1 5127308 14544 ? Ssl 17:08 0:00 java -cp /data/apps/presto-server-0.236/lib/* -server -Xmx3G -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -DHADOOP_USER_NAME=root -Dlog.output-file=/data/apps/presto-server-0.236/data/presto/var/log/server.log -Dnode.data-dir=/opt/apps/presto-server-0.236/data/presto -Dnode.id=hadoop -Dnode.environment=production -Dlog.enable-console=false -Dlog.levels-file=/data/apps/presto-server-0.236/etc/log.properties -Dconfig=/data/apps/presto-server-0.236/etc/config.properties com.facebook.presto.server.PrestoServer
root 8505 0.0 0.0 112728 960 pts/0 R+ 17:08 0:00 grep PrestoServer
[root@hadoop scripts]# jps
4161 ResourceManager
3684 DataNode
4277 NodeManager
3926 SecondaryNameNode
4742 RunJar
8502 PrestoServer
4743 RunJar
8535 Jps
3549 NameNode
[root@hadoop scripts]# sh presto_server_cli.sh cli
presto:ods_news> quit;
[root@hadoop scripts]# sh presto_server_cli.sh stop
Stopped 8502
root 8883 0.0 0.0 112728 960 pts/0 S+ 17:08 0:00 grep PrestoServer
[root@hadoop scripts]#
以上是关于通过脚本来启动/关闭presto的服务端和客户端服务的主要内容,如果未能解决你的问题,请参考以下文章