NameNode: 192.168.229.132
DataNode: 192.168.229.133/192.168.229.134
--------------------------------------------------------------------------------
配置 Hadoop
无密码SSH
首先是NameNode需要通过ssh来访问DataNode,配置一个无密码的ssh
NameNode上生成公钥私钥
$ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
把公钥放到tmp目录,并且scp到每一个DataNode
$cp ~/.ssh/id_dsa.pub /tmp
在NameNode和DataNode都执行这个,完成配置
$cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys
配置文件 (其中涉及到的目录会自动创建)
conf/hadoop-env.sh
# The java implementation to use. Required.
export JAVA_HOME=/usr/jdk1.6.0_25
conf/core-site.xml (如果要使用HIVE,就需要把红色的IP改成主机名,否则会有Wrong FS错误)
<configuration>
<property>
<!-- 用于dfs命令模块中指定默认的文件系统协议 -->
<name>fs.default.name</name>
<value>hdfs://192.168.229.132:9000</value>
</property>
<!-- 设置一个比较小的日志尺寸 -->
<property>
<name>hadoop.logfile.size</name>
<value>10</value>
</property>
</configuration>
conf/hdfs-site.xml
<configuration>
<property>
<!-- DFS中存储文件命名空间信息的目录 -->
<name>dfs.name.dir</name>
<value>/u01/app/data/dfs.name.dir</value>
</property>
<property>
<!-- DFS中存储文件数据的目录 -->
<name>dfs.data.dir</name>
<value>/u01/app/data/dfs.data.dir</value>
</property>
</configuration>
conf/mapred-site.xml
<configuration>
<property>
<!-- 用来作JobTracker的节点的(一般与NameNode保持一致) -->
<name>mapred.job.tracker</name>
<value>192.168.229.132:9001</value>
</property>
<property>
<!-- map/reduce的系统目录(使用的HDFS的路径) -->
<name>mapred.system.dir</name>
<value>/u01/app/data/mapred.system.dir</value>
</property>
<property>
<!-- map/reduce的临时目录(可使用“,”隔开,设置多重路径来分摊磁盘IO) -->
<name>mapred.local.dir</name>
<value>/u01/app/data/mapred.local.dir</value>
</property>
</configuration>
主从配置
conf/masters
192.168.229.132
conf/slaves
192.168.229.133
192.168.229.134
在NameNode进行了所有的配置之后,通过scp把hadoop安装目录同步到DataNode。然后在NameNode进行格式化和启动。
--------------------------------------------------------------------------------
配置 HBase
$vi /etc/hosts (HBase使用机器名称,在hosts里面必须配置集群里面的机器)
127.0.0.1 localhost
192.168.229.132 ubuntu02
192.168.229.133 ubuntu03
192.168.229.134 ubuntu04
conf/hbase-env.sh (这里)
# The java implementation to use. Java 1.6 required.
export JAVA_HOME=/usr/jdk1.6.0_25
# Extra Java CLASSPATH elements. Optional.
export HBASE_CLASSPATH=/u01/app/hadoop/conf
# Tell HBase whether it should manage it's own instance of Zookeeper or not.
export HBASE_MANAGES_ZK=true
conf/hbase-site.xml (红色部分必须使用主机名称,其他部分可以使用IP)
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://ubuntu02:9000/u01/app/data/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master</name>
<value>hdfs://192.168.229.132:60000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>192.168.229.132, 192.168.229.133, 192.168.229.134</value>
</property>
</configuration>
conf/regionservers (和Hadoop的slaves文件一致)
192.168.229.133
192.168.229.134
通过scp把hbase安装目录同步到DataNode
----------------------------------------------------------------------------------------------
配置 Hive
MySQL存储元数据 (安装过程见这里)
创建数据库的时候,必须使用latin1作为字符集,否则会有错误信息Specified key was too long; max key length is 767 bytes
mysql> create database hivedb default character set latin1;
mysql> create user 'hive'@'localhost' identified by 'hive';
mysql> grant all on hivedb.* to 'hive'@'localhost';
Hive 配置信息 (Hive仅需要在Master节点安装配置即可)
bin/hive-config.sh (可以设置 .profile 文件来略过这步)
export JAVA_HOME=/usr/jdk1.6.0_25
export HIVE_HOME=/u01/app/hive
export HADOOP_HOME=/u01/app/hadoop
conf/hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hivedb?createDatabaseIfNotExist=true</value>
<description>JDBC connect string FOR a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name FOR a JDBC metastore</description> </property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>username TOUSE against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>password TOUSE against metastore database</description>
</property>
MySQL 驱动包
下载mysql-connector-java-5.1.18-bin.jar文件,并放到$HIVE_HOME/lib目录下
测试
hadoop@ubuntu02:/u01/app/hive$ bin/hive
Logging initialized using configuration in jar:file:/u01/app/hive-0.8.1-bin/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/hadoop/hive_job_log_hadoop_201203201733_2122821776.txt
hive> show tables;
OK
tb
Time taken: 2.458 seconds
hive>