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

CMDB迁移工具变色龙(openGauss-tools-chameleon)安装文档

IT那活儿 2023-03-20
754

点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!




下载方式



1. 变色龙下载

变色龙下载地址:https://gitee.com/opengauss/openGauss-tools-chameleon
注:
1)目前测试过的工具中只有(openGauss-tools-chameleon)这个变色龙工具能进行cmdb的数据同步,其他变色龙工具(如pg_chameleon)对于pg版本的要求均为9.5+。(cmdb查看版本的方式见附录1
2)具体使用方式请关注《chameleon使用指南.md》

2. 依赖库下载

依赖库下载地址:https://pypi.org/
注:
1)如果使用谷歌浏览器无法打开,可以换个浏览器试试,如360安全浏览器

2)下载依赖库安装包时需要注意python版本及其他依赖,python版本查看方式附录2




创建及激活python虚拟环境



1. 创建python虚拟环境

dir_venv为目录名,一般放在${HOME}下。
python3 -m venv <dir_venv>
例如:
python3 -m venv venv

2. 激活python虚拟环境

dir_venv为目录名,一般放在${HOME}下。
source <dir_venv>/bin/activate
例如:
source ${HOME}/venv/bin/activate
注:
1)需先创建并激活python虚拟环境,再安装依赖包,再安装变色龙工具

2)python虚拟环境只需要创建一次,后续直接激活使用即可,每次使用变色龙工具前均需要激活python虚拟环境(窗口未退出不需要重复激活




依赖库安装



变色龙官方使用指南要求的依赖库及版本如下:
PyMySQL>=0.10.0, <1.0.0
argparse>=1.2.1
mysql-replication>=0.22
py-opengauss>=1.3.1
PyYAML>=5.1.2
tabulate>=0.8.1
daemonize>=2.4.7
rollbar>=0.13.17
geomet>=0.3.0
mysqlclient>=2.1.1

实际测试时安装的依赖库及安装顺序需要注意安装顺序,因为依赖库之间也存在依赖关系):

daemonize-2.5.0
PyMySQL-0.10.0
PyYAML-6.0
certifi-2022.12.7
urllib3-1.26.14
idna-2.10
chardet-4.0.0
six-1.16.0
requests-2.25.1
tabulate-0.8.10
rollbar-0.16.3
psycopg2-2.9.5
psycopg2-binary-2.9.5
argparse-1.4.0
click-6.6
geomet-0.3.0
mysqlclient-2.1.1
py-opengauss-1.3.9
mysql-replication-0.26

依赖库安装步骤示例如下,依次将所有依赖库按顺序安装即可
tar -zxf daemonize-2.5.0.tar.gz
cd daemonize-2.5.0
python3 setup.py install

注:依赖库安装日志见附录3




变色龙工具安装



unzip openGauss-tools-chameleon-master.zip
cd /data/cmdb/pg_chameleon/openGauss-tools-chameleon-master
python3 setup.py install

注:变色龙工具安装日志见附录4




变色龙工具安装完成后初始化



chameleon set_configuration_files
# 初始化日志如下:
creating directory /home/omn/.pg_chameleon
creating directory /home/omn/.pg_chameleon/configuration/
creating directory /home/omn/.pg_chameleon/logs/
creating directory /home/omn/.pg_chameleon/pid/
copying configuration example in /home/omn/.pg_chameleon/configuration//config-example.yml

初始化完成后,会在${HOME}下创建 .pg_chameleon目录。




附 录



1. 查看cmdb版本及其内核版本的方式

1)查看cmdb的版本
select version();
2)查看cmdb的pg版本
show server_version;

2. 查看python版本

  • python -V
  • python3 -V

3. 依赖库安装成功日志示例

