centos7离线部署Patroni

实验环境Centos7.7.1908 x86_64

这里说明下为什么需要安装gcc readline-devel zlib-devel这三个包,因为编译安装postgres需要用到

一、首先安装gcc

准备以下rpm包

 这边从华为云开源镜像站获取rpm包,当然你也可以从阿里或者163镜像站获取

https://mirrors.huaweicloud.com/centos/7.7.1908/os/x86_64/Packages/

 下载后上传至内网,执行以下命令安装

rpm -ivh *.rpm --nodeps --force
gcc -v  \\查询gcc版本号,验证是否安装成功

 二、安装readline-devel

准备以下rpm包,按照步骤一从华为云开源镜像站获取

rpm -ivh ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm   //按照顺序,依次安装
rpm -ivh readline-devel-6.2-11.el7.x86_64.rpm

 三、安装zlib-devel,按照步骤一从华为云开源镜像站获取

rpm -ivh zlib-devel-1.2.7-18.el7.x86_64

 四、安装python-devel,这里我们一样从华为云开源镜像站获取以下rpm包

python2-rpm-macros-3-32.el7.noarch.rpm
python-devel-2.7.5-86.el7.x86_64.rpm
python-rpm-macros-3-32.el7.noarch.rpm
python-srpm-macros-3-32.el7.noarch.rpm

 五、将以上rpm包放置单独目录中,并执行安装全部rpm包

rpm -ivh *.rpm --nodeps --force

 六、离线安装pip,首先下载pip离线包

wget https://mirrors.aliyun.com/pypi/packages/ce/ea/9b445176a65ae4ba22dce1d93e4b5fe182f953df71a145f557cffaffc1bf/pip-19.3.1.tar.gz
tar -xf pip-19.3.1.tar.gz
cd pip-19.3.1
python  setup.py install

 七、下载setuptools的whl包,并安装setuptools

wget https://mirrors.aliyun.com/pypi/packages/54/28/c45d8b54c1339f9644b87663945e54a8503cfef59cf0f65b3ff5dd17cf64/setuptools-42.0.2-py2.py3-none-any.whl
pip install setuptools-42.0.2-py2.py3-none-any.whl

 八、下载并安装所有patroni用到的pip包

mkdir patroni
cd patroni
wget http://mirrors.aliyun.com/pypi/packages/97/2a/b854019bcb9b925cd10ff245dbc9448a82fe7fdb40127e5cf1733ad0765c/psycopg2_binary-2.8.4-cp27-cp27mu-manylinux1_x86_64.whl
wget https://mirrors.aliyun.com/pypi/packages/b4/40/a9837291310ee1ccc242ceb6ebfd9eb21539649f193a7c8c86ba15b98539/urllib3-1.25.7-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/32/80/8c0fbf433eb9e09eb025bb4f942881cfcf2e343db0750fd50873b4722b43/patroni-1.6.1.tar.gz
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/ef/99/53bd1ac9349262f59c1c421d8fcc2559ae8a5eeffed9202684756b648d33/tzlocal-2.0.0-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/73/93/4f8213fbe66fc20cb904f35e6e04e20b47b85bee39845cc66a0bcf5ccdcb/psutil-5.6.7.tar.gz
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/69/6c/301876940e760a8b46c1caacf08c298f511f517c70eec32e43f38e9cc6f5/cdiff-1.0.tar.gz
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/3f/d0/59bc5f1c6c4d4b498c41d8ce7052ee9e9d68be19e16038a55252018a6c4d/python_consul-1.1.0-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/a1/da/616a4d073642da5dd432e5289b7c1cb0963cc5dde23d1ecb8d726821ab41/python-etcd-0.4.5.tar.gz
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl
wget http://mirrors.cloud.aliyuncs.com/pypi/packages/ec/d3/3aa0e7213ef72b8585747aa0e271a9523e713813b9a20177ebe1e939deb0/dnspython-1.16.0-py2.py3-none-any.whl
pip install *.whl          //这里执行批量安装所有whl包

 九、按照以下顺序安装上面下载的tar包

pip install psutil-5.6.7.tar.gz
pip install cdiff-1.0.tar.gz 
pip install python-etcd-0.4.5.tar.gz
pip install patroni-1.6.1.tar.gz

八、执行patronictl version查询patroni版本号,验证是否安装成功

注意这边离线安装,当切换至postgres用户执行patroni命令时会报如下错误,但使用root用户是正常

-bash-4.2$ patroni -help
Traceback (most recent call last):
File "/bin/patroni", line 6, in
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

解决方法:python模块目录权限不足导致

chmod -Rf 755 /usr/lib/python2.7/site-packages/
chmod -Rf 755 /usr/lib64/python2.7/site-packages/
chmod 755 /usr/bin/patroni
chmod 755 /usr/bin/patronictl 
chmod 755 /usr/bin/patroni_aws
chmod 755 /usr/bin/patroni_wale_restore

 最后建议如果条件允许的话还是推荐使用容器或者Kubernetes进行部署,部署更加简单,迁移也方便,等有时间会做下实验

 附上参考链接:https://github.com/zalando/patroni/blob/master/docker-compose.yml

posted @ 2019-12-02 21:32  也曾少年  阅读(2188)  评论(0编辑  收藏  举报