[140] | 1 | #!/bin/bash |
---|
| 2 | if [ ! -f /usr/src/hbase-0.20.3.tar.gz ]; then |
---|
[141] | 3 | wget http://ftp.twaren.net/Unix/Web/apache/hadoop/hbase/hbase-0.20.3/hbase-0.20.3.tar.gz -O /usr/src/hbase-0.20.3.tar.gz |
---|
[140] | 4 | fi |
---|
| 5 | |
---|
[143] | 6 | if [ ! -f /opt/hase* ]; then |
---|
| 7 | tar zxvf /usr/src/hbase-0.20.3.tar.gz -C /opt |
---|
| 8 | ln -s /opt/hbase-* /opt/hbase |
---|
[141] | 9 | |
---|
[143] | 10 | cp /opt/hadoop/conf/core-site.xml /opt/hbase/conf |
---|
| 11 | cp /opt/hadoop/conf/hdfs-site.xml /opt/hbase/conf |
---|
| 12 | cp /opt/hadoop/conf/mapred-site.xml /opt/hbase/conf |
---|
[141] | 13 | |
---|
[140] | 14 | cat >> /opt/hbase/conf/hbase-env.sh << EOF |
---|
| 15 | export JAVA_HOME=$JAVA_HOME |
---|
| 16 | export HADOOP_CONF_DIR=/opt/hadoop/conf |
---|
| 17 | export HBASE_HOME=/opt/hbase |
---|
| 18 | export HBASE_MANAGES_ZK=true |
---|
| 19 | EOF |
---|
[141] | 20 | |
---|
[140] | 21 | cat > /opt/hbase/conf/hbase-site.xml << EOF |
---|
| 22 | <?xml version="1.0"?> |
---|
| 23 | <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> |
---|
| 24 | <configuration> |
---|
| 25 | <property> |
---|
| 26 | <name>hbase.rootdir</name> |
---|
| 27 | <value>hdfs://localhost:9000/hbase</value> |
---|
| 28 | </property> |
---|
[141] | 29 | <property> |
---|
| 30 | <name>hbase.cluster.distributed</name> |
---|
| 31 | <value>true</value> |
---|
| 32 | </property> |
---|
[140] | 33 | </configuration> |
---|
[141] | 34 | EOF |
---|
| 35 | |
---|
[143] | 36 | echo "export PATH=/opt/hbase/bin/:\$PATH" >> /etc/profile |
---|
| 37 | echo "/bin/stop-hbase" > ~/.bash_logout |
---|
| 38 | echo "/bin/stop-hadoop" >> ~/.bash_logout |
---|
| 39 | echo "/bin/stop-hbase" > /etc/skel/.bash_logout |
---|
| 40 | echo "/bin/stop-hadoop" >> /etc/skel/.bash_logout |
---|
[141] | 41 | |
---|
| 42 | cat > ~/hbase-test << EOF |
---|
| 43 | create 'test','data' |
---|
| 44 | put 'test','row1','data:1','v1' |
---|
| 45 | put 'test','row2','data:2','v2' |
---|
| 46 | put 'test','row3','data:3','v3' |
---|
| 47 | scan 'test' |
---|
| 48 | disable 'test' |
---|
| 49 | drop 'test' |
---|
| 50 | list |
---|
| 51 | exit |
---|
[142] | 52 | EOF |
---|
| 53 | |
---|
[143] | 54 | clear |
---|
| 55 | echo "==========================================" |
---|
| 56 | echo " !! NOTE !! " |
---|
| 57 | echo " please 'source /etc/profile' to update " |
---|
| 58 | echo " current \$PATH environment variables or " |
---|
| 59 | echo " login again to update \$PATH variables. " |
---|
| 60 | echo " . " |
---|
| 61 | echo " run 'start-hbase' to start hbase daemons." |
---|
| 62 | echo " run 'stop-hbase' to stop hbase daemons. " |
---|
| 63 | echo " run 'hbase shell hbase-test' to test " |
---|
| 64 | echo " hbase services. " |
---|
| 65 | echo "==========================================" |
---|
| 66 | |
---|
| 67 | echo " Starting HBase ....." |
---|
| 68 | /bin/start-hbase |
---|
| 69 | fi |
---|