Centos6.5 安装 zabbix3.2-server

Kai zabbix 182 次浏览 没有评论
环境:两台Centos6.5
server ip:172.16.12.203
agent:172.16.12.213 
关闭selinux
修改/etc/selinux/config 文件
[root@localhost ~] vi /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
把名字改成zabbix-server
修改network的HOSTNAME项为zabbix-server。点前面是主机名,点后面是域名。没有点就是主机名。
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=zabbix-server
[root@localhost ~]# vi /etc/hosts
127.0.0.1  localhost.localdomain    #修改localhost.localdomain为zabbix-server
安装mysql
 zabbix需要mysql5.6以上版本,删除旧的版本
[root@zabbix-server /]# rpm -qa mysql*
下载MySQL5.6版本
[root@zabbix-server /]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[root@zabbix-server /]# yum -y install mysql-server
[root@zabbix-server /]# yum list installed | grep mysql
[root@zabbix-server ~]# yum list installed | grep mysql
mysql-community-client.x86_64
5.6.35-2.el6 @mysql56-community
mysql-community-common.x86_64
5.6.35-2.el6 @mysql56-community
mysql-community-libs.x86_64
5.6.35-2.el6 @mysql56-community
mysql-community-libs-compat.x86_64
5.6.35-2.el6 @mysql56-community
mysql-community-release.noarch
mysql-community-server.x86_64
5.6.35-2.el6 @mysql56-community
修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1
[root@zabbix-server/]# vi /etc/my.cnf
innodb_file_per_table=1
[root@zabbix-server/]# /etc/init.d/mysqld start  启动
[root@zabbix-server/]# mysql_secure_installation 先初始化.密码设置为123456
[root@zabbix-server/]# mysql -uroot -p   登陆
[root@zabbix-server/]# 新建zabbix数据库,格式为utf8
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on zabbix.* to ‘zabbix’@’localhost’ identified by ‘zabbix’;
mysql> show databases;    看看有没有新建成功zabbix
拓展:

//授权phplamp用户拥有phplamp数据库的所有权限。

>grant all privileges on phplampDB.* to phplamp@localhost identified by ‘1234’;

//刷新系统权限表

mysql>flush privileges;

@>mysql -u root -p

@>密码

mysql>update mysql.user set password=password(‘新密码’) where User=”phplamp” and Host=”localhost”;

mysql>flush privileges;

mysql> exit;
安装PHP
先安装webtatic的yum源
[root@zabbix-server ~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
 安装依赖包
[root@zabbix-server ~]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
 修改php配置
[root@zabbix-server ~]# vi /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1
修改apache配置
[root@zabbix-server ~]# vi /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php
启动apache
[root@zabbix-server /]# /etc/init.d/httpd start
在iptables上开放80端口
[root@zabbix-server /]# iptables -I INPUT -p tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT
[root@zabbix-server /]# /etc/init.d/iptables save
[root@zabbix-server /]# cat /etc/sysconfig/iptables  如果有下面的就说明添加成功了
-A INPUT -p tcp -m tcp –dport 80 -m state –state NEW,ESTABLISHED -j ACCEPT
 创建zabbix用户
[root@zabbix-server /]# groupadd zabbix
[root@zabbix-server /]# useradd -g zabbix zabbix
 依赖包安装
[root@localhost mysql]# yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
安装zabbix
[root@zabbix-server ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
查找下yum里面有没有zabbix列表
[root@zabbix-server ~]# yum list all|grep zabbix
[root@zabbix-server ~]# yum install -y zabbix-web-mysql.noarch zabbix-server-mysql.x86_64 zabbix-agent.x86_64
启动zabbix和agent
[root@zabbix-server ~]# /etc/init.d/zabbix-server start
[root@zabbix-server ~]# /etc/init.d/zabbix-agent start
修改zabbix_server的配置
[root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
进入zabbix数据库脚本目录,将库数据导入zabbix数据库中.
[root@zabbix-server ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.6/
[root@zabbix-server ~]# zcat create.sql.gz | mysql -uroot -p123456 zabbix
可以查看有没有导入成功.
[root@zabbix-server ~]# mysql -uroot -p123456
[root@zabbix-server ~]# show databases;
[root@zabbix-server ~]# use zabbix;
[root@zabbix-server ~]# show tables;
设置为开机启动
[root@zabbix-server ~]# chkconfig –add zabbix-server
[root@zabbix-server ~]# chkconfig –add zabbix-agent
[root@zabbix-server ~]# chkconfig zabbix-server on
[root@zabbix-server ~]# chkconfig zabbix-agent on
zabbix的前端目录
[root@zabbix-server ~]# find / -name “setup.php”   查找前段安装文件
把/usr/share/zabbix/复制到/var/www/html
[root@zabbix-server zabbix]# cp -r /usr/share/zabbix/ /var/www/html
设置Apache作为Web用户接口文件的所有者
[root@zabbix-server zabbix]# chown -R apache:apache /var/www/html/zabbix
 添加权限给Zabbix Web界面执行文件
[root@zabbix-server zabbix]# chmod +x /var/www/html/zabbix/conf/
 添加Zabbix服务器和Zabbix代理服务
[root@zabbix-server ~]# chkconfig –add zabbix-server
[root@zabbix-server ~]# chkconfig –add zabbix-agentd
[root@zabbix-server ~]# chkconfig httpd on
[root@zabbix-server ~]# chkconfig mysqldcd on
[root@zabbix-server ~]# chkconfig zabbix-server on
[root@zabbix-server ~]# chkconfig zabbix-agentd on
这些都做完以后登录web: http://172.16.12.212/zabbix/setup.php
默认账号是Admin 密码 zabbix
最后一步改字体,解决图像乱码
下载字体文件,并上传到字体文件目录/usr/share/zabbix/fonts
[root@zabbix-server ~]# wget http://down1.chinaunix.net/distfiles/ttf-arphic-uming_0.0.20050501-1.tar.gz
[root@zabbix-server ~]# tar -zxvf ttf-arphic-uming_0.0.20050501-1.tar.gz
[root@zabbix-server ~]# cd ttf-arphic-uming-0.0.20050501/
[root@zabbix-server ttf-arphic-uming-0.0.20050501]# cp uming.ttf /var/www/html/zabbix/fonts/
[root@zabbix-server ~]# vi /var/www/html/zabbix/nclude/defines.inc.php   (3.2的版本/var/www/html/zabbix/include)
将:define(‘ZBX_FONT_NAME’, ‘DejaVuSans’); 替换成:define(‘ZBX_FONT_NAME’, ‘uming’);
将define(‘ZBX_GRAPH_FONT_NAME’, ‘DejaVuSans’); 替换成:define(‘ZBX_GRAPH_FONT_NAME’, ‘uming’);
先改成中文
然后在配置-主机把监控本机打开点更新
然后就能看到agent传过来的数据
 如果报错
vi /etc/zabbix/web/zabbix.conf.php
$DB[‘SERVER’] = ‘localhost’;
改成服务器IP地址
然后重启服务

发表评论

Go