Skip to content

Commit

Permalink
MemSQL 5.5.x
Browse files Browse the repository at this point in the history
Ship it
  • Loading branch information
carlsverre committed Sep 26, 2016
1 parent e6782c6 commit 031070e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 25 deletions.
13 changes: 0 additions & 13 deletions BUILD.md

This file was deleted.

7 changes: 4 additions & 3 deletions Dockerfile
Expand Up @@ -4,7 +4,7 @@
# https://github.com/memsql/memsql-docker-quickstart
#

FROM debian:8.4
FROM debian:8.6
MAINTAINER Carl Sverre <carl@memsql.com>

RUN apt-get update && \
Expand Down Expand Up @@ -34,8 +34,9 @@ RUN mkdir /memsql /memsql-ops

# download and install MemSQL Ops
# then reduce size by symlinking objdir and lib from one install to the other
COPY setup_ops.sh /tmp/setup_ops.sh
RUN /tmp/setup_ops.sh
COPY setup.sh /tmp/setup.sh
ADD VERSIONS /tmp/VERSIONS
RUN /tmp/setup.sh

# COPY helper scripts
COPY memsql-shell /usr/local/bin/memsql-shell
Expand Down
3 changes: 3 additions & 0 deletions Makefile
@@ -0,0 +1,3 @@
.PHONY: latest
latest:
docker build -t memsql/quickstart:latest -f Dockerfile .
14 changes: 12 additions & 2 deletions README.md
Expand Up @@ -14,7 +14,7 @@ docker pull memsql/quickstart
# Verify your machine satisfies our minimum requirements
docker run --rm --net=host memsql/quickstart check-system
docker run --rm memsql/quickstart check-system
# Spin up a MemSQL cluster on your machine
Expand All @@ -30,5 +30,15 @@ docker run --rm -it --link=memsql:memsql memsql/quickstart memsql-shell
# Stop and remove the container
docker stop memsql && docker rm -v memsql
docker rm -fv memsql
```

### Custom schema file at start

If you mount a SQL file to /schema.sql inside the container it will be loaded
when the cluster is started. Example:

```
echo "CREATE DATABASE test;" > schema.sql
docker run -d -v $(PWD)/schema.sql:/schema.sql -p 3306:3306 -p 9000:9000 --name=memsql memsql/quickstart
```
3 changes: 3 additions & 0 deletions VERSIONS
@@ -0,0 +1,3 @@
export OPS_VERSION=5.5.0
export MEMSQL_VERSION=321074d63e5f6f4bb6229c1fce597993e720daae

15 changes: 10 additions & 5 deletions memsql-entrypoint.sh
@@ -1,15 +1,20 @@
#!/bin/bash
set -e

if [ "$1" = "memsqld" ]; then
# Start up the cluster
if [[ "$1" = "memsqld" ]]; then
memsql-ops start
memsql-ops memsql-start --all
memsql-ops memsql-list

# Check for a schema file at /schema.sql and load it
if [[ -e /schema.sql ]]; then
echo "Loading schema from /schema.sql"
cat /schema.sql
memsql < /schema.sql
fi

# Tail the logs to keep the container alive
exec tail -F /memsql/master/tracelogs/memsql.log /memsql/leaf/tracelogs/memsql.log
else
exec "$@"
fi

exec "$@"

20 changes: 18 additions & 2 deletions setup_ops.sh → setup.sh
Expand Up @@ -2,7 +2,10 @@
set -e
set -x

VERSION_URL="http://versions.memsql.com/memsql-ops/5.1.0"
# Expects this file to export $OPS_VERSION and $MEMSQL_VERSION
source /tmp/VERSIONS

VERSION_URL="http://versions.memsql.com/memsql-ops/$OPS_VERSION"
MEMSQL_VOLUME_PATH="/memsql"
OPS_URL=$(curl -s "$VERSION_URL" | jq -r .tar)

Expand All @@ -20,16 +23,29 @@ mkdir /tmp/memsql-ops
tar -xzf /tmp/memsql_ops.tar.gz -C /tmp/memsql-ops --strip-components 1
/tmp/memsql-ops/install.sh \
--host 127.0.0.1 \
--simple-cluster \
--no-cluster \
--ops-datadir /memsql-ops \
--memsql-installs-dir /memsql-ops/installs

DEPLOY_EXTRA_FLAGS=
if [[ $MEMSQL_VERSION != "community" ]]; then
DEPLOY_EXTRA_FLAGS="--version-hash $MEMSQL_VERSION"
fi

memsql-ops memsql-deploy --role master --community-edition $DEPLOY_EXTRA_FLAGS
memsql-ops memsql-deploy --role leaf --community-edition --port 3307 $DEPLOY_EXTRA_FLAGS

MASTER_ID=$(memsql-ops memsql-list --memsql-role=master -q)
MASTER_PATH=$(memsql-ops memsql-path $MASTER_ID)

LEAF_ID=$(memsql-ops memsql-list --memsql-role=leaf -q)
LEAF_PATH=$(memsql-ops memsql-path $LEAF_ID)

# We need to clear the maximum-memory setting in the leaf's memsql.cnf otherwise
# when we move to another machine with a different amount of memory the memory
# imbalance nag will show up
memsql-ops memsql-update-config --key maximum_memory --delete $LEAF_ID

# symlink leaf's static directories to master
for tgt in objdir lib; do
rm -rf $LEAF_PATH/$tgt
Expand Down

0 comments on commit 031070e

Please sign in to comment.