Re: Upgrading postgres to 10 running with patroni

From: Debraj Manna <subharaj(dot)manna(at)gmail(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Upgrading postgres to 10 running with patroni
Date: 2017-11-16 19:25:38
Message-ID: CAF6DVKNn76CRhaCJUYJJ9jk7grd+HUBf-XfAjPM893q1BTNLBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

After upgrading my patroni to 1.3.6 I am not seeing any exception. But on
trying to start patroini I am seeing logs like below

ubuntu(at)vrni-platform:/var/log/postgresql$ patroni /etc/patroni/patroni.yml
2017-11-16 19:19:38,036 INFO: Connecting to localhost:2181
2017-11-16 19:19:38,040 INFO: Zookeeper connection established, state: CONNECTED
2017-11-16 19:19:38,053 INFO: Lock owner: None; I am postgresql0
2017-11-16 19:19:38,058 INFO: waiting for leader to bootstrap
2017-11-16 19:19:38,061 INFO: Lock owner: None; I am postgresql0
2017-11-16 19:19:38,061 INFO: waiting for leader to bootstrap

Also postgres is not running

psql -U postgres -d vnera -p 5432 -h 127.0.0.1
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

Can someone let me know how can I get around this? Do I have to make
any changes in `patroni.yml` after upgrading to 1.3.6 ?

On Thu, Nov 16, 2017 at 2:04 PM, Debraj Manna <subharaj(dot)manna(at)gmail(dot)com>
wrote:

> Thanks Magnus. I will upgrade patroni and come back with my findings.
>
> Do you find any other faults in the steps that I have been performing.
>
> On Thu, Nov 16, 2017 at 1:10 PM, Magnus Hagander <magnus(at)hagander(dot)net>
> wrote:
>
>> You need Patroni 1.3 to work with postgresql version 10. My guess is
>> that's where your problem is.
>>
>> /Magnus
>>
>> On Nov 16, 2017 08:34, "Debraj Manna" <subharaj(dot)manna(at)gmail(dot)com> wrote:
>>
>>> I am attaching my patroni.yml for reference.
>>>
>>> On Thu, Nov 16, 2017 at 12:59 PM, Debraj Manna <subharaj(dot)manna(at)gmail(dot)com
>>> > wrote:
>>>
>>>> Hi
>>>>
>>>> I am trying to upgrade postgres 9.5 to postgres 10 running with
>>>> patroni. I am using patroni 1.0 with single node postgres.
>>>>
>>>> The steps that I have been following -
>>>>
>>>> *Stop patroni*
>>>> sudo kill -9 <patroni process id>
>>>>
>>>>
>>>> *Install postgres-10*
>>>> sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/
>>>> trusty-pgdg main"
>>>> wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |
>>>> sudo apt-key add -
>>>> sudo apt-get update
>>>> sudo apt-get install postgresql-10
>>>>
>>>> *Stop postgresql cluster*
>>>>
>>>> *Init data directory for the new upgrade*
>>>> sudo -H -u postgres mkdir -p /var/lib/postgresql/10/data/postgresql0
>>>> sudo -H -u postgres /usr/lib/postgresql/10/bin/pg_ctl -D
>>>> /var/lib/postgresql/10/data/postgresql0 initdb -o '--data-checksums'
>>>> -o '--locale=C' -o '--encoding=utf8'
>>>>
>>>> *Change data_directory in postgresq.conf for both 9.5 & 10*
>>>> data_directory - /var/lib/postgresql/data/postgresql0 # For
>>>> postgresql-9.5
>>>> data_directory - /var/lib/postgresql/10/data/postgresql0 # For
>>>> postgresql-10
>>>>
>>>> *Perform the upgrade*
>>>> cd /tmp
>>>> sudo -H -u postgres /usr/lib/postgresql/10/bin/pg_upgrade \
>>>> -b /usr/lib/postgresql/9.5/bin \
>>>> -B /usr/lib/postgresql/10/bin \
>>>> -d /var/lib/postgresql/data/postgresql0 \
>>>> -D /var/lib/postgresql/10/data/postgresql0 \
>>>> -o ' -c config_file=/etc/postgresql/9.5/main/postgresql.conf' \
>>>> -O ' -c config_file=/etc/postgresql/10/main/postgresql.conf' -k
>>>>
>>>> *./analyze_new_cluster.sh reported success.*
>>>>
>>>> *Copy conf files*
>>>> Copied postgresql.base.conf, postgresql.conf , pg_hba.conf &
>>>> postmaster.opts from 9.5 data directory /var/lib/postgresql/
>>>> data/postgresql0 to the 10 data directory /var/lib/postgresql/
>>>> 10/data/postgresql0
>>>>
>>>>
>>>> *Change postmaster.opts to match postgres-10 locations*
>>>> /usr/lib/postgresql/10/bin/postgres "-D" "/var/lib/postgresql/10/data/postgresql0"
>>>> "-p" "50432" "-b" "-c" "config_file=/etc/postgresql/10/main/postgresql.conf"
>>>> "-c" "listen_addresses=" "-c" "unix_socket_permissions=0700" "-c"
>>>> "unix_socket_directories=/tmp"
>>>>
>>>>
>>>> *Change data_dir in patroni.yml to/var/lib/postgresql/10/data/postgresql0*
>>>>
>>>> On starting patroni I am getting exception like below and also the DB
>>>> is not accessible.
>>>>
>>>> 2017-11-16 07:11:18,622 INFO: Connecting to localhost:2181
>>>> 2017-11-16 07:11:18,624 INFO: Zookeeper connection established, state: CONNECTED
>>>> 2017-11-16 07:11:19,132 INFO: Closing connection to localhost:2181
>>>> 2017-11-16 07:11:19,132 INFO: Zookeeper session lost, state: CLOSED
>>>> 2017-11-16 07:11:19,133 INFO: Connecting to localhost:2181
>>>> 2017-11-16 07:11:19,135 INFO: Zookeeper connection established, state: CONNECTED
>>>> Traceback (most recent call last):
>>>> File "/usr/local/bin/patroni", line 11, in <module>
>>>> load_entry_point('patroni==1.0', 'console_scripts', 'patroni')()
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/__init__.py", line 128, in main
>>>> patroni.run()
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/__init__.py", line 102, in run
>>>> logger.info(self.ha.run_cycle())
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 502, in run_cycle
>>>> return self._run_cycle()
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/ha.py", line 470, in _run_cycle
>>>> if self.sysid_valid(self.cluster.initialize) and self.cluster.initialize != self.state_handler.sysid:
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/postgresql.py", line 257, in sysid
>>>> data = self.controldata()
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/postgresql.py", line 675, in controldata
>>>> result = {l.split(':')[0].replace('Current ', '', 1): l.split(':')[1].strip() for l in data if l}
>>>> File "/usr/local/lib/python2.7/dist-packages/patroni/postgresql.py", line 675, in <dictcomp>
>>>> result = {l.split(':')[0].replace('Current ', '', 1): l.split(':')[1].strip() for l in data if l}
>>>> IndexError: list index out of range
>>>> ~
>>>>
>>>> I was able to access the DB before starting patroni. So I think I
>>>> missed something on patroni side.
>>>>
>>>> I am not sure if this is the right forum to ask this question. If
>>>> anyone has tried this please do let me know your thoughts.
>>>>
>>>
>>>
>>>
>>> --
>>> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>> http://www.postgresql.org/mailpref/pgsql-admin
>>>
>>>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Debraj Manna 2017-11-17 07:46:36 Re: Upgrading postgres to 10 running with patroni
Previous Message rammohan ganapavarapu 2017-11-16 16:58:42 Re: Can master and slave on different PG versions?