forked from CurleySamuel/PyBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_hbase.bash
141 lines (112 loc) · 3.96 KB
/
setup_hbase.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
set -xueo pipefail
sudo apt-get update
sudo apt-get -y dist-upgrade
# # not super necessary, but makes work within the VM more pleasant
sudo apt-get -y install git zsh htop curl
sudo mkdir -p -m777 /mnt/external/clones
sudo chsh -s /bin/zsh vagrant
sudo apt-get -y install python-pip python-virtualenv python-software-properties python-dev debconf-utils
sudo add-apt-repository -y 'ppa:webupd8team/java'
sudo apt-get update
echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get -y install oracle-java7-installer oracle-java7-set-default
sudo mkdir -p -m0755 /data
sudo chown vagrant:vagrant /data
cat > /home/vagrant/.ssh/config <<EOF
Host localhost
StrictHostKeyChecking no
Host 0.0.0.0
StrictHostKeyChecking no
EOF
if [[ ! -f /home/vagrant/.ssh/id_rsa ]]; then
ssh-keygen -t rsa -N '' -C "for hadoop" -f /home/vagrant/.ssh/id_rsa
fi
cat /home/vagrant/.ssh/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
cd
if [[ -f /vagrant/Dropbox\ \(Personal\)/binaries/hadoop-2.7.1.tar.gz ]]; then
cp /vagrant/Dropbox\ \(Personal\)/binaries/hadoop-2.7.1.tar.gz .
elif [[ ! -f hadoop-2.7.1.tar.gz ]]; then
wget http://apache.osuosl.org/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz
fi
sudo mkdir -p -m0755 /data/hadoop
sudo chown -R vagrant:vagrant /data/hadoop
gunzip hadoop-2.7.1.tar.gz --decompress --stdout | tar -mxpf - --strip-components=1 -C /data/hadoop/
echo "export HADOOP_PREFIX=/data/hadoop" >> ~/.profile
echo "export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre" >> /data/hadoop/etc/hadoop/hadoop-env.sh
cat > /data/hadoop/etc/hadoop/core-site.xml <<EOF
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/data/hadoop</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:54310</value>
</property>
</configuration>
EOF
cat > /data/hadoop/etc/hadoop/hdfs-site.xml <<EOF
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
EOF
cd /data/hadoop
if [[ ! -d /data/hadoop/dfs/name ]]; then
./bin/hdfs namenode -format
fi
cd
if [[ -f /vagrant/Dropbox\ \(Personal\)/binaries/hbase-1.1.1-bin.tar.gz ]]; then
cp /vagrant/Dropbox\ \(Personal\)/binaries/hbase-1.1.1-bin.tar.gz .
elif [[ ! -f hbase-1.1.1-bin.tar.gz ]]; then
wget http://mirror.nexcess.net/apache/hbase/1.1.1/hbase-1.1.1-bin.tar.gz
fi
sudo mkdir -p -m0755 /data/{hbase,zk}
sudo chown -R vagrant:vagrant /data/{hbase,zk}
gunzip hbase-1.1.1-bin.tar.gz --decompress --stdout | tar -mxpf - --strip-components=1 -C /data/hbase/
cat > /data/hbase/conf/hbase-site.xml <<EOF
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:54310/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/data/zk/</value>
</property>
</configuration>
EOF
echo "export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre" >> /data/hbase/conf/hbase-env.sh
echo "export HBASE_MANAGES_ZK=false" >> /data/hbase/conf/hbase-env.sh
echo "export PATH=$PATH:/data/hbase/bin/:" >> ~/.bashrc
echo 'export PS1="[\u@\h \W]\\$ "' | ed ~/.bashrc
source ~/.bashrc
if ! pgrep -f proc_datanode; then
/data/hadoop/sbin/start-dfs.sh
fi
if ! pgrep -f proc_zookeeper; then
/data/hbase/bin/hbase-daemon.sh start zookeeper
fi
if ! pgrep -f proc_regionserver; then
/data/hbase/bin/start-hbase.sh
fi
if ! pgrep -f proc_thrift; then
/data/hbase/bin/hbase-daemon.sh start thrift
fi