hadoop集群完整配置

来源:互联网 发布:地图矢量数据 编辑:程序博客网 时间:2024/06/08 19:35

安装hadoop

看是否有yum源
v运行命令ls /etc/yum.repos.d/
确认是否有cdh4.repo此文件,
一般情况会有如下文件:

cdh4.repo  CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo  epel.repo  epel-testing.repo

 

装好JDK之后在/etc/profile中配置jdk环境变量
export JAVA_HOME=/usr/java/jdk1.6.0_45
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:/lib/dt.jar
export PATH=$JAVA_HOME/bin:$PATH

这个文件记得 sorce profile让他直接生效


修改/etc/hosts,所有机器和主机名都要对应


开始安装datanode
yum install ~ hadoop-hdfs-namenode

把namenode的各种目录建好
mkdir -p /services/data/hadoop/namenode
mkdir -p  /services/data/hadoop/tmp
chown -R  hdfs:hdfs /services/data/hadoop/namenode
chown -R  hdfs:hdfs /services/data/hadoop/tmp
chmod 700  /services/data/hadoop/namenode


修改配置文件:core-site.xml 这个文件是核心配置文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
 <property>
 <name>fs.default.name</name>
 <value>hdfs://opd18hdp04.dev.optimad.cn</value>
 </property>
</configuration>


修改配置文件 :Hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>dfs.name.dir</name>
<value>/services/data/hadoop/namenode</value>
</property>
<property>
<name>dfs.tmp.dir</name>
<value>/services/data/hadoop/tmp</value>
</property>
<property>
<name>dfs.permissions.superusergroup</name>
<value>hadoop</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>


配置dfs.replication这个参数指的是数据要备份的次数

初始化(格式化):namenode
使用命令sudo -u hdfshadoopnamenode–format


启动hadoop namenode
使用命令cd /etc/init.d
使用命令 ./hadoop-hdfs-namenode start


使用命令sudo –u hdfs hadoopfs –mkdir /tmp在HDFS中创建名为tmp的文件夹。
使用命令sudo –u hdfs hadoopfs –ls /tmp在HDFS中,把TMP文件里的文件罗列出来。

也可以通过网站的形式来。
在IE浏览器或者其他的网络浏览器输入
http://172.16.26.13:50070/dfshealth.jsp
(其中域名位置可以自己进行替换)


开始安装datanode
yum install ~ hadoop-hdfs-datanode

创建datanode的文件夹
mkdir -p /services/data/hadoop/datanode
chown -R hdfs:hdfs /services/data/hadoop/datanode

同样需要修改core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
 <property>
 <name>fs.default.name</name>
 <value>hdfs://这个地方放namenode机器的主机名或者ip地址</value>
 </property>
</configuration>

 

配置 hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
 <name>dfs.data.dir</name>
 <value>/services/data/hadoop/datanode</value>
</property>
<property>
 <name>dfs.permissions.superusergroup</name>
 <value>hadoop</value>
</property>
</configuration>

 

2.2.3启动
使用命令cd /etc/init.d
使用命令/etc/init.d/hadoop-hdfs-datanode start

sudo -u hdfs hadoop fs -ls /

 

配置 TASKTRACKER

yum install -y hadoop-0.20-mapreduce-tasktracker

mkdir -p /services/data/hadoop/tasktracker/
chown -R mapred:hadoop  /services/data/hadoop/tasktracker


创建一个mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>mapred.job.tracker</name>
 <value>用来做jobtracker的IP地址或者主机名:8021</value>
</property>
<property>
<name>mapred.local.dir</name>
 <value>/services/data/hadoop/tasktracker/</value>
</property>
</configuration>

使用命令/etc/init.d/hadoop-0.20-mapreduce-tasktracker start


打开JOB 地址http://172.16.26.39:50030/查看是否已经在页面中
在即安装成功

 

JOBTRACKER安装

使用命令yum install -y hadoop-0.20-mapreduce-jobtracker来进行安装

mkdir -p /services/data/hadoop/jobtracker
chown -R mapred:mapred/services/data/hadoop/jobtracker

登录namenode,执行如下命令
sudo -u hdfshadoopfs -mkdir /tmp
sudo -u hdfshadoopfs -mkdir /tmp/hadoop-mapred
sudo -u hdfshadoopfs -mkdir /tmp/hadoop-mapred/mapred
sudo -u hdfshadoopfs -mkdir /tmp/hadoop-mapred/mapred/system
sudo -u hdfshadoopfs -chown -R mapred /tmp/hadoop-mapred


core-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
 <property>
 <name>fs.default.name</name>
 <value>hdfs://namenode的主机名或者IP地址</value>
 </property>
</configuration>

 


mapred-site.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>mapred.job.tracker</name>
<value>用来做jobtracker的IP地址或者主机名:8021</value>
</property>
<property>
<name>mapred.local.dir</name>
<value>/services/data/hadoop/jobtracker</value>
</property>
<property>
<name>mapreduce.job.reduce.slowstart.completedmaps</name>
<value>0.5</value>
</property>
</configuration>


 

0 0
原创粉丝点击