1. Introduction to Hbase
HBase is a highly reliable, high-performance, column-oriented, and scalable distributed storage system. HBase technology can be used to build large-scale structured storage clusters on cheap PC Servers.
HBase is an open source implementation of Google Bigtable. Similar to Google Bigtable's use of GFS as its file storage system, HBase uses Hadoop HDFS as its file storage system; Google runs MapReduce to process massive data in Bigtable, and HBase also uses Hadoop MapReduce to process HBase. of massive data; Google Bigtable uses Chubby as a collaborative service, and HBase uses Zookeeper as a counterpart.
2. Hbase installation steps
1. HBase single-click version (standalone) installation (take hbase-1.1.3-bin.tar.gz as an example, in node5)
1) Upload to Linux
2) Unzip
tar -zxvf hbase-1.1.3-bin.tar.gz
3) Configure JAVA_HOME in hbase-env.sh, the content is
export JAVA_HOME=/usr/java/jdk1.7.0_79
4) Configure hbase-site.xml, the content is
<property> <name>hbase.rootdir</name> <value>file:///opt/data/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/opt/data/zkData</value> </property>
5) Start
cd /opt/sxt/soft/hbase-1.1.3 bin/start-hbase.sh
6) Check
By entering jps, you can view the HMaster process
7) Enter the HBase command control line
bin/hbase shell
All commands can be viewed by typing help
Note: (1) The startup of HBase must start zookeeper, but it has its own, so the stand-alone version of HBase does not need to build and start the zookeeper cluster
(2) When starting the stand-alone version of HBase, do not start zookeeper outside
(3) Modify the configuration file to notify HBase to start its own zookeeper, and modify hbase-env.sh
export HBASE_MANAGES_ZK=true
2. Distributed HBase cluster installation (four machines, node5, node6, node7, node8, where node8 is used to configure the standby master, which can be unmatched)
1) Prerequisites for HBase cluster startup
(1) The Hadoop cluster should be started normally
start-all.sh
(2) The Zookeeper cluster starts normally
zkServer.sh start zkServer.sh status
2) Configure hbase-site.xml, the content is
// The value of hbase.rootdir is the value of fs.defaultFS in the configured hadoop // View through vi /home/hadoop-2.5.1/etc/hadoop/core-site.xml <property> <name>hbase.rootdir</name> <value>hdfs://zxl/hbase</value> // If the hdfs of a single node is configured, it can be configured as follows // <value>hdfs://node5:9000/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.zookeeper.quorum</name> <value>node5,node6,node7</value> </property>
3) Configure regionservers, the content is
node5 node6 node7
Configure backup-masters (this step can not be configured, configure the standby master node)
node84) Configure the hadoop configuration folder address to hbase-env.sh
(1) Remove the export HBASE_MANAGES_ZK comment and set it to false (default is true)
// Indicates that the built-in zookeeper is not used export HBASE_MANAGES_ZK=false
(2) Remove the export HBASE_CLASSPATH comment and configure
export HBASE_CLASSPATH=/home/hadoop-2.5.1/etc/hadoop
(3) Remove the export JAVA_HOME comment and configure
export JAVA_HOME=/usr/java/jdk1.7.0_79
5. Copy (distribute) the entire hbase file to node6 and node7
scp -r /opt/sxt/soft/hbase-1.1.3 root@node6:/opt/sxt/soft/ scp -r /opt/sxt/soft/hbase-1.1.3 root@node7:/opt/sxt/soft/ // If equipped with master scp -r /opt/sxt/soft/hbase-1.1.3 root@node8:/opt/sxt/soft/
6) Configure the environment variables of hbase (the stand-alone version can also be configured), vi ~/.bash_profile, the content is
export HBASE_HOME=/opt/sxt/soft/hbase-1.1.3 export PATH=$PATH:$HBASE_HOME/bin
After saving source ~/.bash_profile
7) Start
start-hbase.sh
8) Test
(1) Browser access: node5:16010 (the page is displayed normally, that is, the construction is successful)
(2) Enter the command line console: hbase shell
3. Simple example
To backspace in hbase, you need to press ctrl plus the backspace key, no data is deleted, only the version is updated
create 't1', 'f1', 'f2', 'f3' //t1 is the table name, f1,2,3 are the column families desc 't1' //View the information of table t1 put 't1', '123', 'f1:name', 'zs' //t1, table name; 123, row key; name, column name of column family f1 put 't1', '123', 'f1:sex', '1' get 't1','123','f1' alter 't1', { NAME => 'f1', VERSIONS => 3 } //Modify the version of the column family put 't1', '123', 'f1:sex', '2' get 't1','123',{COLUMN => 'f1:sex' , VERSIONS => 3} //Get the values of the three versions of f1:sex put 't1', '123', 'f2:sex', '2' scan 't1' //View the information of table t1 flush 't1' //Enter the contents of the memstore into the physical storefile drop 't1' //Can't drop at this time, you must first change the table to disable disable ‘t1’At this time, you can view the storage status through the browser: node5:50070, the path is:
/hbase/data/default, you can see the t1 table
Note : If you are not familiar with a command, enter the command directly, such as enter get, you will get The usage syntax of get