1.解壓 hbase-1.2.6-bin.tar.gz,重命名,賦予權限給hadoop用戶html
sudo tar -zxvf hbase-1.2.6-bin.tar.gz sudo mv hbase-1.2.6 hbase sudo chown -R hadoop ./hbase
2. 添加環境變量java
sudo vim ~/.bashrc
export HBASE_HOME=/usr/local/hbase export HBASE_CONF_DIR=$HBASE_HOME/conf export HBASE_CLASS_PATH=$HBASE_CONF_DIR export PATH=$PATH:$HBASE_HOME/bin
使環境變量生效shell
source ~/.bashrc
4.修改hbase-site.xml文件vim
sudo vim /user/lcoal/hbase/conf/hbase-site.xmlbash
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hbase.rootdir</name> <value>hdfs://hadoop:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>hadoop</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/usr/lib/jvm/habse/hadoop/data/zookeeper/zkdata</value> </property> <property> <name>hbase.zookeeper.property.clientPort</name> <value>2181</value> </property> <property> <name>hbase.master</name> <value>hdfs://hadoop:60000</value> </property> <property> <name>hbase.coprocessor.abortonerror</name> <value>false</value> </property> </configuration>
5.修改hbase-env.shjvm
sudo vim /user/lcoal/hbase/conf/hbase-env.shoop
export JAVA_HOME=/usr/local/java-8-openjdk-amd64 export HBASE_MANAGES_ZK=true export HBASE_CLASSPATH=/usr/local/hadoop/conf
6. 啓動hadoop ./hadoop/sbin/start-all.shspa
7. 啓動hbase ./hbase/bin/start-hbase.sh 出現9個進程code
hadoop@hadoop:/usr/local/hadoop/sbin$ start-hbase.sh hadoop: starting zookeeper, logging to /usr/local/hbase/logs/hbase-hadoop-zookeeper-hadoop.out starting master, logging to /usr/local/hbase/logs/hbase-hadoop-master-hadoop.out OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0 OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0 starting regionserver, logging to /usr/local/hbase/logs/hbase-hadoop-1-regionserver-hadoop.out hadoop@hadoop:/usr/local/hadoop/sbin$ jps 14786 ResourceManager 15682 HMaster 16323 Jps 14548 SecondaryNameNode 14921 NodeManager 14346 DataNode 15578 HQuorumPeer 15819 HRegionServer 14190 NameNode hadoop@hadoop:/usr/local/hadoop/sbin$
8. hbase建表 ./hbase/bin/hbase shellserver
hadoop@hadoop:/usr/local/hadoop/sbin$ hbase shell SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] HBase Shell; enter 'help<RETURN>' for list of supported commands. Type "exit<RETURN>" to leave the HBase Shell Version 1.2.6, rUnknown, Mon May 29 02:25:32 CDT 2017 hbase(main):001:0> list TABLE test 1 row(s) in 0.2590 seconds => ["test"] hbase(main):002:0> create 'test2','cf1','cf2' 0 row(s) in 2.4520 seconds => Hbase::Table - test2 hbase(main):003:0> put 'test2','row1','cf1:name','java' 0 row(s) in 0.2220 seconds hbase(main):004:0> scan 'test2' ROW COLUMN+CELL row1 column=cf1:name, timestamp=1521690503935, value=java 1 row(s) in 0.0450 seconds hbase(main):005:0>
咱們下載zookeeper並解壓,重命名
sudo tar -zxvf zookeeper-3.4.10.tar.gz mv zookeeper-3.4.10 /usr/local/zookeeper
添加zookeeper環境變量
sudo vim ~/.bashrc
export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$PATH:$ZOOKEEPER_HOME/bin
使環境變量生效
source ~/.bashrc
修改zoo.cfg文件
cd zookeeper/conf cp zoo_sample.cfg zoo.cfg sudo vim zoo.cfg
zoo.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=/home/hadoop/zookeeper/data dataLogDir=/home/hadoop/zookeeper/logs clientPort=2181
啓動zookeeper ./zkServer.sh start
關閉zookeeper ./zkServer.sh stop
hadoop@hadoop:$ cd zookeeper/bin hadoop@hadoop:/usr/local/zookeeper/bin$ ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED hadoop@hadoop:/usr/local/zookeeper/bin$ jps 7889 QuorumPeerMain 7911 Jps hadoop@hadoop:/usr/local/zookeeper/bin$ ./zkServer.sh stop ZooKeeper JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED hadoop@hadoop:/usr/local/zookeeper/bin$
在hbase中使用zookeeper
只須要修改hbase-env.sh,將管理hbase的設置默認不適用自帶zookeeper(false)
使用zookeeper+hbase時須要先啓動zookeeper,在啓動hbase。
sudo vim /user/lcoal/hbase/conf/hbase-env.sh
export JAVA_HOME=/usr/local/java-8-openjdk-amd64 export HBASE_MANAGES_ZK=false export HBASE_CLASSPATH=/usr/local/hadoop/conf