Hadoop HA 클 러 스 터 구축
본 튜 토리 얼 은 Hadoop HA 클 러 스 터 를 구축 하 는 데 사 용 됩 니 다. HA 클 러 스 터 에 대해 다음 과 같은 몇 가지 설명 이 있 습 니 다.
software
version
OS
CentOS-7-x86_64-DVD-1810.iso
Hadoop
hadoop-2.8.4
Zookeeper
zookeeper-3.4.10
시스템 설정
집단 역할 분배
node
actor
master1
NameNode、DFSZKFailoverController(zkfc)、ResourceManager
master2
NameNode、DFSZKFailoverController(zkfc)、ResourceManager
node1
DataNode、NodeManager、JournalNode、QuorumPeerMain
node2
DataNode、NodeManager、JournalNode、QuorumPeerMain
node3
DataNode、NodeManager、JournalNode、QuorumPeerMain
호스트 설정 [all]
192.168.56.101 node1
192.168.56.102 node2
192.168.56.103 node3
192.168.56.201 master1
192.168.56.202 master2
Hadoop 사용자 추가 [all]
useradd hadoop
passwd hadoop
chmod -v u+w /etc/sudoers
vi /etc/sudoers
hadoop ALL=(ALL) ALL
chmod -v u-w /etc/sudoers
호스트 이름 수정 [all]
hostnamectl set-hostname $hostname [master1|master2|node1|node2|node3]
systemctl reboot -i
비밀 로그 인 면제 [all]
ssh-keygen -t rsa
cat .ssh/id_rsa.pub >> .ssh/authorized_keys
scp .ssh/authorized_keys $next_node:~/.ssh/
sudo vi /etc/ssh/sshd_config
RSAAuthentication yes
StrictModes no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
systemctl restart sshd.service
방화벽 을 닫 고 사용 하지 않 기 [all]
sudo systemctl stop firewalld
sudo firewall-cmd --state
systemctl disable firewalld.service
보안 정책 [all]
vi /etc/selinux/config
SELINUX=disabled
소프트웨어 설치
JDK 설치 [all]
sudo mkdir -p /opt/env
sudo chown -R hadoop:hadoop /opt/env
tar -xvf jdk-8u121-linux-i586.tar.gz
sudo vi /etc/profile
export JAVA_HOME=/opt/env/jdk1.8.0_121
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
ZK 설치 [node 1 node 2 node 3]
sudo mkdir -p /opt/zookeeper
sudo chown -R hadoop:hadoop /opt/zookeeper
tar -zxvf /tmp/zookeeper-3.4.10.tar.gz -C /opt/zookeeper/
sudo chown -R hadoop:hadoop /opt/zookeeper
vi conf/zoo.cfg
dataDir=/opt/zookeeper/zookeeper-3.4.10/data
......
server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888
mkdir data
echo $zk_id [1|2|3] > data/myid
Hadoop 설치 [all]
sudo mkdir -p /opt/hadoop/data
sudo chown -R hadoop:hadoop /opt/hadoop/
tar -zxvf hadoop-2.8.4.tar.gz -C /opt/hadoop/
mkdir journaldata
Hadoop [all] 설정
vi core-site.xml
fs.defaultFS
hdfs://ns1/
hadoop.tmp.dir
/opt/hadoop/data
ha.zookeeper.quorum
node1:2181,node2:2181,node3:2181
ha.zookeeper.session-timeout.ms
3000
vi hdfs-site.xml
dfs.nameservices
ns1
dfs.ha.namenodes.ns1
nn1,nn2
dfs.namenode.rpc-address.ns1.nn1
master1:9000
dfs.namenode.http-address.ns1.nn1
master1:50070
dfs.namenode.rpc-address.ns1.nn2
master2:9000
dfs.namenode.http-address.ns1.nn2
master2:50070
dfs.namenode.shared.edits.dir
qjournal://node1:8485;node2:8485;node3:8485/ns1
dfs.journalnode.edits.dir
/opt/hadoop/journaldata
dfs.ha.automatic-failover.enabled
true
dfs.client.failover.proxy.provider.ns1
org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider
dfs.ha.fencing.methods
sshfence
shell(/bin/true)
dfs.ha.fencing.ssh.private-key-files
/home/hadoop/.ssh/id_rsa
dfs.ha.fencing.ssh.connect-timeout
30000
dfs.namenode.name.dir
file:///opt/hadoop/hdfs/name
dfs.datanode.data.dir
file:///opt/hadoop/hdfs/data
dfs.replication
3
vi mapred-site.xml
mapreduce.framework.name
yarn
mapreduce.jobhistory.address
0.0.0.0:10020
mapreduce.jobhistory.webapp.address
0.0.0.0:19888
vi yarn-site.xml
yarn.resourcemanager.ha.enabled
true
yarn.resourcemanager.recovery.enabled
true
yarn.resourcemanager.cluster-id
yrc
yarn.resourcemanager.ha.rm-ids
rm1,rm2
yarn.resourcemanager.hostname.rm1
master1
yarn.resourcemanager.hostname.rm2
master2
yarn.resourcemanager.ha.id
$ResourceManager_Id [rm1|rm2]
If we want to launch more than one RM in single node,we need this configuration
yarn.resourcemanager.zk-address
node1:2181,node2:2181,node3:2181
ha.zookeeper.quorum
node1:2181,node2:2181,node3:2181
yarn.resourcemanager.zk-state-store.address
node1:2181,node2:2181,node3:2181
yarn.resourcemanager.store.class
org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore
yarn.resourcemanager.ha.automatic-failover.zk-base-path
/yarn-leader-election
Optionalsetting.Thedefaultvalueis/yarn-leader-election
yarn.nodemanager.aux-services
mapreduce_shuffle
vi hadoop-env.sh
vi mapred-env.sh
vi yarn-env.sh
export JAVA_HOME=/opt/env/jdk1.8.0_121
export CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export HADOOP_HOME=/opt/hadoop/hadoop-2.8.4
export HADOOP_PID_DIR=/opt/hadoop/hadoop-2.8.4/pids
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="$HADOOP_OPTS-Djava.library.path=$HADOOP_HOME/lib/native"
export HADOOP_PREFIX=$HADOOP_HOME
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_CONF_DIR=$HADOOP_HOME/etc/hadoop
export HDFS_CONF_DIR=$HADOOP_HOME/etc/hadoop
export YARN_CONF_DIR=$HADOOP_HOME/etc/hadoop
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
vi masters
master2
vi slaves
node1
node2
node3
시작 클 러 스 터
zookeeper 시작 [node 1 node 2 node 3]
./zkServer.sh start
[hadoop@node1 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader
[hadoop@node2 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
[hadoop@node3 bin]$ ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: follower
NameNode 포맷 [master 1]
bin/hdfs namenode -format
[hadoop@master2 ~]$ ll /opt/hadoop/data/dfs/name/current/
total 16
-rw-rw-r--. 1 hadoop hadoop 323 Jul 11 01:17 fsimage_0000000000000000000
-rw-rw-r--. 1 hadoop hadoop 62 Jul 11 01:17 fsimage_0000000000000000000.md5
-rw-rw-r--. 1 hadoop hadoop 2 Jul 11 01:17 seen_txid
-rw-rw-r--. 1 hadoop hadoop 219 Jul 11 01:17 VERSION
포맷 zkfc [master 1 master 2]
bin/hdfs zkfc -formatZK
NameNode / ResourceManager 시작 [master 1]
sbin/start-dfs.sh
[hadoop@master1 sbin]$ sh start-dfs.sh
which: no start-dfs.sh in (/opt/env/jdk1.8.0_121/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/hadoop/.local/bin:/home/hadoop/bin)
Java HotSpot(TM) Client VM warning: You have loaded library /opt/hadoop/hadoop-2.8.4/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.
19/07/25 01:00:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [master1 master2]
master2: starting namenode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-namenode-master2.out
master1: starting namenode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-namenode-master1.out
node2: starting datanode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-datanode-node2.out
node1: starting datanode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-datanode-node1.out
node3: starting datanode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-datanode-node3.out
Starting journal nodes [node1 node2 node3]
node2: starting journalnode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-journalnode-node2.out
node3: starting journalnode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-journalnode-node3.out
node1: starting journalnode, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-journalnode-node1.out
Java HotSpot(TM) Client VM warning: You have loaded library /opt/hadoop/hadoop-2.8.4/lib/native/libhadoop.so.1.0.0 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.
19/07/25 01:01:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting ZK Failover Controllers on NN hosts [master1 master2]
master2: starting zkfc, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-zkfc-master2.out
master1: starting zkfc, logging to /opt/hadoop/hadoop-2.8.4/logs/hadoop-hadoop-zkfc-master1.out
[hadoop@master1 sbin]$ jps
5552 NameNode
5940 Jps
5869 DFSZKFailoverController
sbin/start-yarn.sh
[hadoop@master1 sbin]$ sh start-yarn.sh
starting yarn daemons
which: no start-yarn.sh in (/opt/env/jdk1.8.0_121/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/hadoop/.local/bin:/home/hadoop/bin)
starting resourcemanager, logging to /opt/hadoop/hadoop-2.8.4/logs/yarn-hadoop-resourcemanager-master1.out
node2: starting nodemanager, logging to /opt/hadoop/hadoop-2.8.4/logs/yarn-hadoop-nodemanager-node2.out
node3: starting nodemanager, logging to /opt/hadoop/hadoop-2.8.4/logs/yarn-hadoop-nodemanager-node3.out
node1: starting nodemanager, logging to /opt/hadoop/hadoop-2.8.4/logs/yarn-hadoop-nodemanager-node1.out
[hadoop@master1 sbin]$ jps
5552 NameNode
5994 ResourceManager
6092 Jps
5869 DFSZKFailoverController
이때 DataNode
[hadoop@node1 hadoop-2.8.4]$ jps
3808 QuorumPeerMain
5062 Jps
4506 DataNode
4620 JournalNode
4732 NodeManager
이때 master 2
[hadoop@master2 sbin]$ jps
6092 Jps
5869 DFSZKFailoverController
NameNode Standby 포맷 [master 2]
bin/hdfs namenode -bootstrapStandby
NameNode Standby 시작 [master 2]
sbin/hadoop-daemon.sh start namenode
리 소스 관리자 대기 모드 시작 [master 2]
sbin/yarn-daemon.sh start resourcemanager
[hadoop@master2 hadoop-2.8.4]$ jps
4233 Jps
3885 DFSZKFailoverController
4189 ResourceManager
4030 NameNode
리 소스 관리자 상태
[hadoop@master2 hadoop-2.8.4]$ bin/yarn rmadmin -getServiceState rm2
Java HotSpot(TM) Client VM warning: You have loaded library /opt/hadoop/hadoop-2.8.4/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.
19/07/25 01:48:37 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
active
[hadoop@master2 hadoop-2.8.4]$ bin/yarn rmadmin -getServiceState rm1
Java HotSpot(TM) Client VM warning: You have loaded library /opt/hadoop/hadoop-2.8.4/lib/native/libhadoop.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.
19/07/25 01:48:41 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
standby
enjoy
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Azure HDInsight + Microsoft R Server에서 연산 처리 분산Microsoft Azure HDInsight는 Microsoft가 제공하는 Hadoop의 PaaS 서비스로 인프라 주변의 구축 노하우를 몰라도 훌륭한 Hadoop 클러스터를 구축할 수 있는 훌륭한 서비스입니다. 이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.