linux中一键启动和关闭hadoop和yarn和hive的完整的Shell脚本
时间: 2023-05-29 17:04:40 浏览: 298
下面是一个基本的Shell脚本,可以一键启动和关闭Hadoop、YARN和Hive:
启动脚本:
```
#!/bin/bash
# Start Hadoop
echo "Starting Hadoop..."
start-all.sh
# Start YARN
echo "Starting YARN..."
start-yarn.sh
# Start Hive
echo "Starting Hive..."
hive --service hiveserver2 &
```
关闭脚本:
```
#!/bin/bash
# Stop Hive
echo "Stopping Hive..."
hive --service hiveserver2 --stop
# Stop YARN
echo "Stopping YARN..."
stop-yarn.sh
# Stop Hadoop
echo "Stopping Hadoop..."
stop-all.sh
```
这些脚本需要在Hadoop的bin目录下运行。注意,这些脚本假设您的Hadoop和Hive配置正确,并且已经启动。如果您需要更改脚本以适应您的环境,请确保您知道在何处更改它们。
相关问题
linux中一键启动和关闭hadoop\yarn\hive的Shell脚本
启动hadoop:
```
#!/bin/bash
# Start Hadoop daemons
$HADOOP_HOME/sbin/start-dfs.sh
$HADOOP_HOME/sbin/start-yarn.sh
# Start Hadoop services
$HADOOP_HOME/bin/hdfs dfsadmin -safemode leave
$HADOOP_HOME/bin/hdfs dfs -mkdir /tmp
$HADOOP_HOME/bin/hdfs dfs -mkdir /user
$HADOOP_HOME/bin/hdfs dfs -mkdir /user/hadoop
$HADOOP_HOME/bin/hdfs dfs -chmod 777 /tmp
$HADOOP_HOME/bin/hdfs dfs -chmod 777 /user/hadoop
$HADOOP_HOME/bin/hdfs dfs -chmod 777 /user/hadoop/*
$HADOOP_HOME/bin/yarn app -list
```
关闭hadoop:
```
#!/bin/bash
# Stop Hadoop daemons
$HADOOP_HOME/sbin/stop-dfs.sh
$HADOOP_HOME/sbin/stop-yarn.sh
```
启动hive:
```
#!/bin/bash
# Start Hive service
$HIVE_HOME/bin/hive --service metastore &
$HIVE_HOME/bin/hive --service hiveserver2 &
```
关闭hive:
```
#!/bin/bash
# Stop Hive service
$HIVE_HOME/bin/hive --service metastore -stop
$HIVE_HOME/bin/hive --service hiveserver2 -stop
```
inux中一键启动和关闭hadoop yarn hive的Shell脚本
启动Hadoop YARN和Hive的Shell脚本:
```
#!/bin/bash
# Start Hadoop YARN and Hive
echo "Starting Hadoop YARN and Hive..."
# Start Hadoop YARN
echo "Starting Hadoop YARN..."
start-yarn.sh
# Start Hive
echo "Starting Hive..."
hive --service hiveserver2 &
echo "Hadoop YARN and Hive started successfully."
```
关闭Hadoop YARN和Hive的Shell脚本:
```
#!/bin/bash
# Stop Hadoop YARN and Hive
echo "Stopping Hadoop YARN and Hive..."
# Stop Hive
echo "Stopping Hive..."
hive --service hiveserver2 --hiveconf hive.metastore.schema.verification=false --hiveconf hive.server2.enable.doAs=false --hiveconf hive.cli.print.header=false -e "shutdown;"
# Stop Hadoop YARN
echo "Stopping Hadoop YARN..."
stop-yarn.sh
echo "Hadoop YARN and Hive stopped successfully."
```
注意:在关闭Hive之前,需要使用Hive命令关闭HiveServer2。同时,还需要添加一些额外的参数来避免出现错误。
阅读全文