因为 hadoop 依赖于特定版本的 snappy,请先卸载 snappy 确保装置的顺利进行:
hawq ssh -f hostfile -e 'yum remove -y snappy'
HAWQ 的 HDFS 采纳 HA 的形式进行装置配置。装置 Hadoop 可执行文件。hawq ssh -f hostfile -e 'yum install -y hadoop hadoop-hdfs'
配置 NameNode 目录,须要配置的节点有两个,oushum1 和 oushum2。创立 nnhostfile,
相似前文 hostfile:touch nnhostfile
配置 nnhostfile 内容为 hadoop 的 NameNode 节点 hostname:oushum1oushum2
创立 DataNode 主机文件 dnhostfile,相似前文 nnhostfile:touch dnhostfile
配置 dnhostfile 内容为 hadoop 的 DataNode 节点 hostname:oushus1oushus2
创立 NameNode 目录:
hawq ssh -f nnhostfile -e 'mkdir -p /data1/hdfs/namenode'hawq ssh -f nnhostfile -e 'chmod -R 755 /data1/hdfs'hawq ssh -f nnhostfile -e 'chown -R hdfs:hadoop /data1/hdfs'
创立 DataNode 目录:
hawq ssh -f dnhostfile -e 'mkdir -p /data1/hdfs/datanode'hawq ssh -f dnhostfile -e 'mkdir -p /data2/hdfs/datanode'hawq ssh -f dnhostfile -e 'chmod -R 755 /data1/hdfs'hawq ssh -f dnhostfile -e 'chmod -R 755 /data2/hdfs'hawq ssh -f dnhostfile -e 'chown -R hdfs:hadoop /data1/hdfs'hawq ssh -f dnhostfile -e 'chown -R hdfs:hadoop /data2/hdfs'
复制下列文件到 oushum1 上的 /etc/hadoop/conf/ 中,
● http://www.oushu.com/docs/ch/_downloads/908bee114673dff44292d2b51ed5a1ce/core-site.xml.
● http://www.oushu.com/docs/ch/_downloads/a57b214c41f418570548204fdf5089b3/hdfs-site.xml.
● http://www.oushu.com/docs/ch/_downloads/5caeda7d6d35f2ab18438c8994e855c1/hadoop-env.sh.
批改 hadoop 配置文件, 依据各个节点的本身配置决定的,能够参考上面内容进行批改,次要是 /etc/hadoop/conf 目录下的 core-site.xml、hdfs-site.xml、hadoop-env.xml 和 slaves
批改 oushum1 上的配置文件 /etc/hadoop/conf/core-site.xml 首先须要关上 HA,即去掉如下所示的 HA 正文:<!-- HA
...
HA -->
去掉上面的内容:
<property><name>fs.defaultFS</name><value>hdfs://hdfs-nn:9000</value></property>
批改上面的内容:
<configuration><property><name>fs.defaultFS</name><value>hdfs://oushu</value></property><property><name>ha.zookeeper.quorum</name><value>oushum1:2181,oushum2:2181,oushus1:2181</value></property>…<property><name>ipc.server.listen.queue.size</name><value>3300</value></property>…<configuration>
批改 oushum1 上的配置文件 /etc/hadoop/conf/hdfs-site.xml 首先关上 HA,即去掉如下所示的两行正文:<!-- HA
...
HA -->
HA 关上后,批改内容如下:<configuration><property><name>dfs.name.dir</name><value>file:/data1/hdfs/namenode</value><final>true</final></property><property><name>dfs.data.dir</name><value>file:/data1/hdfs/datanode,file:/data2/hdfs/datanode</value><final>true</final></property>...<property><name>dfs.block.local-path-access.user</name><value>gpadmin</value></property>...<property><name>dfs.domain.socket.path</name><value>/var/lib/hadoop-hdfs/dn_socket</value></property>...<property><name>dfs.block.access.token.enable</name><value>true</value><description>If "true", access tokens are used as capabilities for accessingdatanodes.If "false", no access tokens are checked on accessing datanodes.</description></property>...<property><name>dfs.nameservices</name><value>oushu</value></property><property><name>dfs.ha.namenodes.oushu</name><value>nn1,nn2</value></property><property><name>dfs.namenode.rpc-address.oushu.nn1</name><value>oushum2:9000</value></property><property><name>dfs.namenode.http-address.oushu.nn1</name><value>oushum2:50070</value></property><property><name>dfs.namenode.rpc-address.oushu.nn2</name><value>oushum1:9000</value></property><property><name>dfs.namenode.http-address.oushu.nn2</name><value>oushum1:50070</value></property><property><name>dfs.namenode.shared.edits.dir</name><value>qjournal://oushum1:8485;oushum2:8485;oushus1:8485/oushu</value></property><property><name>dfs.ha.automatic-failover.enabled.oushu</name><value>true</value></property><property><name>dfs.client.failover.proxy.provider.oushu</name><value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value></property><property><name>dfs.journalnode.edits.dir</name><value>/data1/hdfs/journaldata</value></property>...
批改 oushum1 上 /etc/hadoop/conf/hadoop-env.sh:
...
export JAVA_HOME="/usr/java/default"
...
export HADOOP_CONF_DIR="/etc/hadoop/conf"
...
export HADOOP_NAMENODE_OPTS="-Xmx6144m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
export HADOOP_DATANODE_OPTS="-Xmx2048m -Xss256k"
...
export HADOOP_LOG_DIR=/var/log/hadoop/$USER
...
批改 oushum1 上 /etc/hadoop/conf/slaves 将所有 DataNode 的 HostName 写入该文件:oushus1oushus2
拷贝 oushum1 上 /etc/hadoop/conf 中的配置文件到所有节点:
hawq scp -r -f hostfile /etc/hadoop/conf =:/etc/hadoop/
在 oushum1 节点,格式化 ZKFailoverController
sudo -u hdfs hdfs zkfc -formatZK
在配置 journal 的所有节点上,启动 journalnode。创立 jhostfile,相似前文 hostfile,内容为配置 journal 的节点 hostname:oushum1oushum2oushus1
应用上面的命令,启动 journalnode:
hawq ssh -f jhostfile -e 'sudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start journalnode'
格式化并启动 oushum1 上的 NameNode:
sudo -u hdfs hdfs namenode -format -clusterId sssudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start namenode
在另一个 NameNode oushum2 中进行同步操作,并启动 NameNode:
hawq ssh -h oushum2 -e 'sudo -u hdfs hdfs namenode -bootstrapStandby'hawq ssh -h oushum2 -e 'sudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start namenode'
通过 hawq ssh 启动所有 datanode 节点:
hawq ssh -f dnhostfile -e 'sudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start datanode'
通过 hawq ssh 启动 oushum2 上的 zkfc 过程,使其成为 active namenode:
hawq ssh -h oushum2 -e 'sudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start zkfc'
通过 hawq ssh 启动 oushum1 上的 zkfc 过程,使其成为 standby namenode:
hawq ssh -h oushum1 -e 'sudo -u hdfs /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh start zkfc'
查看 hdfs 是否胜利运行:
su – hdfshdfs dfsadmin -reporthdfs dfs -mkdir /testnodehdfs dfs -put /usr/hdp/current/hadoop-client/sbin/hadoop-daemon.sh /testnode/hdfs dfs -ls -R /
你也能够查看 HDFS web 界面:http://oushum1:50070/