hadoop settings
阅读原文时间:2023年07月15日阅读:1

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH

source ~/.bashrc

sudo gedit /usr/local/hadoop/etc/hadoop/hadoop-env.sh

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

sudo gedit /usr/local/hadoop/etc/hadoop/core-site.xml

core-site.xml

    fs.default.name     hdfs://localhost:9000

sudo gedit /usr/local/hadoop/etc/hadoop/yarn-site.xml

    yarn.nodemanager.aux-services     mapreduce_shuffle
    yarn.nodemanager.aux-services.mapreduce.shuffle.class     org.apache.hadoop.mapred.ShuffleHandler

sudo cp /usr/local/hadoop/etc/hadoop/mapred-site.xml.template /usr/local/hadoop/etc/hadoop/mapred-site.xml

sudo gedit  /usr/local/hadoop/etc/hadoop/mapred-site.xml


    mapreduce.framework.name     yarn

sudo gedit  /usr/local/hadoop/etc/hadoop/hdfs-site.xml

    dfs.replication     3     dfs.nodename.name.dir     file:/usr/local/hadoop/hadoop_data/hdfs/namenode     dfs.nodename.data.dir     file:/usr/local/hadoop/hadoop_data/hdfs/datanode

sudo mkdir -p /usr/local/hadoop/hadoop_data/hdfs/namenode

sudo mkdir -p /usr/local/hadoop/hadoop_data/hdfs/datanode

sudo chown liqu -R /usr/local/hadoop

namenode无法启动

/usr/local/hadoop/hadoop-2.8.3/tmp/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.

从这入手,这是一个临时目录,在每次hadoop重启的时候都会删除,所以找不到

解决方法:

修改core-site.xml


hadoop.tmp.dir
file:///usr/local/hadoop/tmp

改成如下:

hadoop.tmp.dir
/usr/local/hadoop/tmp

所以,每次重启临时文件都会被清除

sudo gedit /etc/network/interfaces

interfaces 内容:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

#NAT interface
auto eth0
iface eth0 inet dhcp

#host only interface
auto eth1
iface eth1 inet static
address 192.168.56.101
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

sudo gedit /etc/hosts

127.0.0.1 localhost
127.0.1.1 liqu-VirtualBox

192.168.56.100 master
192.168.56.101 data1
192.168.56.102 data2
192.168.56.103 data3

data1中yarn -site.xml新增

yarn.resourcemanager.resource-tracker.address master:8025

yarn.resourcemanager.scheduler.address master:8030

yarn.resourcemanager.address master:8050