[140] | 1 | #!/bin/bash |
---|
[232] | 2 | if [ ! -f /usr/src/hbase-*.tar.gz ]; then |
---|
| 3 | echo "Hbase tar ball not found at /usr/src/hbase-*.tar.gz!!" |
---|
| 4 | exit |
---|
[140] | 5 | fi |
---|
| 6 | |
---|
[143] | 7 | if [ ! -f /opt/hase* ]; then |
---|
[232] | 8 | tar zxvf /usr/src/hbase-*.tar.gz -C /opt |
---|
[241] | 9 | mv /opt/hbase-* /opt/hbase |
---|
[141] | 10 | |
---|
[143] | 11 | cp /opt/hadoop/conf/core-site.xml /opt/hbase/conf |
---|
| 12 | cp /opt/hadoop/conf/hdfs-site.xml /opt/hbase/conf |
---|
| 13 | cp /opt/hadoop/conf/mapred-site.xml /opt/hbase/conf |
---|
[141] | 14 | |
---|
[140] | 15 | cat >> /opt/hbase/conf/hbase-env.sh << EOF |
---|
| 16 | export JAVA_HOME=$JAVA_HOME |
---|
| 17 | export HADOOP_CONF_DIR=/opt/hadoop/conf |
---|
| 18 | export HBASE_HOME=/opt/hbase |
---|
| 19 | export HBASE_MANAGES_ZK=true |
---|
[241] | 20 | export HBASE_PID_DIR=/var/hbase/pid |
---|
[140] | 21 | EOF |
---|
[141] | 22 | |
---|
[140] | 23 | cat > /opt/hbase/conf/hbase-site.xml << EOF |
---|
| 24 | <?xml version="1.0"?> |
---|
| 25 | <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> |
---|
| 26 | <configuration> |
---|
| 27 | <property> |
---|
| 28 | <name>hbase.rootdir</name> |
---|
| 29 | <value>hdfs://localhost:9000/hbase</value> |
---|
| 30 | </property> |
---|
[141] | 31 | <property> |
---|
[241] | 32 | <name>hbase.tmp.dir</name> |
---|
| 33 | <value>/var/hbase</value> |
---|
| 34 | </property> |
---|
| 35 | <property> |
---|
[141] | 36 | <name>hbase.cluster.distributed</name> |
---|
| 37 | <value>true</value> |
---|
| 38 | </property> |
---|
[140] | 39 | </configuration> |
---|
[141] | 40 | EOF |
---|
| 41 | |
---|
[143] | 42 | echo "export PATH=/opt/hbase/bin/:\$PATH" >> /etc/profile |
---|
| 43 | echo "/bin/stop-hbase" > ~/.bash_logout |
---|
| 44 | echo "/bin/stop-hadoop" >> ~/.bash_logout |
---|
| 45 | echo "/bin/stop-hbase" > /etc/skel/.bash_logout |
---|
| 46 | echo "/bin/stop-hadoop" >> /etc/skel/.bash_logout |
---|
[141] | 47 | |
---|
| 48 | cat > ~/hbase-test << EOF |
---|
| 49 | create 'test','data' |
---|
| 50 | put 'test','row1','data:1','v1' |
---|
| 51 | put 'test','row2','data:2','v2' |
---|
| 52 | put 'test','row3','data:3','v3' |
---|
| 53 | scan 'test' |
---|
| 54 | disable 'test' |
---|
| 55 | drop 'test' |
---|
| 56 | list |
---|
| 57 | exit |
---|
[142] | 58 | EOF |
---|
| 59 | |
---|
[232] | 60 | cat >> /etc/profile << EOF |
---|
| 61 | echo "============================================" |
---|
| 62 | echo " Use 'start-hadoop' to start hadoop daemons." |
---|
| 63 | echo " Use 'start-hadoop' to stop hadoop daemons." |
---|
| 64 | echo " ." |
---|
| 65 | echo " run 'start-hbase' to start hbase daemons. " |
---|
| 66 | echo " run 'stop-hbase' to stop hbase daemons. " |
---|
| 67 | echo " run 'hbase shell hbase-test' to test " |
---|
| 68 | echo " hbase services. " |
---|
| 69 | echo " ." |
---|
| 70 | echo " Use 'jps' to check java process for " |
---|
| 71 | echo " troubleshooting. " |
---|
| 72 | echo "============================================" |
---|
| 73 | EOF |
---|
[143] | 74 | |
---|
| 75 | echo " Starting HBase ....." |
---|
| 76 | /bin/start-hbase |
---|
[236] | 77 | fi |
---|