首页 > 代码库 > CentOS 6.5 Zabbix-server安装

CentOS 6.5 Zabbix-server安装


CentOS 6.5 Zabbix-server安装


安装

配置前先关闭iptables和SELINUX,避免安装过程中报错

service iptables stop

3, 禁用SELINUX

# vi /etc/selinux/config

SELINUX=disabled

让SELINUX生效

#setenforce 0


4, 修改主机名

# vi /etc/sysconfig/network

HOSTNAME=hqzabbix


5, 修改配置文件

# vi /etc/hosts

10.117.180.37 hqzabbix

121.41.113.14 hqzabbix


6, yum安装


#rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm


yum install mysql -y

yum install mysql-server -y

yum install php-mysql -y

yum install php -y

yum install php-gd -y

yum install php-xmlwriter -y

yum install php-bcmath -y

yum install php-mbstring -y

yum install zabbix-server-mysql -y

yum install zabbix-agent -y

yum install zabbix-server -y

yum install zabbix-web-mysql -y


启动数据库

# /etc/init.d/mysqld start 或者使用service mysqld start启动。


创建用户

# mysql -u root 

mysql> create database hqzabbix character set utf8 collate utf8_bin;

mysql> grant all privileges on hqzabbix.* to hqzabbix@localhost identified by ‘hqzabbix‘;

mysql> \q


导入建表语句

# cd /usr/share/doc/zabbix-server-mysql-2.4.8/create

# chmod 775 * //设置权限

# mysql -uroot hqzabbix < schema.sql

# mysql -uroot hqzabbix < images.sql

# mysql -uroot hqzabbix < data.sql


设置mysql【root】密码


  # mysql -u root

  mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘hqzabbix‘);

mysql> \q

修改配置文件

# vi /etc/zabbix/zabbix_server.conf



DBHost=localhost

DBName=hqzabbix


DBUser=hqzabbix


DBPassword=hqzabbix


ListenIP=127.0.0.1


# vi /etc/php.ini

查找/; tab-width: 4

后面添加以下文件

php_value max_execution_time 300

php_value memory_limit 128M

php_value post_max_size 16M

php_value upload_max_filesize 2M

php_value max_input_fime 300


max_execution_time = 300

max_input_time = 300

post_max_size = 32M

memory_limit = 128M


修改以下文件

date.timezone = Asia/Shanghai


# vi /etc/httpd/conf/httpd.conf


ServerName 127.0.0.1:80


配置防火墙

# vi /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT

-A INPUT -m state –state NEW -m tcp -p tcp –dport 7900 -j ACCEPT

上面的只是一个示范,一定要在dport 22下面增加

/etc/init.d/iptables restart //最后重启防火墙使配置生效



当前时间

# yum install ntpdate -y


# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


# ntpdate us.pool.ntp.org


使用 date 查看

设置开机启动

chkconfig httpd on

chkconfig zabbix-server on

chkconfig zabbix-agent on

chkconfig mysqld on


新建文件夹

# mkdir /var/www/html/zabbix

上传 "zabbix-2.4.6.tar.gz" 文件到/usr/local/文件夹下

# cd /usr/local

# tar -zxvf zabbix-2.4.6.tar.gz

# cp -a  /usr/local/zabbix-2.4.6/frontends/php/* /var/www/html/zabbix/

# chown -R  apache.apache /var/www/html/zabbix/

启动服务

# /etc/init.d/zabbix-server start

# /etc/init.d/httpd start

重启

# reboot



打开网页

172.16.1.247/zabbix


看见启动后的界面点击 next ==> OK了点击next输入mysql用户名密码

database name hqzabbix

user hqzabbix

password hqzabbix

验证OK后再点击next==> next==> next==> Finish


默认账户密码 Admin/zabbix

汉化

登陆后点击右上角的Profile==> Language选择Chinese(zh_CN)Update



解决乱码

把windows下的simkai.ttf 上传到zabbix服务器。

windows字体路径C:\Windows\Fonts找到中文包(楷体 常规)复制到桌面

查找zabbix使用的语言包

find / -name *font* -print | grep zabbix

/usr/share/zabbix/fonts

把simkai.ttf上传到这个目录下

# vi /usr/share/zabbix/include/defines.inc.php

//define(‘ZBX_FONT_NAME‘, ‘DejaVuSans‘);

define(‘ZBX_FONT_NAME‘, ‘simkai‘);

//define(‘ZBX_GRAPH_FONT_NAME‘, ‘DejaVuSans‘);

define(‘ZBX_GRAPH_FONT_NAME‘,   ‘simkai‘);

搜索文件

find / -name  ‘graphfont‘

刷新网页还是乱码

# vi /etc/my.cnf

default-character-set = utf8

查看服务端口,没有80,nginx没有启动

netstat -ant -p


添加服务端口【如果有就不需要加了】

vim /etc/services

zabbix-agent 10050/tcp # Zabbix Agent

zabbix-agent 10050/udp # Zabbix Agent

zabbix-trapper 10051/tcp # Zabbix Trapper

zabbix-trapper 10051/udp # Zabbix Trapper

zabbix-agent 10161/udp # Zabbix Agent

zabbix-trapper 10161/tcp # Zabbix Trapper


看日志

vi /etc/zabbix/zabbix_server.conf

vi /var/log/zabbix/zabbix_server.log

vi /etc/httpd/conf/httpd.conf

vi /var/log/httpd/error_log

vi /etc/php.d/mysql.ini


查找

find / -name my.cnf


CentOS 6.5 Zabbix-server安装