1 Star 0 Fork 31

xiexing/hadoop

forked from src-openEuler/hadoop 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hdfs-create-dirs 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
王歌 提交于 2021-05-13 10:10 . init package
#!/bin/bash
hdfs_dirs="/user /var/log /tmp"
mapred_dirs="/tmp/hadoop-yarn/staging /tmp/hadoop-yarn/staging/history /tmp/hadoop-yarn/staging/history/done /tmp/hadoop-yarn/staging/history/done_intermediate"
yarn_dirs="/tmp/hadoop-yarn /var/log/hadoop-yarn"
# Must be run as root
if [[ $EUID -ne 0 ]]
then
echo "This must be run as root" 1>&2
exit 1
fi
# Start the namenode if it isn't running
started=0
systemctl status hadoop-namenode > /dev/null 2>&1
rc=$?
if [[ $rc -gt 0 ]]
then
# Format the namenode if it hasn't been formatted
runuser hdfs -s /bin/bash /bin/bash -c "hdfs namenode -format -nonInteractive" > /dev/null 2>&1
if [[ $? -eq 0 ]]
then
echo "Formatted the Hadoop namenode"
fi
echo "Starting the Hadoop namenode"
systemctl start hadoop-namenode > /dev/null 2>&1
rc=$?
started=1
fi
if [[ $rc -ne 0 ]]
then
echo "The Hadoop namenode failed to start"
exit 1
fi
for dir in $hdfs_dirs $yarn_dirs $mapred_dirs
do
echo "Creating directory $dir"
runuser hdfs -s /bin/bash /bin/bash -c "hadoop fs -mkdir -p $dir" > /dev/null 2>&1
done
echo "Setting permissions on /tmp"
runuser hdfs -s /bin/bash /bin/bash -c "hadoop fs -chmod 1777 /tmp" > /dev/null 2>&1
for dir in $mapred_dirs
do
echo "Setting permissions and ownership for $dir"
runuser hdfs -s /bin/bash /bin/bash -c "hadoop fs -chown mapred:mapred $dir" > /dev/null 2>&1
runuser hdfs -s /bin/bash /bin/bash -c "hadoop fs -chmod 1777 $dir" > /dev/null 2>&1
done
for dir in $yarn_dirs
do
echo "Setting permissions and ownership for $dir"
runuser hdfs -s /bin/bash /bin/bash -c "hadoop fs -chown yarn:mapred $dir" > /dev/null 2>&1
done
# Stop the namenode if we started it
if [[ $started -gt 0 ]]
then
echo "Stopping the Hadoop namenode"
systemctl stop hadoop-namenode > /dev/null 2>&1
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xiexing01/hadoop.git
git@gitee.com:xiexing01/hadoop.git
xiexing01
hadoop
hadoop
master

搜索帮助