hadoop工作日志-安装,挂载HDFS
本帖最后由 pig2 于 2014-3-6 01:36 编辑阅读本文我们需要了解FUSE是什么?ant在挂载中的作用是什么?挂载中那些是需要注意的问题?思考那些问题会导致我们挂在不成功?
FUSE:用户空间文件系统(Filesystem in Userspace),是Linux 中用于挂载某些网络空间,如SSH,到本地文件系统的模块,在SourceForge上可以找到相关内容。
首先是操作系统以及所使用的软件的版本操作系统:CentOS 5.5 (32位)hadoop版本:hadoop-0.20.2.tar.gzjdk版本:jdk-6u20-linux-i586.binfuse版本:fuse-2.8.1.tar.gzant版本:apache-ant-1.7.0-bin.tar.gz两台32位的服务器:hadoop1(192.168.0.3),hadoop2(192.168.0.2),hadoop3(192.168.0.5),hadoop1是master,hadoop2,hadoop3是slave,并在hadoop2,hadoop3之上挂载HDFS文件系统。
一:操作系统安装
1.网卡选择启动时激活2.选择Desktop-Gnome ,Desktop-KDE,Server3.定制软件包:桌面环境,应用程序,开发,服务器,基本系统,这些全选
二:hadoop安装:
1.首先修改三台机器的/etc/hosts文件。将倒数两行注释掉(#127.0.0.1······以及#::······)。然后在文件的末尾添加:192.168.0.3 hadoop1192.168.0.2 hadoop2192.168.0.4 hadoop32.建立节点之间按的无密码连接:(1)在hadoop1上: #cd /root #ssh-keygen -t rsa一路回车即可 #ls -a 查看是否有.ssh文件夹 #cd .ssh进入.ssh目录 #cp id_rsa.pub authorized_keys生成authorized_keys文件 #cd .. 退出到root目录 建立本身的信任连接 #ssh hadoop1 按提示输入yes(三个字母要打全)(2)在hadoop2和hadoop3之上 #cd /root #ssh-keygen -t rsa 生成.ssh文件夹 #scp root@hadoop1:/root/.ssh/* .ssh/ 拷贝hadoop1上的.ssh文件夹覆盖本地的 (3)在三台机器之上运行: #ssh hadoop1 #ssh hadoop2 #ssh hadoop3 这样就建立了三台机器之间的互信连接
3. 安装JDK(在hadoop1,hadoop2,hadoop3三之上执行,安装位置要一致):
#cd /root/Desktop/hadoop_file/(此目录中存放hadoop,ant,jdk) #cpjdk-6u20-linux-i586.bin /usr/local #cd /usr/local #chmod a+x jdk-6u20-linux-i586.bin #./jdk-6u20-linux-i586.bin 然后修改/etc/profile文件,在文件的最末尾添加: export JAVA_HOME=/usr/local/jdk1.6.0_20 export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin export CLASSPATH=.:/usr/local/jdk1.6.0_20/lib:/usr/local/jdk1.6.0_20/jre/lib:$CLASSPATH
source /etc/profile
4.安装hadoop(在hadoop1,hadoop2,hadoop3上执行,hadoop的安装位置要一致):
#cd/root/Desktop/hadoop_file/hadoop-0.20.2(hadoop压缩文件就在此目录,我就将它 安装在此目录) #tar -xzvf hadoop-0.20.2.tar.gz #cd /root/Desktop/hadoop_file/hadoop-0.20.2/conf 在hadoop-env文件中 #export JAVA_HOME=/usr/local/jdk1.6.0_20 #vi core-site.xml 添加:
<property>
<name>fs.default.name</name>
<value>hdfs://hadoop1:9000</value>
</property>
#vi hdfs-site.xml添加: <property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/tmp/hadoop/hadoop-${user.name}</value>
</property>
#vi mapred-sit.xml 添加:
<property>
<name>mapred.job.tracker</name>
<value>hadoop1:9001</value>
</property>
#vimasters 修改为: hadoop1 #vislaves 修改为: hadoop2 hadoop3 到此,hadoop的安装就完成了。
5.启动hadoop:
#service iptables stop (在hadoop1,hadoop2,hadoop3中都要执行) #cd /root/Desktop/hadoop_file/hadoop-0.20.2/bin #./hadoop namenode -format #./start-all.sh 这样就将hadoop启动起来了,接下来测试一下: #./hadoop dfs -copyFromLocal/root/hadooptest test-in #./hadoop dfs -ls test-in
三: HDFS的挂载:
花了很长时间试图用hdfs-fuse来挂载HDFS发现很困难,没有成功,于是不得已,参照 一个文章,放在了回帖中,并成功了。
1. 首先安装fuse-2.8.1.tar.gz : #tar -xzvffuse-2.8.1.tar.gz-C /opt #cd /opt/fuse-2.8.1 #./configure --prefix=/usr
#make
#make install
#modprobe fuse #vi /etc/sysconfig/modules/my.modules 内容为: #!/bin/sh
modprobe fuse >/dev/null 2>&1
#chmod +x /etc/sysconfig/modules/my.modules
2. 然后安装ant
#cd /root/Desktop/hadoop_file #tar -xzvf apache-ant-1.7.0-bin.tar.gz -C /usr/local
3. 拷贝
原来咱们是把hadoop安装在/root/Desktop/hadoop_file/hadoop-0.20.2,现在为了生成fuse-dfs,并且不影响咱们的已经安装好的hadoop,咱们把整个hadoop-0.20.2,拷贝到/root/Desktop,然后在/root/Desktop/hadoop-0.20.2目录下工作,一定要保持机器与外网联通。
4.修改/etc/profile
添加或修改: export HADOOP_HOME=/root/Desktop/hadoop-0.20.2(移动之后的工作目录) export OS_ARCH=i386
export OS_BIT=32
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$OS_ARCH/server:${HADOOP_HOME}/c++/Linux-$OS_ARCH-$OS_BIT/lib:/usr/local/lib:/usr/
lib export ANT_HOME=/usr/local/apache-ant-1.7.0 export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$ANT_HOME/bin #source /etc/profil
5.生成fuse-dfs
#cd $HADOOP_HOME/
#ant compile-c++-libhdfs -Dlibhdfs=1 -Dcompile.c++=1 (保证机器与外网相通)
#ln -s c++/Linux-$OS_ARCH-$OS_BIT/lib build/libhdfs
#ant compile-contrib -Dlibhdfs=1 -Dfusedfs=1
#cd /root/Desktop/hadoop-0.20.2/build/contrib/fuse-dfs #vi fuse_dfs_wrapper.sh,修改内容为: export OS_BIT=32
if [ "$HADOOP_HOME" = "" ]; then
export HADOOP_HOME=/root/Desktop/hadoop-0.20.2
fi
export PATH=$HADOOP_HOME/build/contrib/fuse_dfs:$PATH
for f in ls $HADOOP_HOME/lib/*.jar $HADOOP_HOME/*.jar ; do
exportCLASSPATH=$CLASSPATH:$f
done
if [ "$OS_ARCH" = "" ]; then
export OS_ARCH=i386
fi
if [ "$JAVA_HOME" = "" ]; then
exportJAVA_HOME=/usr/local/jdk1.6.0_20
fi
if [ "$LD_LIBRARY_PATH" = "" ]; then
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$OS_ARCH/server:/root/Desktop/hadoop-0.20.2/c++/Linux-i386-32/lib:/usr
/local/lib
fi
#./fuse_dfs $@
fuse_dfs $@
#chmod +x /root/Desktop/hadoop-0.20.2/build/contrib/fuse-dfs/fuse_dfs_wrapper.sh
#chmod +x /root/Desktop/hadoop-0.20.2/build/contrib/fuse-dfs/fuse_dfs
#ln -s/root/Desktop/hadoop-0.20.2/build/contrib/fuse-dfs/fuse_dfs_wrapper.sh /usr/local/bin
#ln -s/root/Desktop/hadoop-0.20.2/build/contrib/fuse-dfs/fuse_dfs /usr/local/bin
#mkdir /mnt/dfs #/usr/sbin/setenforce 0 暂时停用防火墙 #fuse_dfs_wrapper.sh dfs://hadoop1:9000 /mnt/dfs由此就成功挂载HDFS #umount /mnt/dfs 便卸载了HDFS
本帖最后由 pig2 于 2014-3-6 01:36 编辑
环境
OS Centos 5.3
Jdk1.6
Hadoop-2.20.1
Fuse-2.8.1
Apache-ant-1.7.1-bin.tar.gz
Ant是一种基于Java的build工具。理论上来说,它有些类似于(Unix)C中的make
1、Fuse安装tar zxvf fuse-2.8.1.tar.gz
cd fuse2.8.1
./configure --prefix=/usr
make
make install
modprobe fusevi /etc/sysconfig/modules/my.modules
#!/bin/sh
modprobe fuse >/dev/null 2>&1
chmod +x /etc/sysconfig/modules/my.modules2、Ant安装wget http://www.meisei-u.ac.jp/mirror/apache/dist/ant/binaries/apache-ant-1.7.1-bin.tar.gz
tar zxvf apache-ant-1.7.1-bin.tar.g
mv apache-ant-1.7.1-bin.tar.g /usr/local/ant3、环境变量设置export JAVA_HOME=/usr/local/1dk1.6
export HADOOP_HOME=/data/soft/hadoop-2.20.1
export OS_ARCH=i386
export OS_BIT=32 //如果系统是64位的,这里应该写64
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$OS_ARCH/server:${HADOOP_HOME}/build/c++/Linux-$OS_ARCH-$OS_BIT/lib:/usr/local/lib:/usr/lib
export ANT_HOME=/usr/local/ant
export PATH=$ANT_HOME/bin:$PATH4、libhdfs 制作cd $HADOOP_HOME/
ant compile-c++-libhdfs -Dlibhdfs=1 -Dcompile.c++=1
ln -s c++/Linux-$OS_ARCH-$OS_BIT/lib build/libhdfs5、fuse-dfscd $HADOOP_HOME
ant compile-contrib -Dlibhdfs=1 -Dfusedfs=16、fuse配置export JAVA_HOME=/usr/local/jdk1.6
export HADOOP_HOME=/data/soft/hadoop-2.20.1
export HADOOP_CONF_DIR=/data/soft/hadoop-0.20.1/conf
export OS_ARCH=i386
export OS_BIT=32
//以上都是新增加的内容
if [ "$HADOOP_HOME" = "" ]; then
export HADOOP_HOME=/usr/local/share/hadoop
fi
export PATH=$HADOOP_HOME/contrib/fuse_dfs:$PATH
for f in ls $HADOOP_HOME/lib/*.jar $HADOOP_HOME/*.jar ; do
exportCLASSPATH=$CLASSPATH:$f
done
if [ "$OS_ARCH" = "" ]; then
export OS_ARCH=amd64
fi
if [ "$JAVA_HOME" = "" ]; then
exportJAVA_HOME=/usr/local/java
fi
if [ "$LD_LIBRARY_PATH" = "" ]; then
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/$OS_ARCH/server:/usr/local/share/hdfs/libhdfs/:/usr/local/lib
fi
./fuse_dfs $@ //修改成以下内容
fuse_dfs $@//这里要把前面的./去掉,要不然挂载hdfs文件系统会找不到fuse_dfs文件7、设置文件权限chmod +x /data/soft/hadoop-2.20.1/build/contrib/fuse-dfs/fuse_dfs_wrapper.sh
chmod +x /data/soft/hadoop-2.20.1/build/contrib/fuse-dfs/fuse_dfs
ln -s /data/soft/hadoop-2.20.1/build/contrib/fuse-dfs/fuse_dfs_wrapper.sh /usr/local/bin
ln -s /data/soft/hadoop-2.20.1/build/contrib/fuse-dfs/fuse_dfs /usr/local/bin/
mkdir /mnt/dfs8、手动挂载hdfs文件系统fuse_dfs_wrapper.sh dfs://192.168.1.11:54310 /mnt/dfs9、开机自动挂载hdfs文件系统vi /etc/fstab
fuse_dfs_wrapper.sh dfs://192.168.1.11:54310 /mnt/dfs fuse rw,auto 0 0
页:
[1]