Company department of big data has been I very want to enter the zone, purely personal hobby, but because the big data department set up the selection, is a little Tony, so perfect to miss, regret face, urge the couple, don’t abandon, can learn some is a little more, who knows what time you will have the opportunity to promotion, this time, because the department integration, We also need to share part of the big data research and development work, and the main part happened to fall on our group. The leader said to me with a sly smile: You understand, young man, do a good job, huh? There is a movement, then this operator is what also don’t say, it doesn’t matter, anyway, lz like big data, this bottom can have a place, the silence already a long time of a virtual machine, begin, today’s content is to restore my own feel, to build on their PC practice, command at least of what to put, will continue to update the article starting behind the public no. : So, without further ado, let’s begin today’s topic

Hbase pseudo-distributed construction

Modify the hbase – env. Sh

Export JAVA_HOME = / opt/software/jdk1.8 export HBASE_MANAGES_ZK = trueCopy the code

The first configuration Java environment variable

The second HBase configuration on the local machine can start ZooKeeper and use it

Modify reginserver

node1

Modify the hbase – site. XML

<property>

 <name>hbase.rootdir</name>

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

</property>

<property>

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

 <value>true</value>

</property>

<property>

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

 <value>master</value>

</property>

<property>

 <name>dfs.replication</name>

 <value>1</value>

</property>
Copy the code

Hbase. rootdir Hbase storage path on the HDFS

Hbase. Cluster. Distributed configuration is distributed

Hbase.zookeeper. quorum Specifies the node on which ZooKeeper resides

Dfs. replication Configures the number of copies

Start the

Before startup, copy the hdFS-site. XML file in Hadoop to the hbase configuration file

Run the start-hbase.sh command in the bin directory to start hbase

Before starting hbase, ensure that Hadoop is running properly and files can be written

Because of this location, I’m storing my data in HDFS, not locally, if you want to store it locally, you just need to store it locally

 <value>hdfs://node1:9000/hbase</value>
Copy the code

This configuration path can be changed to local

Access using a browserhttp://master:16010, you can access the web management page similar to Hadoop

Now, the real thing

The actual operation

\1. Start the shell interface command: hbase shell

After the hbase service is successfully started, enter the hbase shell command and press Enter to go to the shell page.

\2. View the command help file: help

The command format is 1: help

In the shell interface, enter the help command and press Enter to display all command information of the shell.

Command format 2: help ‘command’

For example, to view the description of the create command, type help ‘create’

Press Enter to display instructions for the create command.

\3. Run the quit or exit command to exit the shell interface

Enter quit or exit and press Enter to exit the shell interface.

\4. Create table command: create

Format 1: create ‘table name’, ‘column family 1’, ‘column family 2’,……

For example, create a table with table name student, column family 1 base_info, column family 2 class_info, and column family 3 other_info.

Enter the command create ‘student’,’base_info’,’class_info’,’other_info’ and press Enter. The result is as follows:

Command format 2: create table NAME, {NAME = > ‘column family 1}, {NAME = >’ column family 2}, {NAME = > ‘column family 3,… }

For example, create a table whose name is school, column family 1 is base_info, column family 2 is teacher_info, and column family 3 is student_info.

Enter the command: create ‘school’, {NAME => ‘base_info’}, {NAME => ‘teacher_info’}, {NAME => ‘student_info’} The following information is displayed:

Note: There are many different command formats for creating tables, please refer to the help documentation.

\5. Command to list all tables: list

Mytable, School, Student, TB1, TB2;

\6. Query table structure information: describe or desc

Describe ‘table name’

For example, view student table structure information.

Enter the describe ‘student’ command as shown below:

\7. View table data command: scan

Syntax: scan ‘table’

For example: View student data.

Enter the command :scan ‘student’ and press Enter. The following output is displayed:

Select * from student;

\8. Insert, modify or update data command: put

When Hbase data is modified or updated, new data is added. However, data of an earlier version is not displayed or has been deleted.

Insert data command format: put ‘table name’, ‘row value’, ‘column family: Column name’, ‘data’

Example 1: add column name to stduent (row 1, base_info) and add data xiaoming

Enter the command: put ‘student’,’1′,’base’

To check whether the table has data, enter the command: scan ‘student’, press Enter, the following output is displayed:

Example 2: add grade to stduent (row 1, class_info) and add data 2018

Enter the command: put ‘student’,’1′,’class_info:grade’,’2018′ press Enter. The command output is as follows:

To check whether the table has data, enter the command: scan ‘student’, press Enter, the following output is displayed:

\9. Get a row of data command: get

Format 1: get ‘table name ‘,’ row’

For example, view the data in row 1 of the table stduent

Enter the command: get ‘student’,’1′ press Enter, the output is as follows:

Format 2: get ‘table name ‘,’ row ‘,’ column family’

For example, view the data for column name in column family base_info in row 1 of table STduent

Enter the command: get ‘student’,’1′,’ base_info:name’ and press Enter. The following output is displayed:

Format 3: get ‘table name ‘,’ row ‘,{COLUMN=>’ COLUMN family ‘,VERSIONS=> Version n} Obtains the latest N VERSIONS of a COLUMN family in a row.

Select * from student, row 1, class_info

Enter the command: get ‘student’,1,{COLUMN=>’class_info’,VERSIONS=>4}

Note: There are many different command formats for retrieving table data, please refer to the help documentation.

\10. Delete the data of the specified cell: delete

Command format: delete ‘table’, ‘row’, ‘column’, timestamp

Select base_info from student where name = ‘base_info’

Enter the commands: delete ‘student’,’1′,’base_info:name’,1533174244970

Before running the command, use scan to check table information. The result is as follows

\11. The number of rows in the statistics table command: count

Command format: count ‘table name’

For example, check the number of rows in the STUDen table

Enter the command: count ‘student’ and the result is as follows

\12. Clear table data: truncate

Truncate ‘table name’

For example, clear data in table TB2

Enter the truncate ‘tB2’ command to view table data before and after the command is executed using scan, as shown in the following figure

The data has been cleared.

Pay attention to

Xshell cannot delete: modify the file — property