Pasupathi Rajamanickam
Pasupathi Rajamanickam

Reputation: 2052

Hbase data deleted upon restart

I'm not sure what's happening. I created table yesterday in hbase using the following code.

I start hbase using this command.

hbase-2.0.0/bin$ ./start-hbase.sh

Code to create table

private void createStudentTable(String workspace) {
        List<ColumnFamilyDescriptor> colms = new ArrayList<>();
        colms.add(ColumnFamilyDescriptorBuilder.of("id"));
        colms.add(ColumnFamilyDescriptorBuilder.of("name"));


        TableDescriptor desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(workspace + "_an_data"))
                  .setColumnFamilies(colms)
                  .build();

        hbaseAdmin.createTable(desc); //class variable 
    }

I shutdown hbase using command

hbase-2.0.0/bin$ ./stop-hbase.sh

Turned off my system, next day woke up, start hbase.

Login to shell, running list command result it

TABLE                                                                           
0 row(s)

Am I misunderstanding something? hbase is not file memory database? Is it in-memory?

I used phoenix driver in DBeaver same behavior

Upvotes: 0

Views: 117

Answers (2)

Pasupathi Rajamanickam
Pasupathi Rajamanickam

Reputation: 2052

To give an example for @gagan's answer

Config File: /hbase-2.0.0/conf/hbase-site.xml

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/pasu/apps/hbase-2.0.0</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/pasu/apps/hbase-2.0.0/data</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
  </property>
</configuration>

Upvotes: 0

gagan singh
gagan singh

Reputation: 1611

By default the hbase.rootdir is in /tmp which is cleaned up every time you reboot. Update the hbase-site.xml to use a directory of your choice.

Upvotes: 2

Related Questions