1 #!/bin/bash 2 case $1 in 3 "start") 4 echo "————————————启动 hadoop 集群————————" 5 ssh hadoop106 "/opt/module/hadoop/sbin/start-dfs.sh" 6 ssh hadoop107 "/opt/module/hadoop/sbin/start-yarn.sh" 7 ;; 8 "stop") 9 echo "—————————关闭 Hadoop 集群———————————" 10 ssh hadoop106 "/opt/module/hadoop/sbin/stop-dfs.sh" 11 ssh hadoop107 "/opt/module/hadoop/sbin/stop-yarn.sh" 12 ;; 13 esac
在 /opt/module/hadoop/etc/hadoop/hadoop-env.sh 里添加
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root