linux下从安装JDK到安装ssh到hadoop单机伪分布式部署

环境: ubuntu 10.10 JDK1.6.0.27 hadoop 0.20.2

一. ubuntu 下 JDK 的安装:

1. 下载jdk-6u27-linux-i586.bin

2. 拷贝到/usr/java,设置文件的操作权限

3. $ ./jdk-6u27-linux-i586.bin开始安装

4. 设置环境变量 vi /etc/profile 在文件最后添加

JAVA_HOME=/usr/Java/jdk1.6.0_27
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH JAVA_HOME CLASSPATH

5. 设置用户安装的JDK为默认JDK,执行

$ update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0_12/bin/java 300
$ update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0_12/bin/javac 300

$ update-alternatives --config java

6. 输入 java -version 成功安装

二.ubuntu下安装ssh:

1. $ sudo apt-get install openssh-server

2. 启动ssh /etc/init.d/ssh start

3. $ ps -e | grep ssh 来验证是否启动sshserver

4. 免密码化

$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

三.ubuntu 下安装 hadoop:

1. 下载hadoop-0.20.2.tar.gz,放在/usr/hadoop 下载地址http://apache.etoak.com//hadoop/core/

2. 解压$ tar zxvf hadoop-0.20.2.tar.gz

3. 修改hadoop配置文件

conf/hadoop-env.sh 修改JAVA_HOME选项:

export JAVA_HOME=/usr/java/jdk.1.6.0_27

4. 伪分布式单机配置

conf/core-site.xml

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>fs.default.name</name> <value>hdfs://localhost:9000</value> </property> </configuration>
conf/hdfs-site.xml:

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>

conf/mapred-site.xml:

<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>mapred.job.tracker</name> <value>localhost:9001</value> </property> </configuration>
5. 创建hdfs文件系统

$ bin/hadoop namenode -format

6. 启动hadoop 需要先启动ssh $ /etc/init.d/ssh start

$ bin/hadoop start-all.sh

7. 在hadoop下创建test目录,然后建立file1.txt file2.txt 写入几个单词;将hadoop/test下的测试文件上传到hadoop 文件系统中

$ bin/hadoop dfs -put ./test input

8. 运行wordCount例子

$ bin/hadoop jar hadoop-0.20.2-examples.jar wordcount input output

9. 把结果从dfs上拷贝下来

$ bin/hadoop dfs -get output output

10. 查看结果

$ cat output/* 也可以直接查看 $ bin/hadoop dfs -cat output/*

11. 停止hadoop运行

$ bin/hadoop stop-all.sh

12. 关闭ssh-server

$ /etc/init.d/ssh stop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值