[15:43:46](venv) [omn@tidb1 daemonize-2.5.0]$ cd daemonize-2.5.0                ; python3 setup.py install
[15:43:46]running install
[15:43:46]running egg_info
[15:43:46]writing daemonize.egg-info/PKG-INFO
[15:43:46]writing dependency_links to daemonize.egg-info/dependency_links.txt
[15:43:46]writing top-level names to daemonize.egg-info/top_level.txt
[15:43:46]reading manifest file 'daemonize.egg-info/SOURCES.txt'
[15:43:46]reading manifest template 'MANIFEST.in'
[15:43:46]warning: no previously-included files matching '*.pyc' found under directory 'docs'
[15:43:46]warning: no previously-included files matching '*.pyo' found under directory 'docs'
[15:43:46]writing manifest file 'daemonize.egg-info/SOURCES.txt'
[15:43:46]installing library code to build/bdist.linux-x86_64/egg
[15:43:46]running install_lib
[15:43:46]running build_py
[15:43:46]creating build/bdist.linux-x86_64/egg
[15:43:46]copying build/lib/daemonize.py -> build/bdist.linux-x86_64/egg
[15:43:46]byte-compiling build/bdist.linux-x86_64/egg/daemonize.py to daemonize.cpython-36.pyc
[15:43:46]creating build/bdist.linux-x86_64/egg/EGG-INFO
[15:43:46]copying daemonize.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
[15:43:46]copying daemonize.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[15:43:46]copying daemonize.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[15:43:46]copying daemonize.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[15:43:46]zip_safe flag not set; analyzing archive contents...
[15:43:46]creating 'dist/daemonize-2.5.0-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
[15:43:46]removing 'build/bdist.linux-x86_64/egg' (and everything under it)
[15:43:46]Processing daemonize-2.5.0-py3.6.egg
[15:43:46]Removing home/omn/venv/lib/python3.6/site-packages/daemonize-2.5.0-py3.6.egg
[15:43:46]Copying daemonize-2.5.0-py3.6.egg to /home/omn/venv/lib/python3.6/site-packages
[15:43:46]daemonize 2.5.0 is already the active version in easy-install.pth
[15:43:46]
[15:43:46]Installed /home/omn/venv/lib/python3.6/site-packages/daemonize-2.5.0-py3.6.egg
[15:43:46]Processing dependencies for daemonize==2.5.0
[15:43:46]Finished processing dependencies for daemonize==2.5.0

4. 变色龙安装成功日志

