From a0d2b99b546244c4b7622e4faf6018be2078f547 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 16:59:42 -0800 Subject: [PATCH 01/25] switch default deployment back to master --- README.md | 2 +- template.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2fa614..9abeeb7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Azure Patroni Deployment - + Date: Thu, 2 Feb 2017 17:27:49 -0800 Subject: [PATCH 02/25] added license and readme info --- LICENSE | 21 +++++++++++++++++++++ README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2877737 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 HelloTech + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 9abeeb7..251ea37 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,49 @@ -# Azure Patroni Deployment - - \ No newline at end of file + + +# Azure Patroni Deployment + +One click deployment of a Highly-Available PostgreSQL Cluster on Azure. With automated replication, server management and leader election. This project contains a modified deployment version of Haufe's [blog post](http://dev.haufe.com/PostgreSQL-Cluster-Azure/). + +This azure template generates two sets of machines both running Ubuntu 16.04 LTS. The first set of three machines are used to run the distributed configuration store [ZooKeeper](https://zookeeper.apache.org/), while the second set is running PostgreSQL 9.6 together with [Patroni](https://github.com/zalando/patroni) providing a high-availability customizable PostgreSQL cluster deployment. + +# Parameters + +This template provides the following parameters, so you can customize your deployment to your needs: + + +* clusterName: What your cluster will be named. + +* _artifactsLocation: The repo name from which you are deploying. Default("https://raw.githubusercontent.com/HelloTech/azure_patroni/master") + +* newVnet: Whether or not you want to create a new vnet. Default("yes") + +* vnetGroup: The resource group in which the vnet is located. If you select yes on newVnet this needs to be set to the resource group in which you are deploying. + +* lbType: Whether you want to create an external or internal load balancer. If set to internal the load balancer will only be accessible from inside the virtual network. Default("internal") + +* vnetName: If newVnet is set to yet the this will be name of the created vnet otherwise this is the name of already existing vnet to which the deployment will be associated. + +* zookeeperNetName: If newVnet is set to yes the this will be name of the created subnet for the zookeeper machines, otherwise this is the name of already existing subnet that will contain the zookeeper vm's. + +* postgresNetName: If newVnet is set to yes the this will be name of the created subnet for the postgres machines, otherwise this is the name of already existing subnet that will contain the postgres vm's. + +* zookeeperVMSize: The size of zookeeper vms. + +* postgresVMSize: The size of the postgres vms. + +* postgresDataSize: The size of the ssd used for pg_data for the postgres vms. + +* instanceCount: The number of postgres vms. + +* adminUsername: The Ubuntu username. + +* adminPassword: The Ubuntu password. + +# License + +Released under the MIT license. See the LICENSE file for more info. \ No newline at end of file From f72bf251a586ca313135ada684874bf95b09523a Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 17:35:16 -0800 Subject: [PATCH 03/25] added script info --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 251ea37..ff493e6 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,18 @@ This template provides the following parameters, so you can customize your deplo * adminPassword: The Ubuntu password. + +# Scripts + +### Zookeeper +The creation of the zookeeper instances is handled by the [zookeeper_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/zookeeper_startup.sh) script. If you would like to make any changes to what is installed on those vm's that's the file you should modify. + +### Mounts +The mounting of the data ssds is handled by the [autopart.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/autopart.sh) script. + +### Postgres +The creation of the postgres instances is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's that's the file you should modify. + # License Released under the MIT license. See the LICENSE file for more info. \ No newline at end of file From be6fc64e31a9345d8e1bb61817218754c845e63c Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 19:55:38 -0800 Subject: [PATCH 04/25] added plv8 --- README.md | 14 +++++++------- postgres_startup.sh | 13 +++++++++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ff493e6..edc36bd 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Fhellotech%2Fa # Azure Patroni Deployment -One click deployment of a Highly-Available PostgreSQL Cluster on Azure. With automated replication, server management and leader election. This project contains a modified deployment version of Haufe's [blog post](http://dev.haufe.com/PostgreSQL-Cluster-Azure/). +This one click deployment of a Highly-Available PostgreSQL Cluster on Azure has automated replication, server management and leader election. This project contains a modified deployment version of Haufe's [blog post](http://dev.haufe.com/PostgreSQL-Cluster-Azure/). -This azure template generates two sets of machines both running Ubuntu 16.04 LTS. The first set of three machines are used to run the distributed configuration store [ZooKeeper](https://zookeeper.apache.org/), while the second set is running PostgreSQL 9.6 together with [Patroni](https://github.com/zalando/patroni) providing a high-availability customizable PostgreSQL cluster deployment. +This Azure template generates two sets of machines both running Ubuntu 16.04 LTS. The first set of three machines are used to run the distributed configuration store [ZooKeeper](https://zookeeper.apache.org/), while the second set is running PostgreSQL 9.6 together with [Patroni](https://github.com/zalando/patroni) providing a high-availability customizable PostgreSQL cluster deployment. # Parameters @@ -26,11 +26,11 @@ This template provides the following parameters, so you can customize your deplo * lbType: Whether you want to create an external or internal load balancer. If set to internal the load balancer will only be accessible from inside the virtual network. Default("internal") -* vnetName: If newVnet is set to yet the this will be name of the created vnet otherwise this is the name of already existing vnet to which the deployment will be associated. +* vnetName: If newVnet is set to yes, this will be name of the created vnet. Otherwise, this is the name of already existing vnet to which the deployment will be associated. -* zookeeperNetName: If newVnet is set to yes the this will be name of the created subnet for the zookeeper machines, otherwise this is the name of already existing subnet that will contain the zookeeper vm's. +* zookeeperNetName: If newVnet is set to yes, this will be name of the created subnet for the zookeeper machines, otherwise this is the name of already existing subnet that will contain the zookeeper vm's. -* postgresNetName: If newVnet is set to yes the this will be name of the created subnet for the postgres machines, otherwise this is the name of already existing subnet that will contain the postgres vm's. +* postgresNetName: If newVnet is set to yes, this will be name of the created subnet for the postgres machines, otherwise this is the name of already existing subnet that will contain the postgres vm's. * zookeeperVMSize: The size of zookeeper vms. @@ -48,13 +48,13 @@ This template provides the following parameters, so you can customize your deplo # Scripts ### Zookeeper -The creation of the zookeeper instances is handled by the [zookeeper_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/zookeeper_startup.sh) script. If you would like to make any changes to what is installed on those vm's that's the file you should modify. +The creation of the zookeeper instances is handled by the [zookeeper_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/zookeeper_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify this file. ### Mounts The mounting of the data ssds is handled by the [autopart.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/autopart.sh) script. ### Postgres -The creation of the postgres instances is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's that's the file you should modify. +The creation of the postgres instance is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify that script. # License diff --git a/postgres_startup.sh b/postgres_startup.sh index d9b3ff0..b7beb45 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -79,10 +79,19 @@ echo "pip python-dateutil exited with: $?" #sudo touch /usr/sbin/policy-rc.d #sudo chmod 777 /usr/sbin/policy-rc.d #echo exit 101 > /usr/sbin/policy-rc.d -sudo apt-get --assume-yes --force-yes -qq install postgresql postgresql-contrib -echo "apt-get postgresql postgresql-contrib exited with: $?" +sudo apt-get --assume-yes --force-yes -qq install postgresql postgresql-contrib postgresql-server-dev-9.6 +echo "apt-get postgresql postgresql-server-dev-9.6 postgresql-contrib exited with: $?" export PATH=/usr/lib/postgresql/9.6/bin:$PATH +#install plv8 +wget https://github.com/plv8/plv8/archive/v2.0.0.tar.gz +tar -xvzf v2.0.0.tar.gz +cd plv8-2.0.0 +make static +sudo cp plv8.so /usr/lib/postgresql/9.6/lib/ +sudo cp plv8.control /usr/share/postgresql/9.6/extension/ +sudo cp plv8--2.0.0.sql /usr/share/postgresql/9.6/extension/ + # download patroni sudo apt-get --assume-yes -qq install unzip echo "apt-get unzip exited with: $0" From fe80e0c6ff3add3d00bdc0c4bac57a6c1d80f436 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 19:58:56 -0800 Subject: [PATCH 05/25] added plv8 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index edc36bd..544195b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Fhellotech%2Fa This one click deployment of a Highly-Available PostgreSQL Cluster on Azure has automated replication, server management and leader election. This project contains a modified deployment version of Haufe's [blog post](http://dev.haufe.com/PostgreSQL-Cluster-Azure/). -This Azure template generates two sets of machines both running Ubuntu 16.04 LTS. The first set of three machines are used to run the distributed configuration store [ZooKeeper](https://zookeeper.apache.org/), while the second set is running PostgreSQL 9.6 together with [Patroni](https://github.com/zalando/patroni) providing a high-availability customizable PostgreSQL cluster deployment. +This Azure template generates two sets of machines both running Ubuntu 16.04 LTS. The first set of three machines are used to run the distributed configuration store [ZooKeeper](https://zookeeper.apache.org/), while the second set is running PostgreSQL 9.6 together with [Patroni](https://github.com/zalando/patroni) providing a high-availability customizable PostgreSQL cluster deployment. This deployment also includes [PL/V8 v.2.0.0](https://github.com/plv8/plv8). # Parameters From 08b4441f7ae7d621529724cb110a094b2304d442 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 20:03:48 -0800 Subject: [PATCH 06/25] rename --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 544195b..b97c479 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Fhellotech%2Fazure_patroni%2Fmaster%2Ftemplate.json" target="_blank"> -# Azure Patroni Deployment +# Highly-Available PostgreSQL Cluster (Patroni) on Azure This one click deployment of a Highly-Available PostgreSQL Cluster on Azure has automated replication, server management and leader election. This project contains a modified deployment version of Haufe's [blog post](http://dev.haufe.com/PostgreSQL-Cluster-Azure/). From a6892e7a1cab6b69a6640fb2c03cc974b99ff55b Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 20:08:13 -0800 Subject: [PATCH 07/25] renaming --- README.md | 12 ++++++------ backup.json | 6 +++--- template.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b97c479..c38caba 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ - + +http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2Fhellotech%2Fazure_postgres%2Fmaster%2Ftemplate.json" target="_blank"> # Highly-Available PostgreSQL Cluster (Patroni) on Azure @@ -18,7 +18,7 @@ This template provides the following parameters, so you can customize your deplo * clusterName: What your cluster will be named. -* _artifactsLocation: The repo name from which you are deploying. Default("https://raw.githubusercontent.com/HelloTech/azure_patroni/master") +* _artifactsLocation: The repo name from which you are deploying. Default("https://raw.githubusercontent.com/HelloTech/azure_postgres/master") * newVnet: Whether or not you want to create a new vnet. Default("yes") @@ -48,13 +48,13 @@ This template provides the following parameters, so you can customize your deplo # Scripts ### Zookeeper -The creation of the zookeeper instances is handled by the [zookeeper_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/zookeeper_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify this file. +The creation of the zookeeper instances is handled by the [zookeeper_startup.sh](https://github.com/HelloTech/azure_postgres/blob/custom_deploy/zookeeper_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify this file. ### Mounts -The mounting of the data ssds is handled by the [autopart.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/autopart.sh) script. +The mounting of the data ssds is handled by the [autopart.sh](https://github.com/HelloTech/azure_postgres/blob/custom_deploy/autopart.sh) script. ### Postgres -The creation of the postgres instance is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_patroni/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify that script. +The creation of the postgres instance is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_postgres/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify that script. # License diff --git a/backup.json b/backup.json index ba2c0a3..ab89f52 100644 --- a/backup.json +++ b/backup.json @@ -224,7 +224,7 @@ "typeHandlerVersion": "1.2", "settings": { "fileUris": [ - "https://raw.githubusercontent.com/HelloTech/azure_patroni/master/zookeeper_startup.sh" + "https://raw.githubusercontent.com/HelloTech/azure_postgres/master/zookeeper_startup.sh" ], "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" } @@ -353,8 +353,8 @@ "typeHandlerVersion": "1.2", "settings": { "fileUris": [ - "https://raw.githubusercontent.com/HelloTech/azure_patroni/master/autopart.sh", - "https://raw.githubusercontent.com/HelloTech/azure_patroni/master/postgres_startup.sh" + "https://raw.githubusercontent.com/HelloTech/azure_postgres/master/autopart.sh", + "https://raw.githubusercontent.com/HelloTech/azure_postgres/master/postgres_startup.sh" ], "commandToExecute": "[concat('sh postgres_startup.sh ', parameters('clusterName'), ' ', variables('zookeeperInstanceCount'), ' ', variables('postgresInstanceCount'), ' ', copyIndex(), ' ', parameters('adminUsername'), ' \"', parameters('adminPassword'), '\" ')]" } diff --git a/template.json b/template.json index beefc25..76adb15 100644 --- a/template.json +++ b/template.json @@ -7,7 +7,7 @@ }, "_artifactsLocation": { "type": "string", - "defaultValue": "https://raw.githubusercontent.com/HelloTech/azure_patroni/master", + "defaultValue": "https://raw.githubusercontent.com/HelloTech/azure_postgres/master", "metadata": { "description": "Change this value to your repo name if deploying from a fork" } From eb52bb926335ed061b51f34b01889c9bd3127027 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Thu, 2 Feb 2017 23:39:23 -0800 Subject: [PATCH 08/25] update script to us systemd instead of rc.local --- postgres_startup.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/postgres_startup.sh b/postgres_startup.sh index b7beb45..de8f087 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -170,6 +170,7 @@ fi echo " listen: '*:5433'" >> $patroniCfg echo " connect_address: 10.0.101.$(($myIndex + 10)):5433" >> $patroniCfg echo " data_dir: /media/data1/data/postgresql" >> $patroniCfg +echo " bin_dir: /usr/lib/postgresql/9.6/bin" >> $patroniCfg echo " pgpass: /tmp/pgpass" >> $patroniCfg if [ $myIndex -ne 0 ] then @@ -256,10 +257,20 @@ done sudo haproxy -D -f $hacfgFile # prepare patroni to restart after reboot -sudo chmod 777 /etc/rc.local -echo "sudo haproxy -D -f /usr/local/patroni-master/$hacfgFile" > /etc/rc.local -echo "su -s /bin/bash -c 'export PATH=/usr/lib/postgresql/9.6/bin:\$PATH; /usr/local/patroni-master/patroni.py /usr/local/patroni-master/$patroniCfg >> /usr/local/startup.log' $adminUsername" >> /etc/rc.local -echo "exit 0" >> /etc/rc.local +sudo touch /etc/systemd/system/patroni.service +sudo chmod 777 /etc/systemd/system/patroni.service +echo "[Unit]" > /etc/systemd/system/patroni.service +echo "Description=patroni script" >> /etc/systemd/system/patroni.service +echo "" >> /etc/systemd/system/patroni.service +echo "[Service]" >> /etc/systemd/system/patroni.service +echo "User=$adminUsername" >> /etc/systemd/system/patroni.service +echo "WorkingDirectory=usr/local/patroni-master" >> /etc/systemd/system/patroni.service +echo "ExecStart=/usr/bin/python /usr/local/patroni-master/patroni.py /usr/local/patroni-master/postgres.yml >> /usr/local/startup.log" >> /etc/systemd/system/patroni.service +echo "Restart=always" >> /etc/systemd/system/patroni.service +echo "" >> /etc/systemd/system/patroni.service +echo "[Install]" >> /etc/systemd/system/patroni.service +echo "WantedBy=multi-user.target" >> /etc/systemd/system/patroni.service +sudo systemctl enable patroni.service # start patroni -su -c "export PATH=/usr/lib/postgresql/9.6/bin:$PATH; ./patroni.py $patroniCfg >> /usr/local/startup.log" $adminUsername & echo "spawned" +sudo systemctl start patroni.service From b2fe4f05a78b5332833eaebc3516121843db17b2 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 02:26:48 -0800 Subject: [PATCH 09/25] added note regarding plv8 build time --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c38caba..a13826c 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ The mounting of the data ssds is handled by the [autopart.sh](https://github.com ### Postgres The creation of the postgres instance is handles by the [postgres_startup.sh](https://github.com/HelloTech/azure_postgres/blob/custom_deploy/postgres_startup.sh) script. If you would like to make any changes to what is installed on those vm's modify that script. +### Notes +This deployment can take anywhere from 90 to 120 minutes to complete due to long build time for plv8. + # License Released under the MIT license. See the LICENSE file for more info. \ No newline at end of file From 4a45efcd9bfee555312c5b92659da9c2cdc35d6b Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 11:08:57 -0800 Subject: [PATCH 10/25] add package updates to build process --- postgres_startup.sh | 1 + zookeeper_startup.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/postgres_startup.sh b/postgres_startup.sh index de8f087..112076d 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -38,6 +38,7 @@ sudo chmod 777 /media/data1/data sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - sudo apt-get -qq update +sudo apt-get -qq -y upgrade echo "apt-get update exited with: $?" diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 7ee47dd..6a2284b 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,4 +1,6 @@ #!/bin/bash +sudo apt update +sudo apt upgrade -y wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From 546d29524ba43b0fb477043aa9fb67b17b164df0 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 11:13:37 -0800 Subject: [PATCH 11/25] added updates to postrgres log --- postgres_startup.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/postgres_startup.sh b/postgres_startup.sh index 112076d..6a53580 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -25,6 +25,8 @@ sudo chmod +x ./autopart.sh >> /usr/local/startup.log sudo ./autopart.sh >> /usr/local/startup.log sudo mkdir /media/data1/data sudo chmod 777 /media/data1/data +echo "/media/data1/data partition created" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # create RAID #sudo apt-get --assume-yes -qq install mdadm @@ -40,6 +42,8 @@ wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key a sudo apt-get -qq update sudo apt-get -qq -y upgrade echo "apt-get update exited with: $?" +echo "updated packages" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # install python @@ -73,7 +77,8 @@ sudo pip -q install tzlocal echo "pip tzlocal exited with: $?" sudo pip -q install python-dateutil echo "pip python-dateutil exited with: $?" - +echo "installed python" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # install postgres # prevent postgres from autostart @@ -83,6 +88,8 @@ echo "pip python-dateutil exited with: $?" sudo apt-get --assume-yes --force-yes -qq install postgresql postgresql-contrib postgresql-server-dev-9.6 echo "apt-get postgresql postgresql-server-dev-9.6 postgresql-contrib exited with: $?" export PATH=/usr/lib/postgresql/9.6/bin:$PATH +echo "installed postgres" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log #install plv8 wget https://github.com/plv8/plv8/archive/v2.0.0.tar.gz @@ -92,6 +99,8 @@ make static sudo cp plv8.so /usr/lib/postgresql/9.6/lib/ sudo cp plv8.control /usr/share/postgresql/9.6/extension/ sudo cp plv8--2.0.0.sql /usr/share/postgresql/9.6/extension/ +echo "installed plv8" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # download patroni sudo apt-get --assume-yes -qq install unzip @@ -100,6 +109,8 @@ cd /usr/local sudo wget -O /usr/local/patroni-master.zip https://github.com/zalando/patroni/archive/master.zip sudo unzip patroni-master.zip cd patroni-master +echo "download patroni" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # write configuration sudo touch $patroniCfg @@ -221,6 +232,8 @@ if [ $myIndex -ne 0 ] echo " parameters:" >> $patroniCfg echo " unix_socket_directories: '.'" >> $patroniCfg fi +echo "setup patroni configuration" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # install HA PROXY @@ -253,9 +266,13 @@ do echo " server Postgres$i 10.0.101.$(($i + 10)):5433 maxconn 100 check port 8008" >> $hacfgFile i=$(($i+1)) done +echo "installed haproxy" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # start ha as deamon sudo haproxy -D -f $hacfgFile +echo "started haproxy" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # prepare patroni to restart after reboot sudo touch /etc/systemd/system/patroni.service @@ -272,6 +289,10 @@ echo "" >> /etc/systemd/system/patroni.service echo "[Install]" >> /etc/systemd/system/patroni.service echo "WantedBy=multi-user.target" >> /etc/systemd/system/patroni.service sudo systemctl enable patroni.service +echo "setup reboot script for patroni" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log # start patroni sudo systemctl start patroni.service +echo "started patroni" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log \ No newline at end of file From be6802c8a2528e433c981cba952b156a468448b0 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 11:25:53 -0800 Subject: [PATCH 12/25] added jq installation to both init scripts --- postgres_startup.sh | 1 + zookeeper_startup.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/postgres_startup.sh b/postgres_startup.sh index 6a53580..84e1ecd 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -41,6 +41,7 @@ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs` wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - sudo apt-get -qq update sudo apt-get -qq -y upgrade +sudo apt-get install -y jq echo "apt-get update exited with: $?" echo "updated packages" >> /usr/local/startup.log echo "" >> /usr/local/startup.log diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 6a2284b..9089b7e 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,6 +1,7 @@ #!/bin/bash sudo apt update sudo apt upgrade -y +sudo apt install -y jq wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From 37d630574972afae792a64e997fb9e519771f194 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 14:59:36 -0800 Subject: [PATCH 13/25] add restart true so apps are updated once service starts --- template.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/template.json b/template.json index 76adb15..a164762 100644 --- a/template.json +++ b/template.json @@ -326,7 +326,8 @@ "fileUris": [ "[concat(parameters('_artifactsLocation'), '/zookeeper_startup.sh')]" ], - "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" + "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]", + "Restart": "true" } }, "dependsOn": [ @@ -456,7 +457,8 @@ "[concat(parameters('_artifactsLocation'), '/autopart.sh')]", "[concat(parameters('_artifactsLocation'), '/postgres_startup.sh')]" ], - "commandToExecute": "[concat('sh postgres_startup.sh ', parameters('clusterName'), ' ', variables('zookeeperInstanceCount'), ' ', variables('postgresInstanceCount'), ' ', copyIndex(), ' ', parameters('adminUsername'), ' \"', parameters('adminPassword'), '\" ')]" + "commandToExecute": "[concat('sh postgres_startup.sh ', parameters('clusterName'), ' ', variables('zookeeperInstanceCount'), ' ', variables('postgresInstanceCount'), ' ', copyIndex(), ' ', parameters('adminUsername'), ' \"', parameters('adminPassword'), '\" ')]", + "Restart": "true" } }, "dependsOn": [ From 1c10d3facc40ede996f1cad3a8fe09d68f5a1bb3 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 15:27:32 -0800 Subject: [PATCH 14/25] replace apt with apt-get --- zookeeper_startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 9089b7e..884fa1f 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,7 +1,7 @@ #!/bin/bash -sudo apt update -sudo apt upgrade -y -sudo apt install -y jq +sudo apt-get update +sudo apt-get upgrade -y +sudo apt-get install -y jq wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From ae165873e7c0919a72c392e077ad4589a23a953d Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 15:51:16 -0800 Subject: [PATCH 15/25] another apt-get update --- zookeeper_startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 884fa1f..eac8f7b 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,7 +1,7 @@ #!/bin/bash -sudo apt-get update -sudo apt-get upgrade -y -sudo apt-get install -y jq +sudo apt-get --assume-yes -qq update +sudo apt-get --assume-yes -qq upgrade +sudo apt-get --assume-yes -qq install jq wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From 5d1e920cb43753611fdf90956d88f852552b7eca Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 15:52:49 -0800 Subject: [PATCH 16/25] add assume-yes --- postgres_startup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/postgres_startup.sh b/postgres_startup.sh index 84e1ecd..10cd891 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -39,9 +39,9 @@ echo "" >> /usr/local/startup.log # update package lists for PostgreSQL 9.6 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - -sudo apt-get -qq update -sudo apt-get -qq -y upgrade -sudo apt-get install -y jq +sudo apt-get --assume-yes -qq update +sudo apt-get --assume-yes -qq upgrade +sudo apt-get --assume-yes -qq install jq echo "apt-get update exited with: $?" echo "updated packages" >> /usr/local/startup.log echo "" >> /usr/local/startup.log From ddb0c6c819b761561d7c579396251d13bcebd5f6 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 16:18:58 -0800 Subject: [PATCH 17/25] test --- postgres_startup.sh | 1 + zookeeper_startup.sh | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/postgres_startup.sh b/postgres_startup.sh index 10cd891..0e5216c 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -9,6 +9,7 @@ adminPassword=$6 hacfgFile=postgresha.cfg patroniCfg=postgres.yml +export DEBIAN_FRONTEND=noninteractive sudo touch /usr/local/startup.log sudo chmod 666 /usr/local/startup.log echo "Cluster name: $clusterName" >> /usr/local/startup.log diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index eac8f7b..0cf7cb2 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,7 +1,13 @@ #!/bin/bash +export DEBIAN_FRONTEND=noninteractive +sudo touch /usr/local/startup.log +sudo chmod 666 /usr/local/startup.log sudo apt-get --assume-yes -qq update +echo "ran update" >> /usr/local/startup.log sudo apt-get --assume-yes -qq upgrade +echo "ran upgrade" >> /usr/local/startup.log sudo apt-get --assume-yes -qq install jq +echo "ran install" >> /usr/local/startup.log wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From 04f30686f0ade6aaed12149c3fcbc9a797af6a28 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 16:40:38 -0800 Subject: [PATCH 18/25] update vm on separate script --- postgres_startup.sh | 3 --- template.json | 54 ++++++++++++++++++++++++++++++++++++++++---- zookeeper_startup.sh | 7 ------ 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/postgres_startup.sh b/postgres_startup.sh index 0e5216c..151ed27 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -9,7 +9,6 @@ adminPassword=$6 hacfgFile=postgresha.cfg patroniCfg=postgres.yml -export DEBIAN_FRONTEND=noninteractive sudo touch /usr/local/startup.log sudo chmod 666 /usr/local/startup.log echo "Cluster name: $clusterName" >> /usr/local/startup.log @@ -40,8 +39,6 @@ echo "" >> /usr/local/startup.log # update package lists for PostgreSQL 9.6 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - -sudo apt-get --assume-yes -qq update -sudo apt-get --assume-yes -qq upgrade sudo apt-get --assume-yes -qq install jq echo "apt-get update exited with: $?" echo "updated packages" >> /usr/local/startup.log diff --git a/template.json b/template.json index a164762..0e9dc67 100644 --- a/template.json +++ b/template.json @@ -326,8 +326,31 @@ "fileUris": [ "[concat(parameters('_artifactsLocation'), '/zookeeper_startup.sh')]" ], - "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]", - "Restart": "true" + "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" + } + }, + "dependsOn": [ + "[concat('Microsoft.Compute/virtualMachines/', 'zookeeper', copyIndex())]" + ] + }, + { + "type": "Microsoft.Compute/virtualMachines/extensions", + "name": "[concat('zookeeper', copyIndex(), '/zookeeperExtension')]", + "apiVersion": "2015-05-01-preview", + "location": "[resourceGroup().location]", + "copy": { + "name": "zookeeperExtLoop", + "count": "[variables('zookeeperInstanceCount')]" + }, + "properties": { + "publisher": "Microsoft.OSTCExtensions", + "type": "OSPatchingForLinux", + "typeHandlerVersion": "2.9", + "Settings": { + "disabled": false, + "stop": false, + "category": "ImportantAndRecommended", + "oneoff": true } }, "dependsOn": [ @@ -457,8 +480,31 @@ "[concat(parameters('_artifactsLocation'), '/autopart.sh')]", "[concat(parameters('_artifactsLocation'), '/postgres_startup.sh')]" ], - "commandToExecute": "[concat('sh postgres_startup.sh ', parameters('clusterName'), ' ', variables('zookeeperInstanceCount'), ' ', variables('postgresInstanceCount'), ' ', copyIndex(), ' ', parameters('adminUsername'), ' \"', parameters('adminPassword'), '\" ')]", - "Restart": "true" + "commandToExecute": "[concat('sh postgres_startup.sh ', parameters('clusterName'), ' ', variables('zookeeperInstanceCount'), ' ', variables('postgresInstanceCount'), ' ', copyIndex(), ' ', parameters('adminUsername'), ' \"', parameters('adminPassword'), '\" ')]" + } + }, + "dependsOn": [ + "[concat('Microsoft.Compute/virtualMachines/', 'postgres', copyIndex())]" + ] + }, + { + "type": "Microsoft.Compute/virtualMachines/extensions", + "name": "[concat('postgres', copyIndex(), '/postgresExtension')]", + "apiVersion": "2015-05-01-preview", + "location": "[resourceGroup().location]", + "copy": { + "name": "postgresExtLoop", + "count": "[variables('postgresInstanceCount')]" + }, + "properties": { + "publisher": "Microsoft.OSTCExtensions", + "type": "OSPatchingForLinux", + "typeHandlerVersion": "2.9", + "Settings": { + "disabled": false, + "stop": false, + "category": "ImportantAndRecommended", + "oneoff": true } }, "dependsOn": [ diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 0cf7cb2..e77362d 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,11 +1,4 @@ #!/bin/bash -export DEBIAN_FRONTEND=noninteractive -sudo touch /usr/local/startup.log -sudo chmod 666 /usr/local/startup.log -sudo apt-get --assume-yes -qq update -echo "ran update" >> /usr/local/startup.log -sudo apt-get --assume-yes -qq upgrade -echo "ran upgrade" >> /usr/local/startup.log sudo apt-get --assume-yes -qq install jq echo "ran install" >> /usr/local/startup.log wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" From 73d56957dab7d681aee3a042f18f562c26e0a810 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 16:59:26 -0800 Subject: [PATCH 19/25] remove update extension --- template.json | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/template.json b/template.json index 0e9dc67..76adb15 100644 --- a/template.json +++ b/template.json @@ -333,30 +333,6 @@ "[concat('Microsoft.Compute/virtualMachines/', 'zookeeper', copyIndex())]" ] }, - { - "type": "Microsoft.Compute/virtualMachines/extensions", - "name": "[concat('zookeeper', copyIndex(), '/zookeeperExtension')]", - "apiVersion": "2015-05-01-preview", - "location": "[resourceGroup().location]", - "copy": { - "name": "zookeeperExtLoop", - "count": "[variables('zookeeperInstanceCount')]" - }, - "properties": { - "publisher": "Microsoft.OSTCExtensions", - "type": "OSPatchingForLinux", - "typeHandlerVersion": "2.9", - "Settings": { - "disabled": false, - "stop": false, - "category": "ImportantAndRecommended", - "oneoff": true - } - }, - "dependsOn": [ - "[concat('Microsoft.Compute/virtualMachines/', 'zookeeper', copyIndex())]" - ] - }, { "type": "Microsoft.Network/networkInterfaces", "name": "[concat('postgres', copyIndex(), '-nic')]", @@ -487,30 +463,6 @@ "[concat('Microsoft.Compute/virtualMachines/', 'postgres', copyIndex())]" ] }, - { - "type": "Microsoft.Compute/virtualMachines/extensions", - "name": "[concat('postgres', copyIndex(), '/postgresExtension')]", - "apiVersion": "2015-05-01-preview", - "location": "[resourceGroup().location]", - "copy": { - "name": "postgresExtLoop", - "count": "[variables('postgresInstanceCount')]" - }, - "properties": { - "publisher": "Microsoft.OSTCExtensions", - "type": "OSPatchingForLinux", - "typeHandlerVersion": "2.9", - "Settings": { - "disabled": false, - "stop": false, - "category": "ImportantAndRecommended", - "oneoff": true - } - }, - "dependsOn": [ - "[concat('Microsoft.Compute/virtualMachines/', 'postgres', copyIndex())]" - ] - }, { "type": "Microsoft.Resources/deployments", "name": "lb-temp", From 2f5eacf41a887100444c13bd8fd6c9c3628af6dd Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 17:06:06 -0800 Subject: [PATCH 20/25] test with update only no restart --- zookeeper_startup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index e77362d..6897071 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,4 +1,5 @@ #!/bin/bash +sudo apt-get --assume-yes -qq update sudo apt-get --assume-yes -qq install jq echo "ran install" >> /usr/local/startup.log wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" From 64541dfa0e9359b0b894c7dbd01dde615db411ba Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 17:14:44 -0800 Subject: [PATCH 21/25] test with export DEBIAN_FRONTEND=noninteractive --- template.json | 2 +- zookeeper_startup.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/template.json b/template.json index 76adb15..bec2240 100644 --- a/template.json +++ b/template.json @@ -326,7 +326,7 @@ "fileUris": [ "[concat(parameters('_artifactsLocation'), '/zookeeper_startup.sh')]" ], - "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" + "commandToExecute": "[concat('export DEBIAN_FRONTEND=noninteractive sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" } }, "dependsOn": [ diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 6897071..5d637b9 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,7 +1,6 @@ #!/bin/bash sudo apt-get --assume-yes -qq update sudo apt-get --assume-yes -qq install jq -echo "ran install" >> /usr/local/startup.log wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From b9864c5596a6c22c20a9bde93174913d5c6253d1 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 22:58:55 -0800 Subject: [PATCH 22/25] test with export DEBIAN_FRONTEND=noninteractive --- postgres_startup.sh | 3 ++- zookeeper_startup.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/postgres_startup.sh b/postgres_startup.sh index 151ed27..4369f15 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -39,7 +39,8 @@ echo "" >> /usr/local/startup.log # update package lists for PostgreSQL 9.6 sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add - -sudo apt-get --assume-yes -qq install jq +sudo apt-get -qq update +sudo apt-get --assume-yes -qq install jq echo "apt-get update exited with: $?" echo "updated packages" >> /usr/local/startup.log echo "" >> /usr/local/startup.log diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 5d637b9..5faeac7 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,5 +1,5 @@ #!/bin/bash -sudo apt-get --assume-yes -qq update +#sudo apt-get --assume-yes -qq update sudo apt-get --assume-yes -qq install jq wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* From a0719cbe74f897bc4c52252bd1c55a63b0e1b178 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Fri, 3 Feb 2017 23:49:57 -0800 Subject: [PATCH 23/25] remove more code --- zookeeper_startup.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/zookeeper_startup.sh b/zookeeper_startup.sh index 5faeac7..7ee47dd 100644 --- a/zookeeper_startup.sh +++ b/zookeeper_startup.sh @@ -1,6 +1,4 @@ #!/bin/bash -#sudo apt-get --assume-yes -qq update -sudo apt-get --assume-yes -qq install jq wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz" tar -xvf jdk-7* mkdir /usr/lib/jvm From bf689c92134338412f5faf292cbf992524476dba Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Sat, 4 Feb 2017 00:14:20 -0800 Subject: [PATCH 24/25] fix command bug --- template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.json b/template.json index bec2240..76adb15 100644 --- a/template.json +++ b/template.json @@ -326,7 +326,7 @@ "fileUris": [ "[concat(parameters('_artifactsLocation'), '/zookeeper_startup.sh')]" ], - "commandToExecute": "[concat('export DEBIAN_FRONTEND=noninteractive sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" + "commandToExecute": "[concat('sh zookeeper_startup.sh ', copyIndex(), ' ', variables('zookeeperInstanceCount'))]" } }, "dependsOn": [ From da71606583616de24c3b27548e9f8a4910b31238 Mon Sep 17 00:00:00 2001 From: Paulo Diniz Date: Tue, 7 Feb 2017 16:58:20 -0800 Subject: [PATCH 25/25] added configs to start haproxy on startup --- postgres_startup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/postgres_startup.sh b/postgres_startup.sh index 4369f15..71c9d83 100644 --- a/postgres_startup.sh +++ b/postgres_startup.sh @@ -292,6 +292,19 @@ sudo systemctl enable patroni.service echo "setup reboot script for patroni" >> /usr/local/startup.log echo "" >> /usr/local/startup.log +# prepare haproxy to restart after reboot +sudo chmod 777 /etc/default/haproxy +echo "ENABLED=1" >> /etc/default/haproxy +echo "CONFIG=\"/usr/local/patroni-master/postgresha.cfg\"" >> /etc/default/haproxy +sudo chmod 644 /etc/default/haproxy +echo "setup reboot config for haproxy" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log + +# start haproxy +sudo haproxy -D -f /usr/local/patroni-master/postgresha.cfg +echo "started haproxy" >> /usr/local/startup.log +echo "" >> /usr/local/startup.log + # start patroni sudo systemctl start patroni.service echo "started patroni" >> /usr/local/startup.log