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