Skip to content

Commit

Permalink
fallback to :80 for keyserver, more dev bits
Browse files Browse the repository at this point in the history
  • Loading branch information
paulczar committed Sep 22, 2014
1 parent 891d4a8 commit 1817411
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ RUN \
RUN locale-gen en_US.UTF-8

RUN \
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A && \
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A || \
apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys 1C4CBDCDCD2EFD2A

RUN \
echo "deb http://repo.percona.com/apt `lsb_release -cs` main" > /etc/apt/sources.list.d/percona.list && \
echo "deb-src http://repo.percona.com/apt `lsb_release -cs` main" >> /etc/apt/sources.list.d/percona.list && \
ln -fs /bin/true /usr/bin/chfn && \
Expand All @@ -46,7 +49,7 @@ ADD https://s3-us-west-2.amazonaws.com/opdemand/confd-v0.5.0-json /usr/local/bin
RUN chmod +x /usr/local/bin/confd

# Define mountable directories.
VOLUME ["/etc/mysql", "/var/lib/mysql"]
VOLUME ["/var/lib/mysql"]

ADD . /app

Expand Down
9 changes: 7 additions & 2 deletions bin/boot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DIR=$(dirname $0)
# functions
. $DIR/functions

DB_OPTIONS=""
MYSQL_USER=${MYSQL_USER:-admin}
MYSQL_PASS=${MYSQL_PASS:-admin}
REP_USER=${REP_USER:-replicator}
Expand All @@ -26,6 +27,8 @@ if [[ -z $HOST ]]; then
echo '==> $HOST not set. booting mysql without clustering.'
init_database
echo "==> database running..."
touch /var/log/mysql/error.log
tail -f /var/log/mysql/error.log &
mysqld_safe $DB_OPTIONS
exit $?
fi
Expand Down Expand Up @@ -79,12 +82,12 @@ if [[ -z $CLUSTER_MEMBERS ]]; then
echo "-----> leader ready. Starting."
sleep 5
echo "-----> joining cluster with known members: $CLUSTER_MEMBERS"
mysqld_safe --wsrep_cluster_address=gcomm://$CLUSTER_MEMBERS $WSREP_OPTIONS &
mysqld --wsrep_cluster_address=gcomm://$CLUSTER_MEMBERS $WSREP_OPTIONS &
fi
else
cluster_members
echo "-----> joining cluster with known members: $CLUSTER_MEMBERS"
mysqld_safe --wsrep_cluster_address=gcomm://$CLUSTER_MEMBERS $WSREP_OPTIONS &
mysqld --wsrep_cluster_address=gcomm://$CLUSTER_MEMBERS $WSREP_OPTIONS &
fi


Expand All @@ -106,6 +109,8 @@ while [[ -z $(netstat -lnt | awk "\$6 == \"LISTEN\" && \$4 ~ \".$PUBLISH\" && \$

echo "==> database running..."

tail -f /var/log/mysql/error.log &

# publish the service to etcd using the injected HOST and PORT
if [[ ! -z $PUBLISH ]]; then

Expand Down
2 changes: 1 addition & 1 deletion bin/functions
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function on_exit() {
}

function cluster_members() {
CLUSTER_MEMBERS=
for key in $(etcdctl --no-sync -C $ETCD ls $ETCD_PATH/cluster/galeraEndpoints); do
value=$(etcdctl --no-sync -C $ETCD get $key)
LIST+="$(basename $value),"
Expand All @@ -33,7 +34,6 @@ function publish_to_etcd() {
}

function init_database() {
DB_OPTIONS="--skip-syslog --verbose"
chown -R mysql:mysql /var/lib/mysql
if [[ ! -d /var/lib/mysql/mysql ]]; then
echo "==> An empty or uninitialized database is detected in /var/lib/mysql"
Expand Down
2 changes: 2 additions & 0 deletions templates/my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ query_cache_size = 64M
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
log_error = /var/log/mysql/error.log

# we do want to know about network errors and such
log_warnings = 2
#
Expand Down
18 changes: 10 additions & 8 deletions user-data.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ coreos:
BindIPv6Only=both
[Install]
WantedBy=sockets.target
<% unless ENV['dev'] %>
- name: database.service
command: start
enable: true
Expand All @@ -38,25 +39,26 @@ coreos:
ExecStartPre=/usr/bin/docker pull paulczar/percona-galera:latest
ExecStart=/bin/sh -c "/usr/bin/docker run --name database --rm -p 3306:3306 -p 4444:4444 -p 4567:4567 -p 4568:4568 -e PUBLISH=3306 -e HOST=$COREOS_PRIVATE_IPV4 -e CLUSTER=galera paulczar/percona-galera:latest"
ExecStop=/usr/bin/docker stop database

<% end %>
write_files:
- path: /etc/motd
content: "Database Cluster Demo\n"
- path: /etc/profile.d/nse-function.sh
- path: /etc/profile.d/db-functions.sh
permissions: '0755'
content: |
function nse() {
sudo nsenter --pid --uts --mount --ipc --net --target $(docker inspect --format="{{ .State.Pid }}" $1)
}
- path: /etc/profile.d/database_shell.sh
permissions: '0755'
content: |
function dev_db() {
eval `cat /etc/environment`
/usr/bin/docker run -it -e DEBUG=1 -p 3306:3306 -p 4444:4444 -p 4567:4567 -p 4568:4568 -e PUBLISH=3306 -e HOST=$COREOS_PRIVATE_IPV4 -e CLUSTER=galera paulczar/percona-galera:latest bash
}
function database() {
sudo nsenter --pid --uts --mount --ipc --net --target $(docker inspect --format="{{ .State.Pid }}" database)
}
- path: /etc/profile.d/rebuild.sh
permissions: '0755'
content: |
function rebuild() {
docker build -t paulczar/percona-galera /home/core/share
}
function cleanup() {
etcdctl rm --recursive /database
}

0 comments on commit 1817411

Please sign in to comment.