背景:公司一臺老機器,上面有個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命令,詳情見附件。