安装环境 ubuntu server 12.04
hadoop-1.0.2
1)创建hadoop用户和ssh-key- #创建hadoop用户
- leslie@Notebook:~$ sudo useradd -m -s /bin/bash -G sudo hadoop
- leslie@Notebook:~$ sudo su - hadoop
- #生成key
- hadoop@Notebook:~$ ssh-keygen -t rsa
- #本地ssh 认证。
- hadoop@Notebook:~$ ssh-copy-id -i .ssh/id_rsa.pub localhost
- hadoop@Notebook:~$ ssh localhost
2)安装jdk- hadoop@Notebook:~$ sudo apt-get install default-jdk
3) 安装hadoop
下载hadoop解压到/home/hadoop/目录下- #下载hadoop-1.0.2
- hadoop@Notebook:~$ wget -c http://archive.apache.org/dist/hadoop/core/stable/hadoop-1.0.2.tar.gz
- #解压到/home/hadoop目录下
- hadoop@Notebook:~$ tar xvzf http://archive.apache.org/dist/hadoop/core/stable/hadoop-1.0.2.tar.gz
- #建立软链接
- hadoop@Notebook:~$ ln -s hadoop-1.0.2 hadoop
- #添加/etc/profile
- export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386
export HADOOP_HOME=/home/hadoop/hadoop-1.0.2
export PATH=$PATH:$HADOOP_HOME/bin:$JAVA_HOME/bin
export HADOOP_HOME_WARN_SUPPRESS=1 #忽略hadoop的警告。
4)配置hadoop
1.修改conf/hadoop-env.sh,添加jdk支持
- export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386
如果ssh端口不是默认的22,在conf/hadoop-env.sh里改下。如:- export HADOOP_SSH_OPTS="-p 1234"
2 修改conf/core-site.xml,增加下面内容 - <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost:9000</value> //决定namenode
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/home/hadoop/tmp</value> //临时文件,有问题的时候,可以删除
- <description>A base for other temporary directories.</description>
- </property>
3.修改conf/hdfs-site.xml,增加下面内容
- <property>
- <name>dfs.name.dir</name>
- <value>/home/hadoop/name</value> //namenode持久存储名字空间,事务日志的本地路径
- </property>
- <property>
- <name>dfs.data.dir</name>
- <value>/home/hadoop/data</value> //datanode存放数据的路径
- </property>
- <property>
- <name>dfs.datanode.max.xcievers</name>
- <value>4096</value>
- </property>
- <property>
- <name>dfs.replication</name>
- <value>1</value> //数据备份的个数,默认是3
- </property>
4.修改conf/mapred-site.xml,增加下面内容
- <property>
- <name>mapred.job.tracker</name> //jobTracker的主机
- <value>localhost:9001</value>
- </property>
5修改conf/masters,这个决定那个是secondarynamenode6 .修改conf/slaves,这个是所有datanode的机器
5) 格式化hdfs文件系统的namenode- hadoop@Notebook:~$ hadoop namenode -format
6 ) 启动hadoop集群
- hadoop@Notebook:~$ hadoop/bin/start-all.sh
7) Hdfs操作
建立目录
- hadoop@Notebook:~$ hadoop dfs -mkdir zed
查看现有文件
- hadoop@Notebook:~$ hadoop dfs -ls
8) 关闭Hdfs
- hadoop@Notebook:~$ hadoop/bin/stop-all.sh
阅读(2790) | 评论(0) | 转发(1) |