1、大数据时代背景
移动互联、社交网络、电子商务导致各种数据迅速膨胀并变大。
1 PB = 1,024 TB = 1,048,576 GB =1,125,899,906,842,624 Bytes
1 EB = 1,024 PB = 1,048,576 TB = 1,152,921,504,606,846,976 Bytes
1 ZB = 1,024 EB = 1,180,591,620,717,411,303,424 Bytes
1 YB = 1,024 ZB = 1,208,925,819,614,629,174,706,176 Bytes

数据能为我们带来什么?------商业价值
海量数据如何处理?------Hadoop

MapReduce------并行计算框架
BigTable------join耗费资源,列式存储
创建者:Doug Cutting 棕黄色的大象

Hadoop安装:
3台虚拟机
集群模式

vim /etc/sysconfig/network 修改主机名:HOSTNAME=h101
重启虚拟机 init 6
vim /etc/sysconfig/network-scripts/ifcfg-eth0 修改虚拟机的主机IP

service network restart 网卡生效
vim /etc/hosts 修改hosts做映射
输入:192.168.16.101 h101
192.168.16.102 h102
192.168.16.103 h103
配置完后 :ssh h102 直接跳到h102
创建Hadoop用户:useradd hadoop
password hadoop
三台虚拟机安装JDK
tar -zxvf jdk.XX.tar.gz -C /usr/
配置环境变量 vim /etc/profile

让环境变量生效 source /etc/profile 或者init 6
验证环境变量生效 /usr/jdk1.7/bin/java -version
1、上传并解压Hadoop安装包
2、在conf文件夹下的hadoop-env.sh 最后一行添加
export JAVA_HOME=/usr/jdk1.7.0_25/
3、修改core-site.xml
<property>
<name>fs.default.name</name>
<value>hdfs://h101:9000</value>
</property>
4、修改hdfs-site.xml
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
5、修改mapred-site.
<property>
<name>mapred.job.tracker</name>
<value>h101:9001</value>
</property>
6、修改masters
localhost修改为主节点主机名:h101
7、修改slaves
localhost修改为从节点主机名:h102
h103
8、拷贝到其他两个节点
scp -r /home/hadoop/hadoop-0.20.2-cdh3u5 h103:/home/hadoop/
9、授权:所有节点上的hadoop-0.20.2-cdh3u5目录的所有者改为Hadoop用户
chown hadoop.hadoop /usr/local/hadoop-0.20.2-cdh3u5/ -R
10、免密钥操作配置SSH服务:Hadoop 用户下
ssh-keygen -t rsa
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h101
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h102
ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h103
11、namenode格式化:
cd /home/hadoop/hadoop-0.20.2-cdh3u5
bin/hadoop namenode -format
12、验证
bin/start-all.sh 开启服务
jps查看进程:
分布式文件系统HDFS
hadoop2.0默认大小是128M。









Hadoop基本命令
$hadoop_home/bin/hadoop fs <args>
hadoop fs -ls/lsr uri
实际例子:./hadoop fs -ls hdfs://h101:9000/
在主节点上可以简写成 ./hadoop fs -ls /
cat 显示一个或多个文件内容到控制台
put 将本地一个文件或多个文件导入HDFS
get 下载

打开安全模式:./hadoop dfsadmin -safemode enter
关闭安全模式:./hadoop dfsadmin -safemode leave
安全模式下不能删除文件
删除文件:./hadoop fs -rmr /a.txt
./hadoop dfsadmin -report
MapReduce介绍



网友评论