背景:公司一台老机器,上面有个cacti。系统为centos5.X,有天手滑卸载了httpd,但yum源已经不支持centos5系列了,无奈百度上找了一个源内容以下:php
<span style="background-color: rgb(255, 102, 102);"><strong><span style="color:#ff6666;"># CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ baseurl=http://vault.centos.org/5.11/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ baseurl=http://vault.centos.org/5.11/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ baseurl=http://vault.centos.org/5.11/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ baseurl=http://vault.centos.org/5.11/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ baseurl=http://vault.centos.org/5.11/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5</span></strong></span>
装上后发现本来有中文支持的cacti图片所有不显示中文了,百度上找了一圈。全是说要么从新编译rrdtool,要么修改src/cacti/lib/function.php加入setlocale(LC_CTYPE,"zh_CN.UTF-8");之类的所有试遍了仍是乱码,最后google到一篇文章,参考其思路解决问题。https://www.iyunv.com/thread-366540-1-1.html html
检查cacti配置页面setting中path的RRDTool Default Font已选择字体文件;mysql
检查httpd/conf/httpd.conf中发现已有AddDefaultCharset GB2312,且cacti的grph栏中能够正常显示中文,编码格式肯定;sql
检查/etc/sysconfig/httpd文件中发现HTTPD_LANG行为注销状态,取消此行前面的#号,修改成HTTPD_LANG=zh_CN.gb2312。数据库
保存,重启httpd,刷新cacti页面,大功告成,流量图中已成功显示中文。bootstrap
p.s:centos
spine编译安装碰到的问题: bash
./configure --prefix=/usr/local/spine报错configure: error: C compiler cannot create executablesless
解决方法:sh bootstrap //所要支持的依赖包net-snmp-devel mysql-devel openssl-devel dos2unix autoconf automake binutils libtool gcc cpp glibc-headers kernel-headers glibc-develide
make && make install报错false // No help2man // --output=spine.1 --name='Data Collector for Cacti' --no-info --version-option='--version' ./spine
解决方法:安装help2man
后续:
将cacti0.8.7b升级至1.1.24过程当中遇到的问题
过程:
保存原cacti路径下的rra文件夹全部文件,拷贝至新cacti的rra下;
使用mysqldump保存数据库,还原至新数据库中;
遇到的问题为流量图及流量图页面左边的树均为乱码,最后查询数据库发现这些数据均从数据库中读取,在还原时已是乱码了。原来是旧数据库中使用的编码为latin1,新数据库使用编码为utf8,解决过程以下:
旧数据库使用mysqldump时加上--create-options=false参数:
备份时:mysqldump --default-character-set=latin1 --create-options=false --set-charset=false -uroot -p 数据库名称 > 数据库名称.sql
还原时:mysql -ucacti -p --default-character-set=gbk 数据库名称 < 数据库名称.sql
流量图不显示问题解决:用脚本将旧的rrd文件转换成xml格式,再使用脚本将xml格式还原为rrd文件放置在新cacti的rrd路径下,脚本使用rrdtool命令,详情见附件。