-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbootstrap.sh
242 lines (214 loc) · 9.43 KB
/
bootstrap.sh
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#!/usr/bin/env bash
apt-get update
MESOS_VERSION=0.18.2
PROTOBUF_VERSION=2.5.0
#Set the hostname
hostname mesos1
echo "mesos1" > /etc/hostname
echo "192.168.56.101 mesos1 jenkins jenkins1 marathon marathon1 aurora aurora1 zookeeper1 nginx1 docker1 chronos chronos1" >> /etc/hosts
echo "192.168.56.102 mesos2 jenkins2 marathon2 aurora2 zookeeper2 nginx2 docker2 chronos2" >> /etc/hosts
echo "192.168.56.103 mesos3 jenkins3 marathon3 aurora3 zookeeper3 nginx3 docker3 chronos3" >> /etc/hosts
#Install base packages
echo "####################################"
echo "Installing base packages........"
echo "####################################"
apt-get -y install g++ python-dev zlib1g-dev libssl-dev libcurl4-openssl-dev libsasl2-modules python-setuptools python-protobuf libsasl2-dev make daemon
apt-get -y install curl git-core mlocate
#Clone Git repo containing config files
echo "###############################################################"
echo "Cloning https://github.com/ahunnargikar/vagrant-mesos........"
echo "###############################################################"
git clone https://github.com/ahunnargikar/vagrant-mesos
cd vagrant-mesos
git pull
cd ..
#Install Java & Maven
echo "####################################"
echo "Installing JDK7 & Maven........"
echo "####################################"
apt-get -y install default-jdk maven
java -version
mvn --version
#Install Docker
echo "####################################"
echo "Installing Docker........"
echo "####################################"
echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
apt-get -y update
apt-get -y --force-yes install lxc-docker-0.11.1
#Install Docker Executor
echo "####################################"
echo "Installing the Docker Executor........"
echo "####################################"
mkdir -p /var/lib/mesos/executors
curl https://raw.githubusercontent.com/mesosphere/mesos-docker/master/bin/mesos-docker --output /var/lib/mesos/executors/docker
chmod +x /var/lib/mesos/executors/docker
cp /var/lib/mesos/executors/docker /var/lib/mesos/executors/docker2
#sed -i 's/, cidfile ]/ , cidfile , \x27-privileged\x27]/g' /var/lib/mesos/executors/docker2
sed -i 's/, cidfile ]/ , cidfile , \x27-v\x27, \x27\/var\/run\/docker.sock:\/var\/run\/docker.sock\x27]/g' /var/lib/mesos/executors/docker2
#Install Zookeeper
echo "####################################"
echo "Installing Zookeeper........"
echo "####################################"
apt-get -y install zookeeperd
echo "1" > /etc/zookeeper/conf/myid
cp vagrant-mesos/zookeeper/zoo.cfg /etc/zookeeper/conf/zoo.cfg
#Install Mesos
echo "####################################"
echo "Installing Mesos........"
echo "####################################"
cp -rf vagrant-mesos/mesos/mesos-master /etc/mesos-master
cp -rf vagrant-mesos/mesos/mesos-slave /etc/mesos-slave
wget http://downloads.mesosphere.io/master/ubuntu/13.10/mesos_${MESOS_VERSION}_amd64.deb
#wget http://downloads.mesosphere.io/master/ubuntu/13.10/mesos_${MESOS_VERSION}_amd64.egg
wget http://downloads.mesosphere.io/master/ubuntu/13.10/mesos-${MESOS_VERSION}-py2.7-linux-x86_64.egg
dpkg -i mesos_${MESOS_VERSION}_amd64.deb
#easy_install mesos_${MESOS_VERSION}_amd64.egg
easy_install mesos-${MESOS_VERSION}-py2.7-linux-x86_64.egg
sed -i '/--recover=cleanup/d' /usr/bin/mesos-init-wrapper
cp vagrant-mesos/mesos/mesos/zk /etc/mesos/zk
#Install protobuf ${PROTOBUF_VERSION}
echo "####################################"
echo "Installing Protobuf ${PROTOBUF_VERSION}......."
echo "####################################"
wget https://protobuf.googlecode.com/files/protobuf-${PROTOBUF_VERSION}.tar.gz
tar -xzvf protobuf-${PROTOBUF_VERSION}.tar.gz; cd protobuf-${PROTOBUF_VERSION}/
./configure
make
#make check
make install
ldconfig
protoc --version
cd ..
#Install Jenkins
echo "####################################"
echo "Installing Jenkins........"
echo "####################################"
apt-get -y install jenkins
update-rc.d jenkins defaults
cp vagrant-mesos/jenkins/jenkins /etc/default/jenkins
cp vagrant-mesos/jenkins/config.xml /var/lib/jenkins/config.xml
cp vagrant-mesos/jenkins/jenkins.model.JenkinsLocationConfiguration.xml /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml
mkdir -p /var/lib/jenkins/plugins
cp vagrant-mesos/mesos-plugin/mesos.hpi /var/lib/jenkins/plugins/mesos.hpi
chown -R jenkins:jenkins /var/lib/jenkins/plugins
usermod -g docker jenkins
#Install Marathon
echo "####################################"
echo "Installing Marathon........"
echo "####################################"
#git clone https://github.com/mesosphere/marathon
#cd marathon
#sed -i 's#\(<mesos.version>\).*\(</mesos.version>\)#\1'${MESOS_VERSION}'\2#g' pom.xml
#sed -i 's#\(<protobuf.version>\).*\(</protobuf.version>\)#\1'${PROTOBUF_VERSION}'\2#g' pom.xml
#protoc --java_out=src/main/java/ --proto_path=/usr/local/include/mesos/ --proto_path=src/main/proto/ src/main/proto/marathon.proto
#git status
#mvn package
#cd ..
curl -O http://downloads.mesosphere.io/marathon/marathon-0.5.1/marathon-0.5.1.tgz
tar xzf marathon-0.5.1.tgz
mv marathon-0.5.1 /usr/local/marathon
mkdir -p /etc/marathon
cp vagrant-mesos/marathon/marathon.conf /etc/marathon/marathon.conf
cp vagrant-mesos/marathon/marathon.init /etc/init/marathon.conf
#Install & configure Aurora
echo "####################################"
echo "Installing Aurora........"
echo "####################################"
#Build the Aurora code
cd /usr/local
git clone http://git-wip-us.apache.org/repos/asf/incubator-aurora.git
cd incubator-aurora
./gradlew distZip
#Place the Aurora binary under /usr/local
rm -rf /usr/local/aurora-scheduler*
unzip dist/distributions/aurora-scheduler-*.zip -d /usr/local
ln -nfs "$(ls -dt /usr/local/aurora-scheduler-* | head -1)" /usr/local/aurora-scheduler
#Place the Aurora config file under /etc/aurora
mkdir -p /etc/aurora
cat > /etc/aurora/clusters.json <<EOF
[{
"name": "example",
"zk": "192.168.56.101",
"scheduler_zk_path": "/aurora/scheduler",
"auth_mechanism": "UNAUTHENTICATED",
"slave_run_directory": "latest",
"slave_root": "/var/lib/mesos"
}]
EOF
#Install the Python binaries
./pants src/main/python/apache/aurora/client/bin:aurora_admin
./pants src/main/python/apache/aurora/client/bin:aurora_client
sed -i 's/mesos==0.18.0/mesos=='${MESOS_VERSION}'/g' 3rdparty/python/BUILD
cp /home/vagrant/mesos-${MESOS_VERSION}-py2.7-linux-x86_64.egg /usr/local/incubator-aurora/.pants.d/python/eggs/mesos-${MESOS_VERSION}-py2.7.egg
./pants src/main/python/apache/aurora/executor/bin:gc_executor
./pants src/main/python/apache/aurora/executor/bin:thermos_executor
./pants src/main/python/apache/aurora/executor/bin:thermos_runner
./pants src/main/python/apache/thermos/observer/bin:thermos_observer
#Additional Python configuration
python <<EOF
import contextlib
import zipfile
with contextlib.closing(zipfile.ZipFile('dist/thermos_executor.pex', 'a')) as zf:
zf.writestr('apache/aurora/executor/resources/__init__.py', '')
zf.write('dist/thermos_runner.pex', 'apache/aurora/executor/resources/thermos_runner.pex')
EOF
#Place the binaries under /usr/local/bin
install -m 755 dist/aurora_admin.pex /usr/local/bin/aurora_admin
install -m 755 dist/aurora_client.pex /usr/local/bin/aurora_client
install -m 755 dist/gc_executor.pex /usr/local/bin/gc_executor
install -m 755 dist/thermos_executor.pex /usr/local/bin/thermos_executor
install -m 755 dist/thermos_observer.pex /usr/local/bin/thermos_observer
#Launching the scheduler
mesos-log initialize --path="/usr/local/aurora-scheduler-0.5.1-SNAPSHOT/db"
cd /home/vagrant
cp vagrant-mesos/aurora/aurora.sh /usr/local/aurora.sh
chmod +x /usr/local/aurora.sh
#Launch at startup
cat > /etc/init/aurora.conf <<EOF
description "Aurora Scheduler"
start on stopped rc RUNLEVEL=[2345]
respawn
exec /usr/local/aurora.sh \
1>> /var/log/aurora-scheduler-stdout.log \
2>> /var/log/aurora-scheduler-stderr.log
EOF
cat > /etc/init/thermos-observer.conf <<EOF
description "Aurora Thermos Observer"
start on stopped rc RUNLEVEL=[2345]
respawn
exec /usr/local/bin/thermos_observer --root=/var/run/thermos --port=1338 --log_to_disk=NONE --log_to_stderr=google:INFO
EOF
service aurora start
service thermos-observer start
#Install Chronos
echo "####################################"
echo "Installing Chronos........"
echo "####################################"
curl -sSfL http://downloads.mesosphere.io/chronos/chronos-2.1.0_mesos-0.14.0-rc4.tgz --output chronos.tgz
tar xzf chronos.tgz
mv chronos /usr/local/chronos
mkdir -p /etc/chronos
cp vagrant-mesos/chronos/chronos.conf /etc/chronos/chronos.conf
cp vagrant-mesos/chronos/chronos.init /etc/init/chronos.conf
service chronos start
#Installing the Chronos Docker executor
echo "####################################"
echo "Installing Chronos Docker executor........"
echo "####################################"
curl https://raw.githubusercontent.com/mudasirmirza/chronos-docker/master/chronos_docker --output /var/lib/mesos/executors/chronos_docker
chmod +x /var/lib/mesos/executors/chronos_docker
#Install & configure Nginx
echo "####################################"
echo "Installing Nginx........"
echo "####################################"
apt-get -y install nginx
cp vagrant-mesos/nginx/app-servers.include /etc/nginx/app-servers.include
cp vagrant-mesos/nginx/nginx.conf /etc/nginx/nginx.conf
rm -rf /etc/nginx/sites-available
cp -rf vagrant-mesos/nginx/sites-available /etc/nginx/sites-available/
update-rc.d nginx defaults
# echo "####################################"
# echo "Rebooting........"
# echo "####################################"
# #reboot