Skip to content

Instantly share code, notes, and snippets.

@larsgeorge
Created February 14, 2011 09:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save larsgeorge/825646 to your computer and use it in GitHub Desktop.
Save larsgeorge/825646 to your computer and use it in GitHub Desktop.
HBase Replication Notes
HBase 1:
506 wget http://apache.easy-webs.de//hbase/hbase-0.90.0/hbase-0.90.0.tar.gz
507 tar -zxvf hbase-0.90.0.tar.gz
508 cd hbase-0.90.0
522 cp -pR conf conf.2
523 vim conf/hbase-site.xml
524 cp conf/hbase-site.xml conf.2/
525 vim conf.2/hbase-site.xml
534 mv lib/hadoop-core-0.20-append-r1056497.jar lib/hadoop-core-0.20-append-r1056497.jar.original
535 cp /projects/cloudera/cdh/hadoop-0.20.2+737/hadoop-core-0.20.2+737.jar lib/
536 bin/start-hbase.sh
537 bin/stop-hbase.sh
550 tail -f logs/hbase-larsgeorge-{master,regionserver}-de1-app-mbp-2.log &
551 bin/hbase shell
create 'test', 'cf1'
disable 'test'
alter 'test', NAME => 'cf1', REPLICATION_SCOPE => '1'
enable 'test'
scan 'test'
start_replication
scan 'test'
create('test', { NAME => 'cf1', REPLICATION_SCOPE => 1})
add_peer('1', 'localhost:2181:/hbase-2')
start_replication
for i in 'a'..'z' do for j in 'a'..'z' do put 'test', "row-#{i}#{j}", "cf1:#{j}", "#{j}" end end
count 'test'
676 row(s) in 0.1770 seconds
HBase 2:
core-site.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:8020</value>
</property>
</configuration>
hbase-env.sh:
# Where log files are stored. $HBASE_HOME/logs by default.
export HBASE_LOG_DIR=${HBASE_HOME}/logs.2
# A string representing this instance of hbase. $USER by default.
export HBASE_IDENT_STRING=${USER}.2
hbase-site.xml:
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:8020/hbase-2</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/tmp/hbase-2-${user.name}</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.replication</name>
<value>true</value>
</property>
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase-2</value>
</property>
<property>
<name>hbase.master.port</name>
<value>60100</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60110</value>
</property>
<property>
<name>hbase.regionserver.port</name>
<value>60120</value>
</property>
<property>
<name>hbase.regionserver.info.port</name>
<value>60130</value>
</property>
</configuration>
501 cd /projects/opensource/hbase-0.90.0
508 vim conf.2/hbase-env.sh
513 HBASE_CONF_DIR=conf.2 bin/start-hbase.sh
515 tail -n 100 -f logs.2/hbase-larsgeorge.2-master-de1-app-mbp-2.log &
567 HBASE_CONF_DIR=conf.2 bin/hbase shell
517 HBASE_CONF_DIR=conf.2 bin/stop-hbase.sh
521 kill -9 $(cat /tmp/hbase-larsgeorge.2-{master,regionserver,zookeeper}.pid)
create('test', { NAME => 'cf1', REPLICATION_SCOPE => 1})
count 'test'
676 row(s) in 0.2230 seconds
ZooKeeper:
$ cat conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/tmp/zk-server
# the port at which the clients will connect
clientPort=2181
503 wget http://apache.openmirror.de//hadoop/zookeeper/zookeeper-3.3.2/zookeeper-3.3.2.tar.gz
504 tar -zxvf zookeeper-3.3.2.tar.gz
508 cd zookeeper-3.3.2
510 vim conf/zoo.cfg
513 bin/zkServer.sh start
Misc:
hbase(main):014:0> add_peer '1', 'localhost:2181:/hbase-2'
0 row(s) in 0.0580 seconds
hbase(main):015:0> start_replication
2011-02-11 18:04:58,347 INFO org.apache.hadoop.hbase.replication.ReplicationZookeeper: Replication is now started
0 row(s) in 0.0500 seconds
hbase(main):016:0> put 'test',
put 'test', 'row1', 'cf1', 'val1'
put 'test', 'row2', 'cf1', 'val2'
scan 'testtable'
scan 'test'
start_replication
put 'test', 'row3', 'cf1', 'val3'
scan 'test'
put 'test', 'row4', 'cf1', 'val4'
describe 'test'
flush 'test'
scan 'test'
describe 'test'
help
help 'replication'
disbale_peer '1'
disable_peer '1'
help 'replication'
add_peer '1', 'localhost:2181:/hbase-2'
exit
help 'replication'
remove_peer '1'
add_peer '1', 'localhost:2181:/hbase-2'
put 'test', 'row5', 'cf1', 'val5'
for i in 'a'..'z' do for j in 'a'..'z' do for k in 'a'..'z' do put 'test', "row-#{i}#{j}#{k}", "cf1:#{k}", "#{k}" end end end
for i in 'a'..'z' do for j in 'a'..'z' do put 'test', "row-#{i}#{j}", "cf1:#{j}", "#{j}" end end
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment