1 | #!/bin/bash |
---|
2 | if [ ! -f /usr/src/hbase-*.tar.gz ]; then |
---|
3 | echo "Hbase tar ball not found at /usr/src/hbase-*.tar.gz!!" |
---|
4 | exit |
---|
5 | fi |
---|
6 | |
---|
7 | if [ ! -f /opt/hase* ]; then |
---|
8 | tar zxvf /usr/src/hbase-*.tar.gz -C /opt |
---|
9 | mv /opt/hbase-* /opt/hbase |
---|
10 | |
---|
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 |
---|
14 | |
---|
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 |
---|
20 | export HBASE_PID_DIR=/var/hbase/pid |
---|
21 | EOF |
---|
22 | |
---|
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> |
---|
31 | <property> |
---|
32 | <name>hbase.tmp.dir</name> |
---|
33 | <value>/var/hbase</value> |
---|
34 | </property> |
---|
35 | <property> |
---|
36 | <name>hbase.cluster.distributed</name> |
---|
37 | <value>true</value> |
---|
38 | </property> |
---|
39 | </configuration> |
---|
40 | EOF |
---|
41 | |
---|
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 |
---|
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 |
---|
58 | EOF |
---|
59 | |
---|
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 |
---|
74 | |
---|
75 | echo " Starting HBase ....." |
---|
76 | /bin/start-hbase |
---|
77 | fi |
---|