Skip to content

Commit 5507749

Browse files
committed
full sample cluster dockerfile
1 parent b6c9ac6 commit 5507749

File tree

4 files changed

+82
-16
lines changed

4 files changed

+82
-16
lines changed

Diff for: Dockerfile

+31-10
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,51 @@ RUN mkdir -p /var/lib/druid
3636
RUN chown druid:druid /var/lib/druid
3737

3838
# Druid (release tarball)
39-
RUN wget -q -O - http://static.druid.io/artifacts/releases/druid-services-0.6.121-bin.tar.gz | tar -xzf - -C /usr/local
40-
RUN ln -s /usr/local/druid-services-0.6.121 /usr/local/druid
39+
#ENV DRUID_VERSION 0.7.0
40+
#RUN wget -q -O - http://static.druid.io/artifacts/releases/druid-services-$DRUID_VERSION-bin.tar.gz | tar -xzf - -C /usr/local
41+
#RUN ln -s /usr/local/druid-services-0.6.121 /usr/local/druid
4142

4243
# Druid (from source)
43-
#ENV DRUID_VERSION druid-0.6.121
44-
#RUN git clone -q --branch $DRUID_VERSION --depth 1 https://github.com/metamx/druid.git /tmp/druid
45-
#WORKDIR /tmp/druid
46-
#RUN hash=$(git rev-parse --short HEAD); mkdir -p /usr/local/druid-$hash/lib && ln -s /usr/local/druid-$hash /usr/local/druid
47-
#RUN mvn package -DskipTests=true
48-
#RUN cp services/target/druid-services-*-selfcontained.jar /usr/local/druid/lib
44+
ENV DRUID_VERSION druid-0.7.x
45+
# trigger rebuild only if branch changed
46+
ADD https://api.github.com/repos/metamx/druid/git/refs/heads/$DRUID_VERSION druid-version.json
47+
RUN git clone -q --branch $DRUID_VERSION --depth 1 https://github.com/metamx/druid.git /tmp/druid
48+
RUN git config --global user.email [email protected]
49+
WORKDIR /tmp/druid
50+
RUN hash=$(git rev-parse --short HEAD); mkdir -p /usr/local/druid-$hash/lib && ln -s /usr/local/druid-$hash /usr/local/druid
51+
# package and install Druid locally
52+
RUN mvn -B release:prepare -DpushChanges=false -DpreparationGoals=clean -DreleaseVersion=$DRUID_VERSION -DdevelopmentVersion=$DRUID_VERSION-SNAPSHOT release:perform -DskipTests=true -DlocalCheckout=true -Dgoals=install
53+
RUN cp -f target/checkout/services/target/druid-services-$DRUID_VERSION-selfcontained.jar /usr/local/druid/lib
54+
# pull dependencies for Druid extensions
55+
RUN mkdir -p /usr/local/druid/repository
56+
RUN java -Ddruid.extensions.coordinates=[\"io.druid.extensions:druid-s3-extensions:$DRUID_VERSION\"] -Ddruid.extensions.localRepository=/usr/local/druid/repository -Ddruid.extensions.remoteRepositories=[\"file:///root/.m2/repository/\",\"http://repo1.maven.org/maven2/\",\"https://metamx.artifactoryonline.com/metamx/pub-libs-releases-local\"] -cp /usr/local/druid/lib/* io.druid.cli.Main tools pull-deps
57+
58+
WORKDIR /
4959

5060
# Setup metadata store
5161
RUN /etc/init.d/mysql start && echo "GRANT ALL ON druid.* TO 'druid'@'localhost' IDENTIFIED BY 'diurd'; CREATE database druid;" | mysql -u root && /etc/init.d/mysql stop
5262

63+
# Add sample data
64+
RUN /etc/init.d/mysql start && java -cp /usr/local/druid/lib/druid-services-*-selfcontained.jar io.druid.cli.Main tools metadata-init --connectURI="jdbc:mysql://localhost:3306/druid" --user=druid --password=diurd && /etc/init.d/mysql stop
65+
ADD sample-data.sql sample-data.sql
66+
RUN /etc/init.d/mysql start && echo "Adding sample data" && (cat sample-data.sql | mysql -u root druid) && echo "Stopping" && /etc/init.d/mysql stop
67+
68+
# Setup supervisord
5369
ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf
70+
RUN perl -pi -e "s/\\\$DRUID_VERSION/$DRUID_VERSION/" /etc/supervisor/conf.d/supervisord.conf
5471

5572
# Clean up
5673
RUN apt-get clean && rm -rf /tmp/* /var/tmp/*
5774

5875
# Expose ports:
59-
# - 8080: HTTP
76+
# - 8081: HTTP (coordinator)
77+
# - 8082: HTTP (broker)
78+
# - 8083: HTTP (historical)
6079
# - 3306: MySQL
6180
# - 2181 2888 3888: ZooKeeper
62-
EXPOSE 8080
81+
EXPOSE 8081
82+
EXPOSE 8082
83+
EXPOSE 8083
6384
EXPOSE 3306
6485
EXPOSE 2181 2888 3888
6586

Diff for: Tutorial.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ docker info
4242
Build Druid image
4343

4444
```sh
45-
docker build -t druid/coordinator .
45+
docker build -t druid/cluster .
4646
```
4747

4848
## Run Druid
4949

5050
```sh
51-
docker run -i --rm -p 3000:8080 -t druid/coordinator
51+
docker run --rm -i -p 3000:8082 -p 3001:8081 druid/cluster
5252
```
5353

54-
Assuming `boot2docker ip` returns `192.168.59.103`, you should be able to access the coordinator console at: http://192.168.59.103:3000/
54+
Wait a minute or so for the Druid to download the sample data an start up.
55+
56+
Assuming `boot2docker ip` returns `192.168.59.103`, you should be able to
57+
- access the coordinator console at: http://192.168.59.103:3001/
58+
- list data-sources on the broker http://192.168.59.103:3000/druid/v2/datasources

Diff for: sample-data.sql

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO druid_segments (id, dataSource, created_date, start, end, partitioned, version, used, payload) VALUES ('wikipedia_2013-08-01T00:00:00.000Z_2013-08-02T00:00:00.000Z_2013-08-08T21:22:48.989Z', 'wikipedia', '2013-08-08T21:26:23.799Z', '2013-08-01T00:00:00.000Z', '2013-08-02T00:00:00.000Z', '0', '2013-08-08T21:22:48.989Z', '1', '{\"dataSource\":\"wikipedia\",\"interval\":\"2013-08-01T00:00:00.000Z/2013-08-02T00:00:00.000Z\",\"version\":\"2013-08-08T21:22:48.989Z\",\"loadSpec\":{\"type\":\"s3_zip\",\"bucket\":\"static.druid.io\",\"key\":\"data/segments/wikipedia/20130801T000000.000Z_20130802T000000.000Z/2013-08-08T21_22_48.989Z/0/index.zip\"},\"dimensions\":\"dma_code,continent_code,geo,area_code,robot,country_name,network,city,namespace,anonymous,unpatrolled,page,postal_code,language,newpage,user,region_lookup\",\"metrics\":\"count,delta,variation,added,deleted\",\"shardSpec\":{\"type\":\"none\"},\"binaryVersion\":9,\"size\":24664730,\"identifier\":\"wikipedia_2013-08-01T00:00:00.000Z_2013-08-02T00:00:00.000Z_2013-08-08T21:22:48.989Z\"}');
2+

Diff for: supervisord.conf

+42-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ command=java
1616
-Xmx1g
1717
-Duser.timezone=UTC
1818
-Dfile.encoding=UTF-8
19-
-Ddruid.host=localhost
20-
-Ddruid.port=8080
21-
-Ddruid.service=druid/coordinator
2219
-Ddruid.db.connector.connectURI=jdbc:mysql://localhost:3306/druid
2320
-Ddruid.db.connector.user=druid
2421
-Ddruid.db.connector.password=diurd
@@ -27,6 +24,48 @@ command=java
2724
-Ddruid.discovery.curator.path=/discovery
2825
-Ddruid.curator.compress=true
2926
-Ddruid.announcer.type=batch
27+
-Ddruid.coordinator.startDelay=PT5S
3028
-cp /usr/local/druid/lib/*
3129
io.druid.cli.Main server coordinator
3230
redirect_stderr=true
31+
32+
[program:druid-historical]
33+
user=druid
34+
command=java
35+
-server
36+
-Xmx1g
37+
-Duser.timezone=UTC
38+
-Dfile.encoding=UTF-8
39+
-Ddruid.zk.service.host=localhost
40+
-Ddruid.zk.paths.base=/druid
41+
-Ddruid.discovery.curator.path=/discovery
42+
-Ddruid.curator.compress=true
43+
-Ddruid.announcer.type=batch
44+
-Ddruid.extensions.coordinates=[\"io.druid.extensions:druid-s3-extensions:$DRUID_VERSION\"]
45+
-Ddruid.extensions.localRepository=/usr/local/druid/repository
46+
-Ddruid.s3.accessKey=AKIAIMKECRUYKDQGR6YQ
47+
-Ddruid.s3.secretKey=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
48+
-Ddruid.computation.buffer.size=67108864
49+
-Ddruid.segmentCache.locations="[{\"path\":\"/var/tmp/druid/indexCache\",\"maxSize\":5000000000}]"
50+
-Ddruid.server.maxSize=5000000000
51+
-cp /usr/local/druid/lib/*
52+
io.druid.cli.Main server historical
53+
redirect_stderr=true
54+
55+
[program:druid-broker]
56+
user=druid
57+
command=java
58+
-server
59+
-Xmx1g
60+
-Duser.timezone=UTC
61+
-Dfile.encoding=UTF-8
62+
-Ddruid.zk.service.host=localhost
63+
-Ddruid.zk.paths.base=/druid
64+
-Ddruid.discovery.curator.path=/discovery
65+
-Ddruid.curator.compress=true
66+
-Ddruid.announcer.type=batch
67+
-Ddruid.computation.buffer.size=67108864
68+
-Ddruid.broker.cache.sizeInBytes=33554432
69+
-cp /usr/local/druid/lib/*
70+
io.druid.cli.Main server broker
71+
redirect_stderr=true

0 commit comments

Comments
 (0)