yum安装zabbix3.0

2016-08-09  本文已影响2821人  撸大师

前言:先谈谈zabbix的优劣,以及为啥要选择zabbix来搭建我们的监控平台;

  • Zabbix优势:
    1 支持分布式监控
    2 自带绘图功能,获取到数值型的数据,可自动生成图
    3 Web配置方式,操作易用性较好。添加监控项或机器时速度很快。
    4 有报警时无论在任何界面会弹出小窗口报警,同时有报警的声音提示,同时可对监控项的快速查看。
    5 自带内置函数较为丰富,同时也支持脚本及nagios等脚本的调用。
    6 出现问题时,可自动远程执行命令(需对agent设置执行权限)

一、安装

1.卸载相关软件包,保持干净环境

yum remove -y mysql* httpd* php* nginx* zabbix*

2.安装依赖包

yum -y install wget gcc automake autoconf libtool make cmake bzip2 zlib-devel tree \
pam-devel vim-enhanced man ntpdate unzip telnet python perl perl-devel gcc-c++ zcat \
redhat-lsb tcpdump sysstat lsof git nfs-utils expect traceroute htop lrzsz pymysql\
MySQL-python  libffi-devel libxml2 libxml2-devel libxslt-devel readline-devel \
libffi  epel-release openssl-devel python-devel 

rpm -ivh http://repo.webtatic.com/yum/el6/x86_64/libmysqlclient16-5.1.69-1.w6.x86_64.rpm

3.安装 数据库

数据库可以选择mariadb和mysql,下面是两种数据库的安装方式

rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
vi /etc/yum.repos.d/mysql-community.repo
yum repolist enabled | grep mysql
yum install -y mysql-community-server
vi /etc/yum.repos.d/MariaDB.repo
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/10.0/centos6-amd64 
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1
yum -y install MariaDB-client MariaDB-server MariaDB-devel

安装mysql报错auto-extending data file ./ibdata1 is of a different size 640 pages
解决

cd /var/lib/mysql
> rm -rf ib*
root@sh-salt-01 mysql
> /etc/init.d/mysqld start
Starting mysqld:                                           [  OK  ]

4.配置 数据库

/etc/init.d/mysql start
mysql -e "grant all on *.* to 'root'@'localhost' identified by '123';"
mysql -uroot -p123 -e "create database zabbix character set utf8;"
mysql -uroot -p123 -e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';"

报错ERROR 1054 (42S22) at line 1: Unknown column 'plugin' in 'mysql.user'
原因:原来这个机器上之前装了5.1的mysql,它的user表只要39列,而5.6的有4.2列,用下面的命令进行修复表,参考
解决mysql_upgrade --force -p123

Warning: Using a password on the command line interface can be insecure.
原因:这个是提示使用 -p123,这种直接跟密码的命令不安全,实验环境不予理会

5.安装 php

rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
yum install -y http php55w php55w-soap php55w-bcmath php55w-cli php55w-fpm \
php55w-common php55w-devel  php55w-gd php55w-imap php55w-mysql php55w-odbc \
php55w-ldap php55w-mbstring php55w-mcrypt  php55w-xml php55w-intl php55w-pdo\
 php55w-pear php55w-pecl-igbinary php55w-xmlrpc php55w-opcache php55w-pecl-memcache

6.配置 php

post_max_size=16M
max_execution_time=300
max_input_time=300
date.timezone=Asia/Shanghai
always_populate_raw_post_data=-1
sed -i "s/post_max_size.*/post_max_size=16M/" /etc/php.ini 
sed -i "s/max_execution_time.*/max_execution_time=300/" /etc/php.ini 
sed -i "s/max_input_time.*/max_input_time=300/" /etc/php.ini 
sed -i "s#;date.timezone.*#date.timezone=Asia/Shanghai#" /etc/php.ini
[global]
log_level = debug
[www]
;listen = /tmp/php-cgi.sock
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /data/log/php-fpm/php_slow.log

7.安装 zabbix

groupadd zabbix
useradd -g zabbix zabbix
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent \
zabbix-java-gateway zabbix-proxy-mysql zabbix-sender

8.配置 zabbix

zcat /usr/share/doc/zabbix-server-mysql-3.0.4/create.sql.gz |mysql -uzabbix -pzabbix zabbix
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
# sed -i "s/# DBHost/DBHost/g" zabbix_server.conf
# sed -i "s/# DBPassword=/DBPassword=zabbix/g" zabbix_server.conf
chown www.www -R  /etc/zabbix/
cp -r /usr/share/zabbix/ /data/www/

9.安装nginx

yum install -y nginx

10.启动并访问

/etc/init.d/nginx start
/etc/init.d/php-fpm start
/etc/init.d/zabbix-server start

看到如下界面即安装成功

Paste_Image.png
for i  in `chkconfig --list|grep "3:on"|awk '{print $1}'|grep -vE "crond|sshd|network|rsyslog|sysstat|zabbix-server|zabbix-agent"`;do chkconfig $i off;done

参考1:CentOS 6安装Zabbix 3.0 Beta
参考2:Zabbix 3.0 安装笔记

上一篇下一篇

猜你喜欢

热点阅读