暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

如何升级 Patroni

原创 谭磊Terry 恩墨学院 2022-07-15
823

我已经有一段时间没有写关于PostgreSQL 13 和 Patroni 2.0的博文了。在这个博客上,我收到了一条评论,如果可以解释,如何从 Patroni 1.6 升级到 2。所以让我们写一个关于 Patroni 升级过程的简短博客。

对于我的初始安装,使用的是 python pip,而不是 rpm 包。但是使用 pip 进行升级也非常简单直接。没有必要停止 Patroni。但像往常一样,请确保您有数据库的备份或服务器的快照(如果适用)。

第一步,让我们检查 Patroni 的当前版本并升级 pip 本身和 setuptools 以确保它也在最新版本上。

postgres@patroni1:/u02/pgdata/ [PG1] patronictl version
patronictl version 1.6.4
postgres@patroni1:/u02/pgdata/ [PG1] python3 -m pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
     |████████████████████████████████| 1.7 MB 2.0 MB/s
Installing collected packages: pip
Successfully installed pip-21.3.1
postgres@patroni1:/u02/pgdata/ [PG1] python3 -m pip install --upgrade --user setuptools
Requirement already satisfied: setuptools in /home/postgres/.local/lib/python3.6/site-packages (45.2.0)
Collecting setuptools
  Downloading setuptools-59.6.0-py3-none-any.whl (952 kB)
     |████████████████████████████████| 952 kB 1.6 MB/s
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 45.2.0
    Uninstalling setuptools-45.2.0:
      Successfully uninstalled setuptools-45.2.0
Successfully installed setuptools-59.6.0
postgres@patroni3:/u01/app/postgres/product/ [PG1]

之后我们升级 Patroni 本身。这也可以使用带有 –upgrade 选项的 python pip 完成。

postgres@patroni1:/u02/pgdata/ [PG1]  python3 -m pip install --upgrade  --user patroni[etcd]
Requirement already satisfied: patroni[etcd] in /home/postgres/.local/lib/python3.6/site-packages (1.6.4)
Collecting patroni[etcd]
  Downloading patroni-2.1.3-py3-none-any.whl (222 kB)
     |████████████████████████████████| 222 kB 1.6 MB/s
Requirement already satisfied: psutil>=2.0.0 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (5.7.0)
Requirement already satisfied: six>=1.7 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (1.14.0)
Requirement already satisfied: urllib3!=1.21,>=1.19.1 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (1.25.8)
Collecting ydiff>=1.2.0
  Downloading ydiff-1.2.tar.gz (42 kB)
     |████████████████████████████████| 42 kB 2.1 MB/s
  Preparing metadata (setup.py) ... done
Requirement already satisfied: click>=4.1 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (7.0)
Requirement already satisfied: PyYAML in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (5.3)
Requirement already satisfied: prettytable>=0.7 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (0.7.2)
Requirement already satisfied: python-dateutil in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (2.8.1)
Requirement already satisfied: python-etcd=0.4.3 in /home/postgres/.local/lib/python3.6/site-packages (from patroni[etcd]) (0.4.5)
Requirement already satisfied: dnspython>=1.13.0 in /home/postgres/.local/lib/python3.6/site-packages (from python-etcd=0.4.3->patroni[etcd])                                                                                                                                                            (1.16.0)
Using legacy 'setup.py install' for ydiff, since package 'wheel' is not installed.
Installing collected packages: ydiff, patroni
    Running setup.py install for ydiff ... done
  Attempting uninstall: patroni
    Found existing installation: patroni 1.6.4
    Uninstalling patroni-1.6.4:
      Successfully uninstalled patroni-1.6.4
Successfully installed patroni-2.1.3 ydiff-1.2
postgres@patroni3:/u01/app/postgres/product/ [PG1] 

为确保一切按预期工作,请检查最后一步中的版本和集群本身

postgres@patroni1:/u02/pgdata/ [PG1]  patronictl list
+ Cluster: PG1 (7093128570847303467) -+---------+----+-----------+
| Member   | Host           | Role    | State   | TL | Lag in MB |
+----------+----------------+---------+---------+----+-----------+
| patroni1 | 192.168.22.111 | Leader  | running |  4 |           |
| patroni2 | 192.168.22.112 | Replica | running |  4 |         0 |
| patroni3 | 192.168.22.113 | Replica | running |  4 |         0 |
+----------+----------------+---------+---------+----+-----------+
 
postgres@patroni1:/u02/pgdata/ [PG1] patroni --version
patroni 2.1.3

一旦这在一个节点上成功完成,您就可以继续使用集群中的其他节点

原文标题:How to upgrade Patroni
原文作者:Julia Gugel
原文地址:https://www.dbi-services.com/blog/how-to-upgrade-patroni/

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论