标签:zabbix
mariadb编译安装
1,现在源码包这里用的 mariadb-10.0.15.tar.gz 解压
下载地址 http://mirrors.neusoft.edu.cn/mariadb/mariadb-10.0.15/source/mariadb-10.0.15.tar.gz
[root@node144 src]# ls mariadb-10.0.15.tar.gz [root@node144 src]# tar xf mariadb-10.0.15.tar.gz [root@node144 src]# ls mariadb-10.0.15 mariadb-10.0.15.tar.gz
2,安装编译工具cmake gcc
[root@node144 mariadb-10.0.15]# yum -y install ncurses-devel gcc camke openssl-devel gcc-c++
查看编译选项和配置编译选项
[root@node144 mariadb-10.0.15]# ccmake .
编译
[root@node144 mariadb-10.0.15]# cmake .
如果编译缺少依赖的开发包,可看提示安装,然后删除CMakeCache.txt重新编译
# make && make install
make的界面挺漂亮的
3,添加mysql用户
[root@node144 mariadb-10.0.15]# useradd -r mysql
4,创建数据目录
[root@node144 mariadb-10.0.15]# mkdir -pv /data/mariadb
5,改权限
[root@node144 mariadb-10.0.15]# chown -R root.mysql /usr/local/mysql [root@node144 mariadb-10.0.15]# chown -R mysql.mysql /data/mariadb [root@node144 mariadb-10.0.15]# chmod -R 640 /data/mariadb [root@node144 mariadb-10.0.15]#
6,提供配置文件和启动脚本
[root@node144 mariadb-10.0.15]# cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf [root@node144 mariadb-10.0.15]# cp support-files/mysql.server /etc/init.d/mysqld [root@node144 mysql]# chmod +x /etc/init.d/mysqld [root@node144 mysql]# chkconfig --add mysqld [root@node144 mysql]# chkconfig mysqld on [root@node144 mysql]# chkconfig --list mysqld mysqld 0:off1:off2:on3:on4:on5:on6:off
7,初始化mysql
[root@node144 mysql]# cd /usr/local/mysql [root@node144 mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mariadb --skip-name-resolve --basedir=/usr/local/mysql [root@node144 mysql]# service mysqld start Starting MySQL. SUCCESS! [root@node144 data]# cat /etc/profile.d/mysql.sh export PATH=/usr/local/mysql/bin:$PATH [root@node144 data]#
php编译安装
1,下载源码包并解压
http://cn2.php.net/distributions/php-5.6.4.tar.bz2
[root@node144 src]# tar xf php-5.6.4.tar.bz2
安装编译依赖
[root@node144 php-5.6.4]#yum -y install gcc libcurl-devel bzip2-devel libxml2-devel mhash-devel libmcrypt-devel gd-devel bcmath-devel openssl-devel [root@node144 php-5.6.4]# ./configure --prefix=/usr/local/php --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-bz2 --with-curl --enable-bcmath --with-gd --with-gettext --with-mysql=mysqlnd --with-mysqli=mysqlnd [root@node144 php-5.6.4]# make && make install
2,为php提供配置文件
# cp php.ini-production /etc/php.ini
为php-fpm提供Sysv init脚本,并将其添加至服务列表:
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm # chmod +x /etc/rc.d/init.d/php-fpm # chkconfig --add php-fpm # chkconfig php-fpm on
为php-fpm提供配置文件:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
编辑php-fpm的配置文件:
# vim /usr/local/php/etc/php-fpm.conf
配置fpm的相关选项为你所需要的值,并启用pid文件(如下最后一行):
pm.max_children = 150 pm.start_servers = 8 pm.min_spare_servers = 5 pm.max_spare_servers = 10 pid = /usr/local/php/var/run/php-fpm.pid
接下来就可以启动php-fpm了:
# service php-fpm start
使用如下命令来验正(如果此命令输出有中几个php-fpm进程就说明启动成功了):
# ps aux | grep php-fpm
五、安装xcache,为php加速:
1、安装
# tar xf xcache-2.0.0.tar.gz # cd xcache-2.0.0 # /usr/local/php/bin/phpize # ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config # make && make install
安装结束时,会出现类似如下行:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
2、编辑php.ini,整合php和xcache:
首先将xcache提供的样例配置导入php.ini
# mkdir /usr/local/php/etc/php.d # cp xcache.ini /usr/local/php/etc/php.d
说明:xcache.ini文件在xcache的源码目录中。
接下来编辑/usr/local/php/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:
zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。
3、重新启动php-fpm
# service php-fpm restart
nginx编译安装
首先添加用户nginx,实现以之运行nginx服务进程
[root@node144 nginx-1.6.2]# groupadd -r nginx [root@node144 nginx-1.6.2]# useradd -r -g nginx nginx
1,下载源码包并解压
http://nginx.org/download/nginx-1.6.2.tar.gz
[root@node144 src]# ls mariadb-10.0.15 mariadb-10.0.15.tar.gz nginx-1.6.2 nginx-1.6.2.tar.gz [root@node144 src]# cd nginx-1.6.2 [root@node144 nginx-1.6.2]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
2,可用./configure --help 查看编译选项
[root@node144 nginx-1.6.2]# ./configure --help --help print this message --prefix=PATH set installation prefix --sbin-path=PATH set nginx binary pathname --conf-path=PATH set nginx.conf pathname --error-log-path=PATH set error log pathname --pid-path=PATH set nginx.pid pathname --lock-path=PATH set nginx.lock pathname
编译,根据提示安装devel包
[root@node144 nginx-1.6.2]# yum -y install pcre-devel [root@node144 nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre [root@node144 nginx-1.6.2]# make && make install
3、为nginx提供SysV init脚本:
新建文件/etc/rc.d/init.d/nginx,内容如下:
#!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() { # make required directories user=`nginx -V 2>&1 | grep "configure arguments:" | sed ‘s/[^*]*--user=\([^ ]*\).*/\1/g‘ -` options=`$nginx -V 2>&1 | grep ‘configure arguments:‘` for opt in $options; do if [ `echo $opt | grep ‘.*-temp-path‘` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac
而后为此脚本赋予执行权限:
# chmod +x /etc/rc.d/init.d/nginx
添加至服务管理列表,并让其开机自动启动:
# chkconfig --add nginx # chkconfig nginx on
而后就可以启动服务并测试了:
# service nginx start
四、整合nginx和php5
1、编辑/etc/nginx/nginx.conf,启用如下选项:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; }
2、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:
fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name;
并在所支持的主页面格式中添加php格式的主页,类似如下:
location / { root html; index index.php index.html index.htm; }
而后重新载入nginx的配置文件:
# service nginx reload
3、在/usr/html新建index.php的测试页面,测试php是否能正常工作:
# echo "<?php phpinfo(); ?>" > index.php
编译安装zabbix
下载地址:http://www.zabbix.com/download.php
# tar -zxvf zabbix-2.4.3.tar.gz
创建用户:
# groupadd zabbix # useradd -g zabbix zabbix
注意:同时安装了server和agent的节点上,建议其运行用户不要相同。
创建数据库:
server和proxy的运行都依赖于数据库,agent则不需要。
以MySQL数据库为例:
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin; mysql> GRANT ALL ON zabbix.* TO zbuser@‘%‘ IDENTIFIED BY ‘zbpass‘;
# 请按需要修改用户名和密码;
shell> mysql -u<username> -p<password> zabbix < database/mysql/schema.sql
# 如果仅为proxy创建数据库,只导入schema.sql即可;否则,请继续下面的步骤;
shell> mysql -u<username> -p<password> zabbix < database/mysql/images.sql shell> mysql -u<username> -p<password> zabbix < database/mysql/data.sql
编译安装zabbix:
同时安装server和agent,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-ssh2
如果仅安装server,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --enable-server --with-mysql --with-net-snmp --with-libcurl
如果仅安装proxy,并支持将数据放入mysql数据中,可使用类似如下配置命令:
./configure --prefix=/usr --enable-proxy --with-net-snmp --with-mysql --with-ssh2
如果仅安装agent,可使用类似如下配置命令:
./configure --enable-agent
而后编译安装zabbix即可:
# make # make install
复制zabbix前端页面
[root@node147 tmp]# cp -a /usr/local/src/zabbix-2.4.3/frontends/php /usr/loca/nginx/html/zabbix
复制windows下的字体,不然显示不了中文
控制面板-->字体 复制简体中文到下面的目录,并改名
[root@node147 fonts]# cd /usr/local/nginx/html/zabbix/fonts [root@node147 fonts]# ls DejaVuSans.ttf simkai.ttf [root@node147 fonts]# mv DejaVuSans.ttf DejaVuSans.ttf.bak [root@node147 fonts]# mv simkai.ttf DejaVuSans.ttf [root@node147 fonts]# vim /etc/default/locale # File generated by update-locale LANG=zh_CN.UTF-8
安装中文包
修改zabbix配置文件
root@node144 src]# vim /usr/local/zabbix/etc/zabbix_server.conf DBHost=127.0.0.1 #连接数据库的主机 DBName=zabbix DBUser=zabbix DBPassword=redhat AlertScriptsPath=${datadir}/zabbix/alertscripts #报警脚本的路径,有时候脚本不能报警可修改 ExternalScripts=${datadir}/zabbix/externalscripts
现在的版本可以看到哪个进程是干嘛用的
[root@node147 fonts]# ps -ef|grep zabbix_ser zabbix 37952 1 0 22:20 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server zabbix 38142 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] zabbix 38143 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: db watchdog [synced alerts config in 0.001925 sec, idle 60 sec] zabbix 38144 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #1 [got 231 values in 2.610004 sec, getting values] zabbix 38145 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #2 [got 22 values in 0.563195 sec, idle 1 sec] zabbix 38147 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #3 [got 45 values in 0.396681 sec, idle 1 sec] zabbix 38149 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #4 [got 98 values in 2.439877 sec, getting values] zabbix 38151 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #5 [got 70 values in 0.446605 sec, idle 1 sec] zabbix 38153 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000020 sec, getting values] zabbix 38155 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] zabbix 38157 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] zabbix 38159 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] zabbix 38161 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000287 sec, waiting for connection] zabbix 38163 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection] zabbix 38164 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000003 sec, idle 5 sec] zabbix 38166 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.000975 sec, idle 30 sec] zabbix 38167 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 38169 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: timer #1 [processed 207 triggers, 207 events in 0.149997 sec, 0 maintenances in 0.000000 sec, idle 30 sec] zabbix 38170 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: http poller #1 [got 0 values in 0.000000 sec, getting values] zabbix 38172 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000848 sec, idle 60 sec] zabbix 38174 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #1 [synced 721 items in 0.184371 sec, idle 5 sec] zabbix 38176 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000915 sec, idle 5 sec] zabbix 38178 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000649 sec, idle 5 sec] zabbix 38180 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000448 sec, idle 5 sec] zabbix 38182 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: escalator [processed 0 escalations in 0.000055 sec, idle 3 sec] zabbix 38184 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000043 sec, idle 5 sec] zabbix 38186 37952 0 22:21 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: self-monitoring [processed data in 0.000002 sec, idle 1 sec]
启动不了记得看日志
都ok了才能下一步
连接数据库的配置
本文出自 “小雨” 博客,请务必保留此出处http://evildexy.blog.51cto.com/8607019/1605183
标签:zabbix
原文地址:http://evildexy.blog.51cto.com/8607019/1605183