separated the Postgres from the 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/01bdb8ec Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/01bdb8ec Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/01bdb8ec Branch: refs/heads/master Commit: 01bdb8ecf0f0de0bc0fb5a706600855f3246cbe1 Parents: c6253f1 Author: Dewayne Richardson <dewr...@apache.org> Authored: Fri Jan 27 16:17:44 2017 -0700 Committer: Jeremy Mitchell <mitchell...@gmail.com> Committed: Mon Jan 30 10:58:07 2017 -0700 ---------------------------------------------------------------------- traffic_ops/app/db/pg-migration/README.md | 6 +++ traffic_ops/app/db/pg-migration/migrate.sh | 53 ++++++++++++------ traffic_ops/app/db/pg-migration/postgres.yml | 4 +- .../app/db/pg-migration/start_postgres.sh | 56 ++++++++++++++++++++ 4 files changed, 101 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/01bdb8ec/traffic_ops/app/db/pg-migration/README.md ---------------------------------------------------------------------- diff --git a/traffic_ops/app/db/pg-migration/README.md b/traffic_ops/app/db/pg-migration/README.md index a4675af..8ff9d67 100644 --- a/traffic_ops/app/db/pg-migration/README.md +++ b/traffic_ops/app/db/pg-migration/README.md @@ -6,5 +6,11 @@ * Ensure that your new Postgres service is running (local or remote) +* Run your Postgres Instance and configure mysql-to-postgres.env accordingly + +* A sample Postgres Docker container has been provided for testing + * `sh start_postgres.sh` + + * Run the Mysql to Postgres Migration Docker flow * `sh migrate.sh` http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/01bdb8ec/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 3988845..1f40ecc 100755 --- a/traffic_ops/app/db/pg-migration/migrate.sh +++ b/traffic_ops/app/db/pg-migration/migrate.sh @@ -15,55 +15,76 @@ . mysql-to-postgres.env +#Traffic Ops Settings +# The following configs should be configured to point to the +# Traffic Ops instances that is connected to the MySQL that +# you want to convert separator="---------------------------------------" -function shutdown_trafficops_database() { - docker-compose -p trafficops -f postgres.yml down +function display_env() { + + echo "TO_SERVER: $TO_SERVER" + echo "TO_USER: $TO_USER" + echo "TO_PASSWORD: $TO_PASSWORD" + echo "MYSQL_HOST: $MYSQL_HOST" + echo "MYSQL_PORT: $MYSQL_PORT" + echo "MYSQL_DATABASE: $MYSQL_DATABASE" + echo "MYSQL_USER: $MYSQL_USER" + echo "MYSQL_PASSWORD: $MYSQL_PASSWORD" + + echo "POSTGRES_HOST: $POSTGRES_HOST" + echo "POSTGRES_PORT: $POSTGRES_PORT" + echo "POSTGRES_DATABASE: $POSTGRES_DATABASE" + echo "POSTGRES_USER: $POSTGRES_USER" + echo "POSTGRES_PASSOWRD: $POSTGRES_PASSWORD" + echo "PGDATA: $PGDATA" + echo "PGDATA_VOLUME: $PGDATA_VOLUME" + echo "PGLOGS_VOLUME: $PGLOGS_VOLUME" + } + function start_staging_mysql_server() { + docker-compose -p trafficops -f mysql_host.yml down docker-compose -p trafficops -f mysql_host.yml up --build -d - #Wait for postgres to come up + #Wait for MySQL 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 + #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 "Postgres Host is started..." echo $separator + } +function migrate_data_from_mysql_to_postgres() { -function run_postgres_datatypes_conversion() { echo $separator echo "Starting Mysql to Postgres Migration..." echo $separator - docker-compose -p trafficops -f convert.yml up --build + docker-compose -p trafficops -f mysql-to-postgres.yml down + docker-compose -p trafficops -f mysql-to-postgres.yml up --build } -function migrate_data_from_mysql_to_postgres() { +function run_postgres_datatypes_conversion() { echo $separator echo "Starting Mysql to Postgres Migration..." echo $separator - docker-compose -p trafficops -f mysql-to-postgres.yml up --build + docker-compose -p trafficops -f convert.yml up --build } + function clean() { echo $separator echo "Cleaning up..." @@ -82,7 +103,7 @@ function clean() { } start_staging_mysql_server -start_staging_postgres_server +#display_env migrate_data_from_mysql_to_postgres run_postgres_datatypes_conversion clean http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/01bdb8ec/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 index f68055c..fbcdd46 100644 --- a/traffic_ops/app/db/pg-migration/postgres.yml +++ b/traffic_ops/app/db/pg-migration/postgres.yml @@ -23,8 +23,8 @@ services: ports: - 5432:5432 volumes: - - /opt/postgresql/data/pgdata:/opt/postgresql/data/pgdata - - /var/log/postgresql:/var/log/postgresql + - '$PGDATA_VOLUME:/opt/postgresql/data/pgdata' + - '$PGLOGS_VOLUME:/var/log/postgresql' networks: - default http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/01bdb8ec/traffic_ops/app/db/pg-migration/start_postgres.sh ---------------------------------------------------------------------- diff --git a/traffic_ops/app/db/pg-migration/start_postgres.sh b/traffic_ops/app/db/pg-migration/start_postgres.sh new file mode 100755 index 0000000..f307fd0 --- /dev/null +++ b/traffic_ops/app/db/pg-migration/start_postgres.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# 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. +# + +. mysql-to-postgres.env + +#Traffic Ops Settings +# The following configs should be configured to point to the +# Traffic Ops instances that is connected to the MySQL that +# you want to convert +separator="---------------------------------------" + +function display_env() { + + echo "TO_SERVER: $TO_SERVER" + echo "TO_USER: $TO_USER" + echo "TO_PASSWORD: $TO_PASSWORD" + echo "MYSQL_HOST: $MYSQL_HOST" + echo "MYSQL_PORT: $MYSQL_PORT" + echo "MYSQL_DATABASE: $MYSQL_DATABASE" + echo "MYSQL_USER: $MYSQL_USER" + echo "MYSQL_PASSWORD: $MYSQL_PASSWORD" + + echo "POSTGRES_HOST: $POSTGRES_HOST" + echo "POSTGRES_PORT: $POSTGRES_PORT" + echo "POSTGRES_DATABASE: $POSTGRES_DATABASE" + echo "POSTGRES_USER: $POSTGRES_USER" + echo "POSTGRES_PASSOWRD: $POSTGRES_PASSWORD" + echo "PGDATA: $PGDATA" + echo "PGDATA_VOLUME: $PGDATA_VOLUME" + echo "PGLOGS_VOLUME: $PGLOGS_VOLUME" + +} + +function start_staging_postgres_server() { + + docker-compose -v -p trafficops -f postgres.yml down + + echo "PGDATA_VOLUME: $PGDATA_VOLUME" + echo "PGLOGS_VOLUME: $PGLOGS_VOLUME" + PGLOGS_VOLUME=$PGLOGS_VOLUME PGDATA_VOLUME=$PGDATA_VOLUME docker-compose -p trafficops -f postgres.yml up -d + +} + +start_staging_postgres_server