3月初写过FreeBSD下安装hadoop的文章,那会hadoop还没有进入FreeBSD的ports,刚写完没多久,3月27日。FreeBSD的ports树就引入了hadoop,安装就太方便了。
怎么更新ports树就略过了,直接跳到安装hadoop
#cd /usr/ports/devel/hadoop
#make install clean
等着完事就行了。都是编译安装,非常优化,而且自动解决依赖关系,诸如bash,openjdk一类的,目前的版本是hadoop-1.0.0。不过我还没想明白将来hadoop ports更新的时候,ports是如何进行热更新的。
不过还不够全自动,少量的东西会需要手工配置一下。主要是帐号权限问题。假设以单机版方式配置hadoop
以下内容用root权限完成
echo "namenode_enable=YES" >> /etc/rc.conf
echo "datanode_enable=YES" >> /etc/rc.conf
echo "jobtracker_enable=YES" >> /etc/rc.conf
echo "tasktracker_enable=YES" >> /etc/rc.conf
echo "127.0.0.1 localhost.localdomain" >> /etc/hosts;
chsh hadoop
#安装完成后,make会自动创建hadoop用户和hadoop组,但在启动hadoop过程中似乎有些问题,所以需要修改一下。修改红字部分为以下内容
echo "datanode_enable=YES" >> /etc/rc.conf
echo "jobtracker_enable=YES" >> /etc/rc.conf
echo "tasktracker_enable=YES" >> /etc/rc.conf
echo "127.0.0.1 localhost.localdomain" >> /etc/hosts;
chsh hadoop
#安装完成后,make会自动创建hadoop用户和hadoop组,但在启动hadoop过程中似乎有些问题,所以需要修改一下。修改红字部分为以下内容
#Changing user information for hadoop.
Login: hadoop
Password: *
Uid [#]: 955
Gid [# or name]: 0
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /nonexistent
Shell: /usr/local/bin/bash
Full Name: hadoop user
Office Location:
Office Phone:
Home Phone:
Other information:
Login: hadoop
Password: *
Uid [#]: 955
Gid [# or name]: 0
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /nonexistent
Shell: /usr/local/bin/bash
Full Name: hadoop user
Office Location:
Office Phone:
Home Phone:
Other information:
然后root部分的工作就完成了,下列工作请su到hadoop用户下完成。
ports安装和源码安装自然是不太一样,配置文件放在了freebsd的标准配置文件路径下,也就是/usr/local/etc/hadoop。
日志文件则放在/var/log/hadoop下
/usr/local/etc/hadoop/core-site.xml:
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
/usr/local/etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
/usr/local/etc/hadoop/mapred-site.xml:
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
/usr/local/etc/hadoop/hdfs-site.xml:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
/usr/local/etc/hadoop/mapred-site.xml:
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
然后还是用hadoop账户,执行如下
hadoop namenode -format
/usr/local/etc/rc.d/namenode start
/usr/local/etc/rc.d/datanode start
/usr/local/etc/rc.d/jobtracker start
/usr/local/etc/rc.d/tasktracker start
没有然后了。
/usr/local/etc/rc.d/namenode start
/usr/local/etc/rc.d/datanode start
/usr/local/etc/rc.d/jobtracker start
/usr/local/etc/rc.d/tasktracker start
没有然后了。