作为初学者,要想取得进步,成为高手,首先应该了解自己的不足之处.
全部博文(117)
分类: 系统运维
2011-08-09 20:44:01
1 Nginx
Nginx编译安装
问题
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by
using --with-pcre=
解决办法
# yum install pcre-devel
修改nginx.conf配置文件
location ~ \.php$ {
root /usr/local/cacti/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
location ~* ^.+\.(css|js|ico|gif|jpg|jpeg|png|html|htm)$ {
root /usr/local/cacti/;
index index.html index.htm;
}
nginx启动
./nginx
其他参数命令参考
nginx -hnginx version: nginx/0.8.54
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /home/q/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
2 MySQL已经安装好,具体情况,查看相关的MySQL安装文档
安装目录/home/q/mysql
3 PHPphp5.3版本,内置了fpm功能模块
下载
wget
解压,编译
tar zxvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --prefix=/usr/local/php --enable-sockets --enable-fpm --with-mysql=/home/q/mysql
make
make install
复制一个php.ini文件
cp ../php-5.3.6/php.ini-production /usr/local/php/lib/
添加时区的参数,设置cacti的时候会用到
date.timezone = "Asia/Chongqing"
修改/usr/local/php/etc/php-fpm.conf配置文件,将以下参数取消注释
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
启动php-fpm服务(端口9000)
/usr/local/php/sbin/php-fpm
[可选]验证php的功能,编写一个php的测试页面,内容如下
phpinfo();
?>
4 Cacti 4.1 rrdtool,snmp安装rrdtool,这个工具是用来绘图的,先下载一个yum源
wget
yum install rrdtool
# vim /etc/snmp/snmpd.conf ,注意修改团体名
4.2 cacti
先yum需要的组件包
yum install net-snmp-devel net-snmp-utils openssl-devel
wget
tar zxvf cacti-0.8.7g.tar.gz
cd cacti-0.8.7g
下载并安装补丁
wget
wget
wget
wget
wget
wget
wget
patch -p1 -N < data_source_deactivate.patch
patch -p1 -N < graph_list_view.patch
patch -p1 -N < html_output.patch
patch -p1 -N < ldap_group_authenication.patch
patch -p1 -N < script_server_command_line_parse.patch
patch -p1 -N < ping.patch
patch -p1 -N < poller_interval.patch
移动目录
mv /opt/cacti-0.8.7g /var/www/cacti
4.3 spine
wget
tar zxvf cacti-spine-0.8.7g.tar.gz
cd cacti-spine-0.8.7g
下载并安装补丁
wget
patch -p1 -N < unified_issues.patch
编译
./configure --with-mysql=/home/q/mysql
make
make install
测试
修改连接MySQL的配置文件/usr/local/spine/etc/spine.conf
启动命令/usr/local/spine/bin/spine
4.4 导入数据mysql> create database cacti;
mysql> grant all privileges on cacti.* to 'cacti'@'localhost' identified by 'password***';
mysql> use cacti;
mysql> source cacti.sql
mysql> flush privileges;
mysql> exit
4.5 配置文件
vim /usr/local/cacti/include/config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = " password***";
$database_port = "3306";
定制任务,以root用户,每五分钟收集一次信息
crontab –e
*/5 * * * * /usr/local/php/bin/php /home/q/www/cacti/poller.php >/dev/null 2>&1
4.6 cacti初始化
url地址
点击Next
下个页面的各个工具路径,需要根据具体的安装路径指定.
......
4.7 spine的设置
Setting----paths----“Spine Poller File Path”|选中”Structured RRA Path (/host_id/local_data_id.rrd)”
4.8 导入模板,添加帐号导出l-dbmonitor.ops.cn1的cacti模板(包括* Linux Generic和X MySQL Server HT)
在l-dbmonitor.ops.cn2中导入(连接MySQL的密码也会包含在内)
检测脚本ss_get_mysql_stats.php,也要用cn1的,这个添加了MySQL多端口监控的支持
在各个MySQL服务器创建监控帐号
mysql -uroot -p' password***' -e "GRANT PROCESS, SUPER ON *.* TO 'monitor'@'192.168.0.1' IDENTIFIED BY ' password***';FLUSH PRIVILEGES;"
参考
Linux主机模板(可选)
wget
MySQL模板
better-cacti-templates-1.1.8.tar.gz
5 FAQ./spine: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@l-dbmonitor bin]# find / -name libmysqlclient.so.18
/home/q/mysql-5.5.14/libmysql/libmysqlclient.so.18
/home/q/mysql/lib/libmysqlclient.so.18
[root@l-dbmonitor bin]# ln -s /home/q/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/home/q/mysql/data/mysql.sock' (2)'
修改了mysql的
socket = /home/q/mysql/data/mysql.sock
如果MySQL是5.5,需要将cacti.sql中的TYPE=MyISAM,改成ENGINE=MyISAM
有一个补丁文件cacti.sql-MySQL-5.5.9.patch,可以改cacti.sql文件
configure: error: xml2-config not found. Please check your libxml2 installation.
解决
yum install libxml2 libxml2-devel
资源
cacti模板