标签:
声明
yum install zookeeper -y
都安装 zookeeper-server
sudo yum install zookeeper-server -y
$ sudo service zookeeper-server init --myid=1 $ sudo service zookeeper-server start JMX enabled by default Using config: /etc/zookeeper/conf/zoo.cfg Starting zookeeper ... STARTED
在 host2 上启动zookeeper
$ sudo service zookeeper-server init --myid=2 $ sudo service zookeeper-server start JMX enabled by default Using config: /etc/zookeeper/conf/zoo.cfg Starting zookeeper ... STARTED
$ netstat -tpnl | grep 2181 tcp 0 0 :::2181 :::* LISTEN 5477/java
用client端测试一下
zookeeper-client -server host1:2181
在两台机子上都编辑 /etc/zookeeper/conf/zoo.cfg 文件
tickTime=2000 dataDir=/var/lib/zookeeper/ clientPort=2181 initLimit=5 syncLimit=2 server.1=host1:2888:3888 server.2=host2:2888:3888
hadoop在启动的时候会自动去找zookeeper的2181端口,如果没有就启动不起来
yum install hadoop-yarn-resourcemanager -y
sudo yum install hadoop-hdfs-namenode -y
yum install hadoop-yarn-nodemanager hadoop-hdfs-datanode hadoop-mapreduce -y
yum install hadoop-hdfs-datanode -y
yum install hadoop-mapreduce-historyserver hadoop-yarn-proxyserver -y
yum install hadoop-client -y
sudo hostname host1
sudo hostname host2
192.168.199.126 host1.localdomain host1 192.168.199.128 host2.localdomain host2
[root@localhost conf]# uname -a Linux host1 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
<property> <name>fs.defaultFS</name> <value>hdfs://host1.localdomain:8020</value> </property>
<property> <name>dfs.permissions.superusergroup</name> <value>hadoop</value> </property>
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hdfs/1/dfs/nn</value> </property> <property> <name>dfs.permissions.superusergroup</name> <value>hadoop</value> </property> </configuration>
<property> <name>dfs.datanode.data.dir</name> <value>file:///data/hdfs/1/dfs/dn,file:///data/hdfs/2/dfs/dn,file:///data/hdfs/3/dfs/dn</value> </property>
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hdfs/1/dfs/nn</value> </property> <property> <name>dfs.permissions.superusergroup</name> <value>hadoop</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/hdfs/1/dfs/dn,file:///data/hdfs/2/dfs/dn,file:///data/hdfs/3/dfs/dn</value> </property> </configuration>
chown -R hdfs.hdfs hdfs
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://host2.localdomain:8020</value> </property> </configuration>
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hdfs/1/dfs/nn</value> </property> <property> <name>dfs.permissions.superusergroup</name> <value>hadoop</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/hdfs/1/dfs/dn,file:///data/hdfs/2/dfs/dn,file:///data/hdfs/3/dfs/dn</value> </property> </configuration>
chown -R hdfs.hdfs hdfs
sudo -u hdfs hdfs namenode -format
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
$ sudo -u hdfs hadoop fs -mkdir /tmp $ sudo -u hdfs hadoop fs -chmod -R 1777 /tmp这样会在hdfs集群上建立 /tmp 文件夹。
sudo -u hdfs hadoop fs -ls /来看下hdfs上根目录下有什么文件夹
[root@host1 ~]# jps 12044 Jps 2207 ResourceManager 11857 NameNode
[root@host2 ~]# jps 10735 NameNode 10855 Jps 10644 DataNode 2272 JobHistoryServer
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://mycluster</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/data/hdfs/tmp</value> </property> <property> <name>ha.zookeeper.quorum</name> <value>host1:2181,host2:2181</value> </property> </configuration>
cd /data/hdfs mkdir tmp chown -R hdfs.hdfs tmp
<configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.permissions</name> <value>false</value> </property> <property> <name>dfs.nameservices</name> <value>mycluster</value> </property> <property> <name>dfs.ha.namenodes.mycluster</name> <value>host1,host2</value> </property> <property> <name>dfs.namenode.rpc-address.mycluster.host1</name> <value>host1:8020</value> </property> <property> <name>dfs.namenode.http-address.mycluster.host1</name> <value>host1:50070</value> </property> <property> <name>dfs.namenode.rpc-address.mycluster.host2</name> <value>host2:8020</value> </property> <property> <name>dfs.namenode.http-address.mycluster.host2</name> <value>host2:50070</value> </property> <property> <name>dfs.ha.automatic-failover.enabled</name> <value>false</value> </property> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://host1:8485;host2:8485/mycluster</value> </property> <property> <name>dfs.client.failover.proxy.provider.mycluster</name> <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value> </property> <property> <name>dfs.journalnode.edits.dir</name> <value>/data/yarn/tmp/journal</value> </property> <property> <name>dfs.ha.fencing.methods</name> <value>sshfence</value> </property> <property> <name>dfs.ha.fencing.ssh.private-key-files</name> <value>/root/.ssh/id_dsa</value> </property> <property> <name>dfs.ha.fencing.ssh.connect-timeout</name> <value>10000</value> </property> <property> <name>dfs.namenode.handler.count</name> <value>100</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///data/hdfs/1/dfs/nn</value> </property> <property> <name>dfs.permissions.superusergroup</name> <value>hadoop</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///data/hdfs/1/dfs/dn,file:///data/hdfs/2/dfs/dn,file:///data/hdfs/3/dfs/dn</value> </property> </configuration>
sudo mkdir -p /data/yarn/tmp/journal sudo chown -R hdfs:hdfs /data/yarn
cd ~ ssh-keygen -t dsa 全程回车 ssh-copy-id -i ~/.ssh/id_dsa root@host2 <pre name="code" class="plain">Are you sure you want to continue connecting (yes/no)?输入 yes这步会让你输入host2的密码ssh root@host2第一次会问你Are you sure you want to continue connecting (yes/no)?记得输入yes 在host2上也做一遍
ssh-keygen -t dsa ssh-copy-id -i ~/.ssh/id_dsa root@host1 ssh root@host1
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
<property> <name>yarn.resourcemanager.hostname</name> <value>host1</value> </property>
host1 host2
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x stop; done for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
yum install hadoop-hdfs-journalnode -y
service hadoop-hdfs-journalnode start
sudo -u hdfs hdfs namenode -format
service hadoop-hdfs-namenode stop
hdfs namenode -initializeSharedEdits
service hadoop-hdfs-namenode start
sudo -u hdfs hdfs namenode -bootstrapStandby可能会问你是否要格式化,记得选Y
service hadoop-hdfs-namenode start
hdfs haadmin -failover host2 host1
yum install hadoop-hdfs-zkfc -y
hdfs zkfc -formatZK
# zookeeper-client -server host1:2181 [zk: host1:2181(CONNECTED) 0] ls / [hadoop-ha, zookeeper]
service hadoop-hdfs-zkfc start
Alex 的 Hadoop 菜鸟教程: 第4课 Hadoop 安装教程 - HA方式 (2台服务器)
标签:
原文地址:http://blog.csdn.net/nsrainbow/article/details/42013293