Centos用的64位系统,网上找到的安装教程大都是建议通过yum来安装。过程如下:
1、yum安装rrdtool
yum install rrdtool rrdtool-devel
2、使用pip安装python-rrdtool模块
pip install rrdtool
Centos 6.4自带的python版本是2.6.6,可以通过上面方式安装python模块。但我将python升级到python2.7后就不行了。提示如下错误:
>>> import rrdtool
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python2.7/site-packages/rrdtoolmodule.so: undefined symbol: rrd_flushcached
解决方法:重新编译并安装rrdtool
1、下载rrdtool
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
2、编译并安装rrdtool
tar zxvf rrdtool-1.4.7.tar.gz
cd rrdtool-1.4.7
./configure --prefix=/usr/local
make
make install
3、使用pip安装python-rrdtool模块
yum install gcc cmake make python-devel cairo-devel libxml2 libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel -y
ln -s /usr/lib64/librrd.so.4 /usr/lib64/librrd.so
pip install python-rrdtool-1.4.7.tar.gz
pip install rrdtool
安装如果遇到找不到rrd.h头文件或者-lrrd库问题可以指定对应目录
C_INCLUDE_PATH=/usr/local/include LDFLAGS=-L/usr/local/lib pip install rrdtool
安装完后遇到新的问题
>>> import rrdtool
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: librrd.so.4: cannot open shared object file: No such file or directory
>>>
解决方法,将rrdtool库做软链接到usr/lib目录
ln -s /usr/local/lib/librrd* /usr/lib
ldconfig