|
一、hadoop安装
虚拟机(centos7)
Master:192.168.0.228
Slave:192.168.0.207
软件
apache-hive-1.2.1-bin.tar.gz
hadoop-2.6.0-cdh5.4.8.tar.gz
jdk-8u65-linux-x64.tar.gz
mysql-connector-java-5.1.31-bin.jar
hbase-0.98.15-hadoop2-bin.tar
zookeeper-3.4.6.tar
1.关闭防火墙
Systemctl disable firewalld.service
Systemctl stop firewalld.service
Setenforce 0
Vim /etc/selinux/config 永久关闭
将SELINUX=enforce改为SELINUX=disable
2.配置主机名
192.168.0.228: echo “master” > /etc/hostname
192.168.0.207: echo “slave” > /etc/hostname
3.主机间解析
在两台机器/etc/hosts文件下添加ip地址和主机名
4.配置SSH互信
master
yum -y install sshpass
ssh-keygen 一路回车
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.220
slave
yum -y install sshpass
ssh-keygen 一路回车
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.201
如图,OK
5.安装JDK
两台机器都需要配置
tar zxvf jdk-8u65-linux-x64.tar.gz
mv jdk1.8.0_65 /usr/jdk
设置环境变量
Vim /etc/profile
export JAVA_HOME=/usr/jdk
export JRE_HOME=/usr/jdk/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
执行 source /etc/profile
测试
java -version,如图
6.安装Hadoop
tar zxvf hadoop-2.6.0-cdh5.4.8.tar.gz
mv hadoop-2.6.0-cdh5.4.8 /usr/hadoop
cd /usr/hadoop
mkdir -p dfs/name
mkdir -p dfs/data
mkdir -p tmp
6.1编辑配置文件
Salves
yarn-env.sh
Yarn-site.xml
mapred-site.xml
hdfs-env.sh
core-site.xml
Hadoop-env.sh
cd /usr/hadoop/etc/hadoop
vim slaves
192.168.0.220 #添加slaveIP
vim hadoop-env.sh / vim yarn-env.sh
export JAVA_HOME=/usr/jdk #加入java变量
Vim core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://192.168.0.228:9000</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131702</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/usr/hadoop/tmp</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>*</value>
</property>
</configuration>
Vim hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>:/usr/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>:/usr/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>192.168.0.228:9001</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
Vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>192.168.0.228:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>192.168.0.228:19888</value>
</property>
</configuration>
Vim yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>192.168.0.228:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>192.168.0.228:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>192.168.0.228:8031</value>
</property>
<property>
<name>yarn.resourcemanager.admin.address</name>
<value>192.168.0.228:8033</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>192.168.0.228:8088</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>768</value>
</property>
</configuration>
把目录拷贝到slave机器上
scp -r /usr/hadoop root@192.168.0.207:/usr/
格式化namenode
./bin/hdfs namenode -format
启动hdfs
./sbin/start-dfs.sh ./sbin/start-yarn.sh
使用jps测试
访问192.168.0.228:50070
192.168.0.228:8088
安装MySQL和Hive
本地模式:这种模式是将元数据保存在本地数据库中(一般是MySQL)。这样可以支持多用户,多会话。
MySQL:
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
systemctl start mysql 启动
mysqladmin -uroot password ‘password’为root设置密码
mysql -uroot -ppassword
Create database hive; 创建hive库
grant all on hive.* to 'hive'@'localhost' identified by ‘hive’; 授权
Hive
tar zxf apache-hive-1.2.1-bin.tar.gz
mv apache-hive-1.2.1-bin/ /usr/hadoop/hive
配置变量
vim /etc/profile
export HIVE_HOME=/usr/hadoop/hive
export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$PATH
执行 source /etc/profile
mv mysql-connector-java-5.1.31-bin.jar /usr/hadoop/hive/lib
将JDBC驱动包拷贝到hive的lib下
cd /usr/hadoop/hive/conf
Cp hive-default.xml.template hive-site.xml
Vim hive-site.xml 更改配置文件
Cd /usr/hadoop/hive/bin/
启动Hive
安装zookeeper和Hbase
1.Zookeeper
Master配置如下:
tar zxf zookeeper-3.4.6.tar
mv zookeeper-3.4.6 /usr/hadoop/zookeeper
更改文件的拥有者
Chown -R root:root /usr/hadoop/zookeeper
cd /usr/hadoop/zookeeper
mkdir data 创建zookeeper数据存储目录
配置变量 vim /etc/profile
加入export ZOOKEEPER_HOME=/usr/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
执行 source /etc/profile
配置文件存放在conf/目录下,将zoo_sample.cfd文件名称改为zoo.cfg, 配置如下:
Cp zoo_sample.cfd zoo.cfg
Vim zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/usr/hadoop/zookeeper/data
clientPort=2181
输入master和slave的ip地址或主机名:
server.1=192.168.0.228:2888:3888
server.2=192.168.0.207:2888:3888
mkdir data/myid 创建myid文件
Vim myid
填写zoo.cfg中本机ip前面server.后边的数字
1
将文件拷贝器slave节点
scp -r /usr/hadoop/zookeeper/ root@192.168.0.207:/root/hadoop/
Slave配置:
配置变量 vim /etc/profile
加入export ZOOKEEPER_HOME=/usr/hadoop/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
执行 source /etc/profile
Cd /usr/hadoop/zookeeper/data
mkdir data/myid 创建myid文件
Vim myid
填写zoo.cfg中本机ip前面server.后边的数字
2
启动:
[iyunv@master bin]# /usr/hadoop/zookeeper/bin/zkServer.sh start
输入jps查看,如图
安装Hbase
1、tar解压hbase安装包
2、配置hbase
a、/conf/hbase-env.sh
export JAVA_HOME= /usr/jdk
export HBASE_MANAGES_ZK=false (可以启用hbase自带的zookeeper,这样也 不用单独安装zookeeper了,如单独安装了,配为false)
b、conf/hbase-site.xml
该配置采用了hbase自带的zookeeper
<configuration>
<property>
<name>hbase.rootdir</name> s
<value>hdfs://master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>slave1,slave2,slave3</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
<description>
</description>
</property>
</configuration>
单独安装的zookeeper采用如下配置
regionservers<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master,slave1,slave2,slave3</value>
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
<description>
</description>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>
/home/hadoop/zk</value>
<description>
</description>
</property>
</configuration>注意hbase.rootdir配置需要与hadoop的配置一致。
c、conf/regionservers
slave1
slave2
slave3
到此hbase的配置已完成,用scp命令复制到slave1~salve3中。
启动hbase,
start-hbase.sh
用jps观看是否启动正常,或通过浏览器查看,master:60010。
|
|