[16:54:58](venv) [omn@tidb1 openGauss-tools-chameleon-master]$ python3 setup.py install
[16:54:58]running install
[16:54:58]running bdist_egg
[16:54:58]running egg_info
[16:54:58]writing chameleon.egg-info/PKG-INFO
[16:54:58]writing dependency_links to chameleon.egg-info/dependency_links.txt
[16:54:58]writing requirements to chameleon.egg-info/requires.txt
[16:54:58]writing top-level names to chameleon.egg-info/top_level.txt
[16:54:58]reading manifest file 'chameleon.egg-info/SOURCES.txt'
[16:54:58]reading manifest template 'MANIFEST.in'
[16:54:58]writing manifest file 'chameleon.egg-info/SOURCES.txt'
[16:54:58]installing library code to build/bdist.linux-x86_64/egg
[16:54:58]running install_lib
[16:54:58]running build_py
[16:54:58]creating build/bdist.linux-x86_64/egg
[16:54:58]creating build/bdist.linux-x86_64/egg/pg_chameleon
[16:54:58]creating build/bdist.linux-x86_64/egg/pg_chameleon/sql
[16:54:58]copying build/lib/pg_chameleon/sql/create_schema.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql
[16:54:58]creating build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/205_to_206.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/206_to_207.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/200_to_201.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/202_to_203.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/203_to_204.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/204_to_205.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/upgrade/201_to_202.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql/upgrade
[16:54:58]copying build/lib/pg_chameleon/sql/drop_schema.sql -> build/bdist.linux-x86_64/egg/pg_chameleon/sql
[16:54:58]copying build/lib/pg_chameleon/__init__.py -> build/bdist.linux-x86_64/egg/pg_chameleon
[16:54:58]creating build/bdist.linux-x86_64/egg/pg_chameleon/configuration
[16:54:58]copying build/lib/pg_chameleon/configuration/config-example.yml -> build/bdist.linux-x86_64/egg/pg_chameleon/configuration
[16:54:58]creating build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/pg_lib.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/__init__.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/parallel_replication.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/sql_util.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/global_lib.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/sql-translator-1.0.jar -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/task_lib.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]copying build/lib/pg_chameleon/lib/mysql_lib.py -> build/bdist.linux-x86_64/egg/pg_chameleon/lib
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/__init__.py to __init__.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/pg_lib.py to pg_lib.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/__init__.py to __init__.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/parallel_replication.py to parallel_replication.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/sql_util.py to sql_util.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/global_lib.py to global_lib.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/task_lib.py to task_lib.cpython-36.pyc
[16:54:58]byte-compiling build/bdist.linux-x86_64/egg/pg_chameleon/lib/mysql_lib.py to mysql_lib.cpython-36.pyc
[16:54:58]creating build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
[16:54:58]running install_scripts
[16:54:58]running build_scripts
[16:54:58]creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
[16:54:58]copying build/scripts-3.6/chameleon -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
[16:54:58]copying build/scripts-3.6/chameleon.py -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
[16:54:58]changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/chameleon to 755
[16:54:58]changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/chameleon.py to 755
[16:54:58]copying chameleon.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]copying chameleon.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]copying chameleon.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]copying chameleon.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]copying chameleon.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
[16:54:58]zip_safe flag not set; analyzing archive contents...
[16:54:58]pg_chameleon.lib.__pycache__.global_lib.cpython-36: module references __file__
[16:54:58]pg_chameleon.lib.__pycache__.pg_lib.cpython-36: module references __file__
[16:54:58]pg_chameleon.lib.__pycache__.sql_util.cpython-36: module references __file__
[16:54:58]creating 'dist/chameleon-3.1.1-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
[16:54:58]removing 'build/bdist.linux-x86_64/egg' (and everything under it)
[16:54:58]Processing chameleon-3.1.1-py3.6.egg
[16:54:58]removing '/home/omn/venv/lib/python3.6/site-packages/chameleon-3.1.1-py3.6.egg' (and everything under it)
[16:54:58]creating /home/omn/venv/lib/python3.6/site-packages/chameleon-3.1.1-py3.6.egg
[16:54:58]Extracting chameleon-3.1.1-py3.6.egg to /home/omn/venv/lib/python3.6/site-packages
[16:54:59]chameleon 3.1.1 is already the active version in easy-install.pth
[16:54:59]Installing chameleon.py script to /home/omn/venv/bin
[16:54:59]Installing chameleon script to /home/omn/venv/bin
[16:54:59]
[16:54:59]Installed /home/omn/venv/lib/python3.6/site-packages/chameleon-3.1.1-py3.6.egg
[16:54:59]Processing dependencies for chameleon==3.1.1
[16:54:59]Searching for mysqlclient==2.1.1
[16:54:59]Best match: mysqlclient 2.1.1
[16:54:59]Processing mysqlclient-2.1.1-py3.6-linux-x86_64.egg
[16:54:59]mysqlclient 2.1.1 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/mysqlclient-2.1.1-py3.6-linux-x86_64.egg
[16:54:59]Searching for geomet==0.3.0
[16:54:59]Best match: geomet 0.3.0
[16:54:59]Processing geomet-0.3.0-py3.6.egg
[16:54:59]geomet 0.3.0 is already the active version in easy-install.pth
[16:54:59]Installing geomet script to /home/omn/venv/bin
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/geomet-0.3.0-py3.6.egg
[16:54:59]Searching for rollbar==0.16.3
[16:54:59]Best match: rollbar 0.16.3
[16:54:59]Processing rollbar-0.16.3-py3.6.egg
[16:54:59]rollbar 0.16.3 is already the active version in easy-install.pth
[16:54:59]Installing rollbar script to /home/omn/venv/bin
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/rollbar-0.16.3-py3.6.egg
[16:54:59]Searching for daemonize==2.5.0
[16:54:59]Best match: daemonize 2.5.0
[16:54:59]Processing daemonize-2.5.0-py3.6.egg
[16:54:59]daemonize 2.5.0 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/daemonize-2.5.0-py3.6.egg
[16:54:59]Searching for tabulate==0.8.10
[16:54:59]Best match: tabulate 0.8.10
[16:54:59]Processing tabulate-0.8.10-py3.6.egg
[16:54:59]tabulate 0.8.10 is already the active version in easy-install.pth
[16:54:59]Installing tabulate script to /home/omn/venv/bin
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/tabulate-0.8.10-py3.6.egg
[16:54:59]Searching for PyYAML==6.0
[16:54:59]Best match: PyYAML 6.0
[16:54:59]Processing PyYAML-6.0-py3.6-linux-x86_64.egg
[16:54:59]PyYAML 6.0 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/PyYAML-6.0-py3.6-linux-x86_64.egg
[16:54:59]Searching for py-opengauss==1.3.9
[16:54:59]Best match: py-opengauss 1.3.9
[16:54:59]Processing py_opengauss-1.3.9-py3.6-linux-x86_64.egg
[16:54:59]py-opengauss 1.3.9 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/py_opengauss-1.3.9-py3.6-linux-x86_64.egg
[16:54:59]Searching for mysql-replication==0.26
[16:54:59]Best match: mysql-replication 0.26
[16:54:59]Processing mysql_replication-0.26-py3.6.egg
[16:54:59]mysql-replication 0.26 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/mysql_replication-0.26-py3.6.egg
[16:54:59]Searching for argparse==1.4.0
[16:54:59]Best match: argparse 1.4.0
[16:54:59]Processing argparse-1.4.0-py3.6.egg
[16:54:59]argparse 1.4.0 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/argparse-1.4.0-py3.6.egg
[16:54:59]Searching for PyMySQL==0.10.0
[16:54:59]Best match: PyMySQL 0.10.0
[16:54:59]Processing PyMySQL-0.10.0-py3.6.egg
[16:54:59]PyMySQL 0.10.0 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/PyMySQL-0.10.0-py3.6.egg
[16:54:59]Searching for six==1.16.0
[16:54:59]Best match: six 1.16.0
[16:54:59]Processing six-1.16.0-py3.6.egg
[16:54:59]six 1.16.0 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/six-1.16.0-py3.6.egg
[16:54:59]Searching for click==6.6
[16:54:59]Best match: click 6.6
[16:54:59]Processing click-6.6-py3.6.egg
[16:54:59]click 6.6 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/click-6.6-py3.6.egg
[16:54:59]Searching for requests==2.25.1
[16:54:59]Best match: requests 2.25.1
[16:54:59]Processing requests-2.25.1-py3.6.egg
[16:54:59]requests 2.25.1 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/requests-2.25.1-py3.6.egg
[16:54:59]Searching for certifi==2022.12.7
[16:54:59]Best match: certifi 2022.12.7
[16:54:59]Processing certifi-2022.12.7-py3.6.egg
[16:54:59]certifi 2022.12.7 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/certifi-2022.12.7-py3.6.egg
[16:54:59]Searching for urllib3==1.26.14
[16:54:59]Best match: urllib3 1.26.14
[16:54:59]Processing urllib3-1.26.14-py3.6.egg
[16:54:59]urllib3 1.26.14 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/urllib3-1.26.14-py3.6.egg
[16:54:59]Searching for idna==2.10
[16:54:59]Best match: idna 2.10
[16:54:59]Processing idna-2.10-py3.6.egg
[16:54:59]idna 2.10 is already the active version in easy-install.pth
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/idna-2.10-py3.6.egg
[16:54:59]Searching for chardet==4.0.0
[16:54:59]Best match: chardet 4.0.0
[16:54:59]Processing chardet-4.0.0-py3.6.egg
[16:54:59]chardet 4.0.0 is already the active version in easy-install.pth
[16:54:59]Installing chardetect script to /home/omn/venv/bin
[16:54:59]
[16:54:59]Using /home/omn/venv/lib/python3.6/site-packages/chardet-4.0.0-py3.6.egg
[16:54:59]Finished processing dependencies for chameleon==3.1.1
[16:55:01](venv) [omn@tidb1 openGauss-tools-chameleon-master]$

END


本文作者:伍 维(上海新炬中北团队)

本文来源:“IT那活儿”公众号

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论