1. 程式人生 > >Hbase本地模式、偽分佈模式、全分佈模式、HA的搭建

Hbase本地模式、偽分佈模式、全分佈模式、HA的搭建

一、搭建HBase本地模式

 

解壓:                                                                                              

tar -zxvf hbase-1.3.1-bin.tar.gz -C ~/training/                                                               

設定環境變數  vi ~/.bash_profile                                                                                    

 HBASE_HOME=/root/training/hbase-1.3.1                                                                        

 export HBASE_HOME                                                                                                                                                                                  

PATH=$HBASE_HOME/bin:$PATH                                                                                   

 export PATH      

生效環境變數                                                                                            

 source ~/.bash_profile                                                                                       

                                                                                                              

由於本地模式:不需要HDFS,儲存在Linux的檔案系統                                                                                

    在bigdata11上配置                                                                                              

                                                                                                            

建個目錄: mkdir data                                                                                            

修改檔案:conf/hbase-env.sh                                                                                      

export JAVA_HOME=/root/training/jdk1.8.0_144                                                              

                                                                                                            

核心配置檔案:  conf/hbase-site.xml                                                                                

<property>                                                                                                

  <name>hbase.rootdir</name>                                                                              

  <value>file:///root/training/hbase-1.3.1/data</value>                                                   

</property>                                                                                               

                                                                                                              

啟動HBase:start-hbase.sh                                                                                      

starting master, logging to /root/training/hbase-1.3.1/logs/hbase-root-master-bigdata11.out                

只有HMaster ,沒有RegionServer                                                                                          

                                                                                                              

                                                                                                            

2、偽分佈模式(bigdata11)                                                                                           

修改檔案:hbase-env.sh                                                                                           

HBASE_MANAGES_ZK =true     ## 使用HBase自帶的ZK                                                                 

                                                                                                          

核心配置檔案:  conf/hbase-site.xml                                                                                                                                                                                        

<!--HBase的資料儲存在HDFS對應目錄-->                                                                                

<property>                                                                                                

  <name>hbase.rootdir</name>                                                                              

  <value>hdfs://192.168.100.11:9000/hbase</value>                                                        

</property>                                                                                               

                                                                                                              

<!--是否是分散式環境-->                                                                                           

<property>                                                                                                

  <name>hbase.cluster.distributed</name>                                                                  

  <value>true</value>                                                                                     

</property>                                                                                           

                                                                                                              

<!--配置ZK的地址-->                                                                                            

<property>                                                                                                

  <name>hbase.zookeeper.quorum</name>                                                                     

  <value>192.168.100.11</value>                                                                          

</property>                                                                                         

                                                                                                              

<!--冗餘度-->                                                                                                

<property>                                                                                                

  <name>dfs.replication</name>                                                                            

  <value>1</value>                                                                                        

</property>                                                                                               

                                                                                                          

檔案regionservers:配置從節點地址                                                                                     

bigdata11                                                                                          

啟動Hbase

在HDFS上檢視自動生成的hbase目錄

 

用網頁的方式檢視Hbase

192.168.100.11:16010

 

建立’emp’表

create 'emp','depto','ename','job'  

查看錶結構  describe 'emp'

或者通過網頁檢視

                                                                                                          

3、全分佈模式:

在bigdata12 、 bigdata13 、 bigdata14  上搭建                                                                   

      解壓:tar -zxvf hbase-1.3.1-bin.tar.gz -C /root/training/

                                                                                                        

修改檔案:hbase-env.sh                                                                                           

export JAVA_HOME=/root/training/jdk1.8.0_144                                                              

HBASE_MANAGES_ZK true  ---> 使用HBase自帶的ZK                                                                 

                                                                                                              

核心配置檔案:  conf/hbase-site.xml                                                                                

                                                                                                            

<!--HBase的資料儲存在HDFS對應目錄-->                                                                                

<property>                                                                                                

  <name>hbase.rootdir</name>                                                                              

  <value>hdfs://192.168.100.12:9000/hbase</value>                                                        

</property>                                                                                               

                                                                                                              

<!--是否是分散式環境-->                                                                                           

<property>                                                                                                

  <name>hbase.cluster.distributed</name>                                                                  

  <value>true</value>                                                                                     

</property>                                                                                           

                                                                                                              

<!--配置ZK的地址-->                                                                                            

<property>                                                                                                

  <name>hbase.zookeeper.quorum</name>                                                                     

  <value>192.168.100.12</value>                                                                          

</property>                                                                                         

                                                                                                              

<!--冗餘度-->                                                                                                

<property>                                                                                                

  <name>dfs.replication</name>                                                                            

  <value>2</value>                                                                                        

</property>                                                                                               

                                                                                                              

<!--主節點和從節點允許的最大時間誤差-->                                                                                   

<property>                                                                                                

  <name>hbase.master.maxclockskew</name>                                                                  

  <value>180000</value>                                                                                   

</property>                                                                                               

                                                                                                          

檔案regionservers:配置從節點地址                                                                                     

192.168.100.13                                                                                           

192.168.100.14                                                                                           

                                                                                                          

複製到其他節點上                                                                                                    

scp -r /root/training/hbase-1.3.1/ [email protected]:/root/training                                                        

scp -r /root/training/hbase-1.3.1/ [email protected]:/root/training                                                        

啟動 Hbase叢集

 通過Web Console檢視

                                                                                                                                                     4、 Hbase HA 的實現               

在bigdata13再手動啟動一個HMaster                                                                                   

hbase-dae