You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2017/01/30 17:58:41 UTC

[04/11] incubator-trafficcontrol git commit: pulled postgres Dockerfiles back just for migration

pulled postgres Dockerfiles back just for migration


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/a0eb24d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/a0eb24d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/a0eb24d3

Branch: refs/heads/master
Commit: a0eb24d3f9a1b2181b21b72a7f08cca94c5c6425
Parents: 499bcbc
Author: Dewayne Richardson <de...@apache.org>
Authored: Fri Jan 27 13:47:10 2017 -0700
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Mon Jan 30 10:58:07 2017 -0700

----------------------------------------------------------------------
 .../app/db/pg-migration/Dockerfile-postgres     | 29 +++++++++
 .../app/db/pg-migration/Dockerfile-waiter       | 24 +++++++
 traffic_ops/app/db/pg-migration/migrate.sh      | 66 ++++++++++++++++++++
 .../app/db/pg-migration/mysql-to-postgres.env   |  5 ++
 traffic_ops/app/db/pg-migration/postgres.yml    | 34 ++++++++++
 traffic_ops/app/db/pg-migration/runwaiter.sh    | 13 ++++
 traffic_ops/app/db/pg-migration/waiter.yml      | 24 +++++++
 7 files changed, 195 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/Dockerfile-postgres
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/Dockerfile-postgres b/traffic_ops/app/db/pg-migration/Dockerfile-postgres
new file mode 100644
index 0000000..6f3c634
--- /dev/null
+++ b/traffic_ops/app/db/pg-migration/Dockerfile-postgres
@@ -0,0 +1,29 @@
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+FROM dewrich/postgres:latest
+
+MAINTAINER Dan Kirkwood
+
+# Postgres Access
+ENV POSTGRES_HOST=$POSTGRES_HOST
+ENV POSTGRES_PORT=$POSTGRES_PORT
+ENV POSTGRES_DATABASE=$POSTGRES_DATABASE
+ENV POSTGRES_PASSWORD=$POSTGRES_PASSWORD
+
+# Adjust PostgreSQL configuration so that remote connections to the
+# database are possible.
+RUN echo "host all  all    0.0.0.0/0  md5" >> $PGDATA/pg_hba.conf
+RUN echo "listen_addresses='*'" >> $PGDATA/postgresql.conf
+
+EXPOSE "5432:5432"

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/Dockerfile-waiter
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/Dockerfile-waiter b/traffic_ops/app/db/pg-migration/Dockerfile-waiter
new file mode 100644
index 0000000..0531c71
--- /dev/null
+++ b/traffic_ops/app/db/pg-migration/Dockerfile-waiter
@@ -0,0 +1,24 @@
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+FROM dimitri/pgloader:latest
+
+MAINTAINER Dewayne Richardson
+
+RUN apt-get -y update && apt-get -y install netcat
+
+ENV WAITER_HOST=$WAITER_HOST
+ENV WAITER_PORT=$WAITER_PORT
+
+ADD pg-migration/runwaiter.sh .
+CMD ./runwaiter.sh

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/migrate.sh
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/migrate.sh b/traffic_ops/app/db/pg-migration/migrate.sh
index 1b73820..a03884f 100755
--- a/traffic_ops/app/db/pg-migration/migrate.sh
+++ b/traffic_ops/app/db/pg-migration/migrate.sh
@@ -13,16 +13,50 @@
 #  limitations under the License.
 #
 
+<<<<<<< HEAD
+. mysql-to-postgres.env
+=======
 : ${TO_SERVER?"Please set the TO_SERVER environment variable: ie: https://kabletown.net"}
 : ${TO_USER?"Please set the TO_USER environment variable: ie: <your Traffic Ops userid>"}
 : ${TO_PASSWORD?"Please set the TO_PASSWORD environment variable: ie: <your Traffic Ops password>"}
 
 MYSQL_PORT=3306
 POSTGRES_PORT=5432
+>>>>>>> master
 
 separator="---------------------------------------"
 
 function shutdown_trafficops_database() {
+<<<<<<< HEAD
+  docker-compose -p trafficops -f postgres.yml down
+}
+
+function start_staging_mysql_server() {
+
+  docker-compose -p trafficops -f mysql_host.yml up --build -d
+
+  #Wait for postgres to come up
+  export WAITER_HOST=$MYSQL_HOST
+  export WAITER_PORT=$MYSQL_PORT
+  docker-compose -p trafficops -f waiter.yml up --build
+
+  echo $separator
+  echo "Mysql Host is started..."
+  echo $separator
+}
+
+function start_staging_postgres_server() {
+  docker-compose -p trafficops -f postgres.yml up --build
+
+  #Wait for postgres to come up
+  export WAITER_HOST=$POSTGRES_HOST
+  export WAITER_PORT=$POSTGRES_PORT
+  docker-compose -p trafficops -f waiter.yml up --build
+
+  echo $separator
+  echo "Postgres started.."
+  echo $separator
+=======
      sudo systemctl stop trafficops-db
 }
 
