oracle agstatus.py,安装Python基础模块

准备环境

首先安装Python环境(Python版本要求为Python2.6以上,不支持Python3)

安装数据库连接Python的驱动包

1.安装 MySQLdb for python (必须安装)

MySQLdb为Python连接和操作MySQL的类库,如果您准备使用lepus系统监控MySQL数据库,那么该模块必须安装。

安装步骤如下:

#wget http://cdn.lepus.cc/cdncache/software/MySQLdb-python.zip

# unzip MySQLdb-python.zip

# cd MySQLdb1-master/

# which mysql_config

/usr/local/mysql/bin/mysql_config

# vim site.cfg 修改如下:

mysql_config = /usr/local/mysql/bin/mysql_config

# python setup.py build

# python setup.py install

常见错误解决:

1).如果编译python出现如下问题

/usr/bin/ld: cannot find -lpython2.7

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

请按如下步骤处理:

A.检查并安装python-devel包

# yum -y install python-devel

B.将libpython2.7.so库文件建立软连接到/usr/lib下

32位服务器下执行

# ln -s /usr/local/Python2.7/lib/libpython2.7.so /usr/lib/libpython2.7.so

64位服务器下执行

# ln -s /usr/local/Python2.7/lib/libpython2.7.so /usr/lib64/libpython2.7.so

C.检查下/etc/ld.so.conf是否包含/usr/local/Python2.7/lib

#vi /etc/ld.so.conf 添加/usr/local/Python2.7/lib

#/sbin/ldconfig

2.安装cx_oracle for python (如果需要监控Oracle则必须安装)

下载安装oracle instant client

http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

如果是64位的,请选择.*x86_64.rpm,否则是.*i386.rpm

如果是oracle 9i或更高,请选择Instant Client 11,如果是8或8i,请选择Instant Client 10

[root@westserver software]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

Preparing… ########################################### [100%]

1:oracle-instantclient11.########################################### [100%]

[root@westserver software]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

Preparing… ########################################### [100%]

1:oracle-instantclient11.########################################### [100%]

[root@westserver software]# rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

Preparing… ########################################### [100%]

1:oracle-instantclient11.########################################### [100%]

[root@westserver home]# vim /root/.bash_profile

ORACLE_HOME="/usr/lib/oracle/11.2/client64"

PATH=$PATH:$ORACLE_HOME/bin

export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib

export LD_LIBRARY_PATH

修改完成后重新加载bash_profile文件

[root@westserver cx_Oracle-5.1.2]# source ~/.bash_profile

[root@westserver software]# vim /etc/ld.so.conf 加入

/usr/lib/oracle/11.2/client64/lib

执行ldconfig生效

[root@westserver software]# ldconfig

安装cx_oracle

# wget http://cdn.lepus.cc/cdncache/software/cx_Oracle-5.1.2.tar.gz

# tar zxvf cx_Oracle-5.1.2.tar.gz

# cd cx_Oracle-5.1.2

# python setup.py build

# python setup.py install

3.安装Pymongo for python (如果需要监控Mongodb则必须安装)

pymongo为Python连接和操作MongoDB的类库,如果您准备使用lepus系统监控MongoDBs数据库,那么该模块必须安装。

安装步骤如下:

# wget http://cdn.lepus.cc/cdncache/software/pymongo-2.7.tar.gz

# tar zxvf pymongo-2.7.tar.gz

# cd pymongo-2.7

# python setup.py install

4.安装Redis 驱动 (如果需要监控Redis则必须安装)

# wget http://cdn.lepus.cc/cdncache/software/redis-py-2.10.3.tar.gz

# tar zxvf redis-py-2.10.3.tar.gz

# cd redis-2.10.3/

# python setup.py install

5.安装SQLServer驱动 (如果需要监控SQLServer则必须安装)

安装pymssql需要的包:

freetds(http://www.filewatcher.com/m/freetds-0.82.tar.gz.1596755-0.html)

setuptools(https://pypi.python.org/pypi/setuptools)

pymssql(https://pypi.python.org/pypi/pymssql/)

安装步骤:

A. 安装freetds

#tar zxvf freetds-0.82.tar.gz

#cd freetds-0.82

#./configure –prefix=/usr/local/freetds –with-tdsver=8.0 –enable-msdblib –enable-dbmfix –with-gnu-ld –enable-shared –enable-static

#make && make install

#echo "/usr/local/freetds/lib" » /etc/ld.so.conf.d/freetds.conf

#ldconfig -v

B. 安装setuptools

#tar zxvf setuptools-3.5.1.tar.gz

#cd setuptools-3.5.1

# python setup.py install

C. 安装pymssql

#tar zxvf pymssql-2.1.0.tar.gz

#cd pymssql-2.1.0

#python setup.py install

注:如果不安装freetds,会报如下错误:

error: command ‘gcc’ failed with exit status 1

6.测试各个驱动是否正常运行(非必须)

在lepus的安装文件包python目录中,你可以找到如下测试文件,测试上述驱动是否安装正确。

# python test_driver_mysql.py

MySQL python drivier is ok!

# python test_driver_oracle.py

Oracle python drivier is ok!

# python test_driver_mongodb.py

MongoDB python drivier is ok!

# python test_driver_redis.py

Redis python drivier is ok!

原文链接:https://blog.csdn.net/weixin_35122994/article/details/116541368?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165918469516781790777876%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165918469516781790777876&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-27-116541368-null-null.nonecase&utm_term=%E9%A6%99%E6%B8%AFcdn

原创文章,作者:优速盾-小U,如若转载,请注明出处:https://www.cdnb.net/bbs/archives/2091

(0)
上一篇 2022年7月30日 21:30
下一篇 2022年7月30日 21:30

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

优速盾注册领取大礼包www.cdnb.net
/sitemap.xml