分布式环境搭建
一:上传压缩包并加压
解压
tar -zxvf hadoop-2.6.0-cdh5.14.0.tar.gz -C ../servers/
二:查看Hadoop压缩方式
cd /export/servers/hadoop-2.6.0-cdh5.14.0
bin/hadoop checknative
- 安装 openssl (yum -y install openssl-devel)
三:修改配置文件
1. cd /export/servers/hadoop-2.6.0-cdh5.14.0/etc/hadoop
vim core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://node01:8020</value> </property> <!-- 设置临时目录 --> <property> <name>hadoop.tmp.dir</name> <value>/export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/tempDatas</value> </property> <!-- 缓冲区大小,实际工作中根据服务器性能动态调整 --> <property> <name>io.file.buffer.size</name> <value>4096</value> </property> <!-- 开启hdfs的垃圾桶机制,删除掉的数据可以从垃圾桶中回收,单位分钟 --> <property> <name>fs.trash.interval</name> <value>10080</value> </property> </configuration>
vim hdfs-site.xml
<configuration> <!-- NameNode存储元数据信息的路径,实际工作中,一般先确定磁盘的挂载目录,然后多个目录用,进行分割 --> <!-- 集群动态上下线 <property> <name>dfs.hosts</name> <value>/export/servers/hadoop-2.6.0-cdh5.14.0/etc/hadoop/accept_host</value> </property> <property> <name>dfs.hosts.exclude</name> <value>/export/servers/hadoop-2.6.0-cdh5.14.0/etc/hadoop/deny_host</value> </property> --> <!-- 设置namenode 服务器的端口号 --> <property> <name>dfs.namenode.secondary.http-address</name> <value>node01:50090</value> </property> <property> <name>dfs.namenode.http-address</name> <value>node01:50070</value> </property> <!-- 确定DFS名称的存储 --> <property> <name>dfs.namenode.name.dir</name> <value>file:///export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/namenodeDatas</value> </property> <!-- 定义dataNode数据存储的节点位置,实际工作中,一般先确定磁盘的挂载目录,然后多个目录用,进行分割 --> <property> <name>dfs.datanode.data.dir</name> <value>file:///export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/datanodeDatas</value> </property> <property> <name>dfs.namenode.edits.dir</name> <value>file:///export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/dfs/nn/edits</value> </property> <property> <name>dfs.namenode.checkpoint.dir</name> <value>file:///export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/dfs/snn/name</value> </property> <property> <name>dfs.namenode.checkpoint.edits.dir</name> <value>file:///export/servers/hadoop-2.6.0-cdh5.14.0/hadoopDatas/dfs/nn/snn/edits</value> </property> <!-- 设置副本数 --> <property> <name>dfs.replication</name> <value>2</value> </property> <!-- 如果HDFS中为true启动权限检查 false 取消检查权限 --> <property> <name>dfs.permissions</name> <value>false</value> </property> <!-- 新建文件的大小 --> <property> <name>dfs.blocksize</name> <value>134217728</value> </property> </configuration>
vim mapred-site.xml
<configuration> <!-- 执行MapReduce作业的运行时框架。可以是本地的,经典的或纱线。 --> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <property> <name>mapreduce.job.ubertask.enable</name> <value>true</value> </property> <!-- MapReduce 服务器地址 默认10020--> <property> <name>mapreduce.jobhistory.address</name> <value>node01:10020</value> </property> <!-- MapReduce 服务器地址 默认19888--> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>node01:19888</value> </property> </configuration>
vim yarn-site.xml
<configuration> <!-- 设置应用管理接口地址--> <property> <name>yarn.resourcemanager.hostname</name> <value>node01</value> </property> <!-- 有效的服务名应该只包含a-zA-Z0-9_,不能以数字开头--> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
vim slaves (写入你的三主机名称)
node01 node02 node03
四:配置hadoop的环境变量
vim /etc/profile.d/hadoop.sh
export HADOOP_HOME=/export/servers/ hadoop-2.6.0-cdh5.14.0 export PATH=$PATH:$HADOOP_HOME/bin export PATH=$PATH:$HADOOP_HOME/sbin
五:集群拷贝
- scp -r hadoop-2.6.0-cdh5.14.0 node02:/export/servers/
- scp -r hadoop-2.6.0-cdh5.14.0 node03:/export/servers/
- scp -r /etc/profile.d/hadoop.sh node02:/etc/profile.d/
- scp -r /etc/profile.d/hadoop.sh node03:/etc/profile.d/
六:在主节点格式化 bin/hdfs namenode -format
七:一键启动 sbin/start-all.sh
八 测试节点是否启动成功 主机点 jps