@@ -48,18 +82,49 @@ function start_staging_postgres_server() {
 	echo $separator
 	echo "Postgres started.."
 	echo $separator
+>>>>>>> master
 }
 
 
 function run_postgres_datatypes_conversion() {
+<<<<<<< HEAD
+  echo $separator
+  echo "Starting Mysql to Postgres Migration..."
+  echo $separator
+  docker-compose -p trafficops -f convert.yml up --build
+=======
 	echo $separator
 	echo "Starting Mysql to Postgres Migration..."
 	echo $separator
 	docker-compose -p trafficops -f convert.yml up --build
+>>>>>>> master
 }
 
 
 function migrate_data_from_mysql_to_postgres() {
+<<<<<<< HEAD
+  echo $separator
+  echo "Starting Mysql to Postgres Migration..."
+  echo $separator
+  docker-compose -p trafficops -f mysql-to-postgres.yml up --build
+}
+
+function clean() {
+  echo $separator
+  echo "Cleaning up..."
+  echo $separator
+  docker kill trafficops_mysql_host_1
+  docker-compose -p trafficops -f mysql-to-postgres.yml down --remove-orphans
+  docker-compose -p trafficops -f convert.yml down --remove-orphans
+  docker rm trafficops_mysql-to-postgres_1 
+  docker rm trafficops_convert_1
+  docker rm trafficops_mysql_host_1
+  docker rmi trafficops_mysql-to-postgres
+  docker rmi trafficops_convert 
+  docker rmi trafficops_mysql_host
+  docker rmi mysql:5.6 
+  docker rmi dimitri/pgloader:latest
+=======
 	echo $separator
 	echo "Starting Mysql to Postgres Migration..."
 	echo $separator
@@ -81,6 +146,7 @@ function clean() {
         docker rmi trafficops_mysql_host
         docker rmi mysql:5.6 
         docker rmi dimitri/pgloader:latest
+>>>>>>> master
 }
 
 start_staging_mysql_server

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/mysql-to-postgres.env
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/mysql-to-postgres.env b/traffic_ops/app/db/pg-migration/mysql-to-postgres.env
index 8f343f1..75ec909 100644
--- a/traffic_ops/app/db/pg-migration/mysql-to-postgres.env
+++ b/traffic_ops/app/db/pg-migration/mysql-to-postgres.env
@@ -40,3 +40,8 @@ POSTGRES_PORT=5432
 POSTGRES_DATABASE=traffic_ops
 POSTGRES_USER=traffic_ops
 POSTGRES_PASSWORD=( your_new_postgres_password )
+<<<<<<< HEAD
+
+PGDATA=/opt/postgresql/data/pgdata
+=======
+>>>>>>> master

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/postgres.yml
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/postgres.yml b/traffic_ops/app/db/pg-migration/postgres.yml
new file mode 100644
index 0000000..f68055c
--- /dev/null
+++ b/traffic_ops/app/db/pg-migration/postgres.yml
@@ -0,0 +1,34 @@
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+version: '2'
+
+services:
+  db:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-postgres
+    env_file:
+      - mysql-to-postgres.env
+    ports:
+      - 5432:5432
+    volumes:
+      - /opt/postgresql/data/pgdata:/opt/postgresql/data/pgdata
+      - /var/log/postgresql:/var/log/postgresql
+    networks:
+      - default
+
+networks:
+  default:
+     driver: bridge
+

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/runwaiter.sh
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/runwaiter.sh b/traffic_ops/app/db/pg-migration/runwaiter.sh
new file mode 100755
index 0000000..7cf2222
--- /dev/null
+++ b/traffic_ops/app/db/pg-migration/runwaiter.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+
+echo "WAITER_HOST: $WAITER_HOST"
+echo "WAITER_PORT: $WAITER_PORT"
+
+for c in "$WAITER_HOST $WAITER_PORT" ; do
+  while true; do
+     echo "Waiting 3 seconds for Host and Port: $c "
+     sleep 3
+     nc -z $c && break
+  done
+done

http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/a0eb24d3/traffic_ops/app/db/pg-migration/waiter.yml
----------------------------------------------------------------------
diff --git a/traffic_ops/app/db/pg-migration/waiter.yml b/traffic_ops/app/db/pg-migration/waiter.yml
new file mode 100644
index 0000000..2796737
--- /dev/null
+++ b/traffic_ops/app/db/pg-migration/waiter.yml
@@ -0,0 +1,24 @@
+#
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+#
+version: '2'
+
+services:
+  # waits for a port to be available
+  waiter:
+    build:
+      context: ..
+      dockerfile: pg-migration/Dockerfile-waiter
+    environment:
+      - WAITER_HOST
+      - WAITER_PORT