centos 7 安装 zabbix过程

来源:互联网 发布:linux vim 复制命令 编辑:程序博客网 时间:2024/06/01 08:59
zabbix server is not running:the infomation displayed may not be current
一、安装 CentOS 7

关闭selinux #setenforce 0 临时关闭

需要关闭 selinux,一定要关闭这个,开启selinux会引起一连串问题,甚至zabbix的discovery功能也不能正常使用
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
确认是否修改成功
# grep SELINUX /etc/selinux/config
然后重启系统即可
# reboot
关闭防火墙 

systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
安装YUM源:cd /etc/yum.repos.d/ 

wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

yum clean all

yum makecache


二、安装 LAMP
1、安装MySQL

从最新版本的linux系统开始,默认的是 Mariadb而不是mysql!
使用系统自带的repos安装很简单:
# yum install -y mariadb mariadb-server
启动mariadb
# systemctl start mariadb
之前的服务管理命令还可以用
# service mariadb start
设置开机自启动
# systemctl enable mariadb
安全初始化,设置root密码等
# mysql_secure_installation
测试登录
# mysql -uroot -p 123456 //密码123456 


安装zabbix
rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591
rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/ ... noarch.rpm



yum install epel-release



yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap wget ntpdate net-snmp*
yum -y install php
yum -y install php-mysql

yum install -y gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel


yum install -y nmap httpd policycoreutils-python net-snmp net-snmp-utils


# systemctl start httpd.service
# systemctl enable httpd.service
# systemctl status httpd.service //检查一下状态

“enabled”表示httpd服务已设为开机启动,“active(running)”则表示httpd服务正在运行中。



systemctl restart httpd 


yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get
yum -y install zabbix-agent

####grant all on zabbic.* to 'zabbix'@'localhost' identified by 'zabbix';
####flush privileges;

####grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
5.初始化数据库
mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; //密码是 zabbix

Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
进入到这个目录

#cd /usr/share/doc/zabbix-server-mysql-3.2.4
#ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
运行命令

# zcat create.sql.gz | mysql -uroot -p zabbix //密码zabbix 对应数据库中新建的 zabbix库

6.启动zabbix server服务

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
实际上我的配置文件修改的是DBHost和DBPassword去掉前面的#号。
启动zabbix服务,设置开机自启动

#systemctl start zabbix-server
#systemctl enable zabbix-server

7.编辑zabbix前端的PHP配合配置
/etc/php.ini
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_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai //主要去掉# 改成上海
调整时间同步:安装 ntpdate , yum -y install ntpdate 

#ntpdate cn.pool.ntp.org

8.修改乱码字体

Win+R打开运行,输入fonts,回车进入Windows字体目录,找到微软雅黑-常规字体,复制出来将文件名修改为msyh.ttf,然后上传到/usr/share/zabbix/fonts

上传成功以后,修改defines.inc.php的第45行,将graphfont改为msyh

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


将'graphfont' 修改为msyh
修改后 define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name

也可直接执行命令:

查看字体配置# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
93:define('ZBX_FONT_NAME', 'graphfont');
确认字体名称是否可以替换
# grep graphfont /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
93:define('ZBX_FONT_NAME', 'graphfont');
执行快捷替换
# sed -i "s/graphfont/msyh/g" /usr/share/zabbix/include/defines.inc.php
确认是否替换成功
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
45:define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name
93:define('ZBX_FONT_NAME', 'msyh');
原创粉丝点击