DB_MONITOR环境部署

1. 安装cx_oracle

下载:https://pypi.org/project/cx_Oracle/5.1.3/#files

[dbmon@mysql ~]$ tar -xvzf cx_Oracle-5.1.3.tar.gz

注意配置ORACLE_HOME,否则会报错

[root@mysql cx_Oracle-5.1.3]# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 135, in 
    raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation

还是报错:

[dbmon@mysql cx_Oracle-5.1.3]$ python setup.py install
running install
running build
running build_ext
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dbmon/instantclient_11_2/sdk/include -I/usr/local/python-2.7.14/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3
In file included from /home/dbmon/instantclient_11_2/sdk/include/oci.h:3045,
                 from cx_Oracle.c:10:
/home/dbmon/instantclient_11_2/sdk/include/ociap.h:10795: warning: function declaration isn’t a prototype
/home/dbmon/instantclient_11_2/sdk/include/ociap.h:10801: warning: function declaration isn’t a prototype
gcc -pthread -shared build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -L/home/dbmon/instantclient_11_2 -lclntsh -o build/lib.linux-x86_64-2.7-11g/cx_Oracle.so
/usr/bin/ld: cannot find -lclntsh
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

将oracle_home中的libclntsh.so.11.1复制一份到libclntsh.so即可

[dbmon@mysql instantclient_11_2]$ cp libclntsh.so.11.1 libclntsh.so

又碰到权限问题

[dbmon@mysql cx_Oracle-5.1.3]$ python setup.py install
running install
running build
running build_ext
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dbmon/instantclient_11_2/sdk/include -I/usr/local/python-2.7.14/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3
In file included from /home/dbmon/instantclient_11_2/sdk/include/oci.h:3045,
                 from cx_Oracle.c:10:
/home/dbmon/instantclient_11_2/sdk/include/ociap.h:10795: warning: function declaration isn’t a prototype
/home/dbmon/instantclient_11_2/sdk/include/ociap.h:10801: warning: function declaration isn’t a prototype
gcc -pthread -shared build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -L/home/dbmon/instantclient_11_2 -lclntsh -o build/lib.linux-x86_64-2.7-11g/cx_Oracle.so
running install_lib
copying build/lib.linux-x86_64-2.7-11g/cx_Oracle.so -> /usr/local/python-2.7.14/lib/python2.7/site-packages
error: [Errno 13] Permission denied: '/usr/local/python-2.7.14/lib/python2.7/site-packages/cx_Oracle.so'

赋权后重新执行

[root@mysql ~]# chown -R dbmon:dbmon /usr/local/python-2.7.14

OK!

[dbmon@mysql cx_Oracle-5.1.3]$ python setup.py install
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /usr/local/python-2.7.14/lib/python2.7/site-packages/cx_Oracle-5.1.3-py2.7.egg-info
Writing /usr/local/python-2.7.14/lib/python2.7/site-packages/cx_Oracle-5.1.3-py2.7.egg-info
[dbmon@mysql cx_Oracle-5.1.3]$ cd
[dbmon@mysql ~]$ python
Python 2.7.14 (default, Apr 28 2018, 11:18:44) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle

2.安装MYSQLdb

[root@mysql ~]# unzip MySQL-python-1.2.5.zip
[root@mysql MySQL-python-1.2.5]# python setup.py build

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 17, in 
    metadata, options = get_config()
  File "/root/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/root/MySQL-python-1.2.5/setup_posix.py", line 25, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

编辑mysql_config

[root@mysql MySQL-python-1.2.5]# vi site.cfg 
mysql_config = /u01/my3306/bin/mysql_config

build

[root@mysql MySQL-python-1.2.5]# python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
creating build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/u01/my3306/include -I/usr/local/python-2.7.14/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
In file included from _mysql.c:44:
/u01/my3306/include/my_config.h:441:1: warning: "HAVE_WCSCOLL" redefined
In file included from /usr/local/python-2.7.14/include/python2.7/Python.h:8,
                 from _mysql.c:29:
/usr/local/python-2.7.14/include/python2.7/pyconfig.h:919:1: warning: this is the location of the previous definition
gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/u01/my3306/lib -lmysqlclient -lpthread -lm -lrt -lssl -lcrypto -ldl -o build/lib.linux-x86_64-2.7/_mysql.so

install

[root@mysql MySQL-python-1.2.5]# python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/connections.py -> build/bdist.linux-x86_64/egg/MySQLdb
creating build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/ER.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FLAG.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CR.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/cursors.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/times.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/converters.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/release.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/_mysql_exceptions.py -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql.so -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
writing MySQL_python.egg-info/native_libs.txt
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.5-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing MySQL_python-1.2.5-py2.7-linux-x86_64.egg
Copying MySQL_python-1.2.5-py2.7-linux-x86_64.egg to /usr/local/python-2.7.14/lib/python2.7/site-packages
Adding MySQL-python 1.2.5 to easy-install.pth file

Installed /usr/local/python-2.7.14/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg
Processing dependencies for MySQL-python==1.2.5
Finished processing dependencies for MySQL-python==1.2.5

报错

[root@mysql MySQL-python-1.2.5]# python
Python 2.7.14 (default, Apr 28 2018, 11:18:44) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/usr/local/python-2.7.14/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /usr/local/python-2.7.14/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg/_mysql.pyc, but /root/MySQL-python-1.2.5 is being added to sys.path
Traceback (most recent call last):
  File "", line 1, in 
  File "MySQLdb/__init__.py", line 19, in 
    import _mysql
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in 
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

建立链接

[root@mysql check&alarm]# ln -s /u01/my3306/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
3. 安装paramiko

paramiko依赖于pycrypto模块

[root@mysql ~]# tar zxvf pycrypto-2.6.1.tar.gz
[root@mysql ~]# cd pycrypto-2.6.1
[root@mysql pycrypto-2.6.1]# python setup.py install
[root@mysql ~]# unzip paramiko-1.7.7.1.zip 
[root@mysql ~]# cd paramiko-1.7.7.1
[root@mysql paramiko-1.7.7.1]# python setup.py install




 
  

你可能感兴趣的:(DB_MONITOR环境部署)