准备
约定
- [M] MODIFY
- [A] ADD
- [D] DELETE
- 所有操作在
hadoop
用户下
安装包
- jdk1.8
- hadoop-2.7.5
- hbase-1.4.8
- zookeeper-3.4.10
- apache-phoenix-4.14.1-HBase-1.4-bin
机器
[HOST-43] 172.16.11.43 hostname host-172-16-11-43
[HOST-44] 172.16.11.44 hostname host-172-16-11-44
http://hbase.apache.org/book.html#configuration
ssh、dns、ntp、ulimit
edit [HOST-43] and [HOST-44] machine /etc/hosts
[A] 172.16.11.43 host-172-16-11-43
[A] 172.16.11.44 host-172-16-11-44
Limits on Number of Files and Processes (ulimit)
ulimit -n
To configure ulimit settings on Ubuntu, edit /etc/security/limits.conf,
which is a space-delimited file with four columns.
Refer to the man page for limits.conf for details
about the format of this file. In the following example,
the first line sets both soft and hard limits for
the number of open files (nofile) to 32768 for
the operating system user with the username hadoop.
The second line sets the number of processes to 32000 for the same user.
1 | hadoop - nofile 32768 |
安装
zookeeper3.4.10
[HOST-43]
配置
client-port:2222
cp conf/zoo_sample.cfg conf/zoo.cfg
[M] conf/zoo.cfg
[M] dataDir=<path>
[A] dataLogDir=<path>
启动
bin/zkServer.sh start
start、stop、status、etc.
bin/zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
hadoop-2.7.5 (Cluster)
Master:[HOST-43]
Slave:[HOST-44]
配置
edit [HOST-43] and [HOST-44] machine ~/.bash_profile
[A] export HADOOP_HOME=/home/hadoop/hadoop/hadoop-2.7.5
[A] export PATH=$HADOOP_HOME/bin:$PATH
source ~/.bash_profile
HDFS
edit [HOST-43] and [HOST-44] <HADOOP_HOME>/etc/hadoop/core.site.xml
[A]
1 | <property> |
edit [HOST-43] and [HOST-44] <HADOOP_HOME>/etc/hadoop/hdfs.site.xml
[A]
1 |
|
edit [HOST-43] <HADOOP_HOME>/etc/hadoop/slaves,like this
**[D]** #localhost
**[A]** host-172-16-11-44
/** choice **/scp -pqr hadoop-2.7.5 hadoop-2.7.5-data hadoop@172.16.11.44:~/hadoop/
启动
启动 [HOST-43] NameNode:
<HADOOP_HOME>/sbin/hadoop-daemon.sh start namenode
启动 [HOST-44] DataNode:
<HADOOP_HOME>/sbin/hadoop-daemon.sh start datanode
VIEW
YARN
mapred-site.xml
配置
1 | <property> |
yarn-site.xm
配置
1 | <property> |
PS :slaves中既是datanode配置同时也是nodemanger的配置
启动
启动 [HOST-43] ResourceManager:
<HADOOP_HOME>/sbin/yarn-daemon.sh start resourcemanager
启动 [HOST-44] NodeManager:
<HADOOP_HOME>/sbin/yarn-daemon.sh start nodemanager
或者 [HOST-43] <HADOOP_HOME>/sbin/start-yarn.sh
验证MR
hadoop jar /home/hadoop/hadoop/hadoop-2.7.5/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.5.jar pi 5 5
VIEW
YARN-ResourceManager http://172.16.11.43:18088
hbase-1.4.8
master:[HOST-43]
regionserver:[HOST-44]
配置
edit [HOST-43] and [HOST-44] machine ~/.bash_profile
[A] export HBASE_HOME=/home/hadoop/hbase/hbase-1.4.8
[A] export PATH=$HBASE_HOME/bin:$PATH
source ~/.bash_profile
edit [HOST-43] and [HOST-44] <HBASE_HOME>/conf/hbase-env.sh
[M] # export JAVA_HOME=/usr/java/jdk1.6.0/ --> JAVA_HOME=<JAVA_HOME>
[M] # export HBASE_MANAGES_ZK=true --> export HBASE_MANAGES_ZK=false
edit [HOST-43] and [HOST-44] <HBASE_HOME>/conf/hbase-site.xml
[A]
1 | <property> |
edit [HOST-43] <HBASE_HOME>/conf/regionservers
,like this
[D] #localhost
[A] host-172-16-11-44
1 | host-172-16-11-44 |
/** choice **/scp -pqr hbase-1.4.8 hbase-1.4.8-data hadoop@172.16.11.44:~/hbase
启动
启动 [HOST-43] master:
<HBASE_HOME>/bin/hbase-daemon.sh start master
启动 [HOST-44] regionserver:
<HBASE_HOME>/bin/hbase-daemon.sh start regionserver
或者 [HOST-43] <HBASE_HOME>/sbin/start-hbase.sh
VIEW
HBase-Master http://172.16.11.44:16010
HBase-RegionSerion http://172.16.11.44:16030
phoenix4.14.1
-
expand installation tar
-
copy the phoenix server jar that is compatible with your HBase installation into the lib directory of every region server
-
restart the region servers
-
add the phoenix client jar to the classpath of your HBase client
配置
1 | copy phoenix-**[verion]**-server.jar to **[HOST-43]** and **[HOST-44]** <HBASE_HOME>/lib path. |
测试
SELECT DISTINCT(TABLE_NAME) FROM “SYSTEM”.“CATALOG”;
1 | create table ABC(id integer PRIMARY KEY,a varchar(500), b date, c integer); |
Note: 必须有主键,因为 HBase row key.
JDBC excuteBatch
edit hbase-site.xml
http://phoenix.apache.org/tuning.html
1 | <property> |
secodery index
edit hbase-site.xml
http://phoenix.apache.org/secondary_indexing.html
1 | <property> |