一、实验环境
主机名 | IP地址 |
---|---|
serverm.zabbix.com | 192.168.200.111 |
agent.zabbix.com | 192.168.200.112 |
二、配置主机名,hosts文件
三、安装依赖软件包,和lamp
yum -y install httpd mariadb mariadb-server php php-mbstring php-mysql php-bcmath php-gd php-xmlrpc php-ldap php-xml libevent libevent-devel net-snmp net-snmp-devel libxml2 libxml2-devel ntpdate
ntpdate s1a.time.edu.cn #同步清华大学时间
四、启动服务
systemctl restart mariadb
systemctl enable mariadb
systemctl restart httpd
systemctl enable httpd
mysqladmin -uroot password 123123
五、Java环境的搭建
ls
anaconda-ks.cfg jdk-8u191-linux-x64.tar.gz
tar xf jdk-8u191-linux-x64.tar.gz
ln -s /usr/local/java/bin/* /usr/bin/
java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
javac -version
javac 1.8.0_191
六、zabbix的搭建
ls
anaconda-ks.cfg jdk-8u191-linux-x64.tar.gz zabbix-3.4.11.tar.gz
tar xf zabbix-3.4.11.tar.gz -C /usr/src/
cd /usr/src/zabbix-3.4.11/
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-java
make && make install
七、数据路对zabbix的授权
mysql -uroot -p123123
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
grant all on zabbix.* to zabbix@192.168.200.111 identified by 'zabbix';
flush privileges;
exit
八、导入zabbix所需要的数据
mysql -uzabbix -p'zabbix' zabbix < /usr/src/zabbix-3.4.11/database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < /usr/src/zabbix-3.4.11/database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < /usr/src/zabbix-3.4.11/database/mysql/data.sql
#查看
mysql -uzabbix -pzabbix
use zabbix;
show tables;
九、zabbix的配置
useradd -M -s /sbin/nologin zabbix
cd /usr/local/
chown -R zabbix:zabbix zabbix/
cd zabbix/
#创建日志logs目录
mkdir logs
chown zabbix:zabbix logs
#备份配置文件
cd /usr/local/zabbix/etc/
cp zabbix_server.conf{,.bak}
cp zabbix_agentd.conf{,.bak}
#修改配置文件
vim zabbix_server.conf
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=192.168.200.111
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
vim zabbix_agentd.conf
Server=127.0.0.1,192.168.200.111
ServerActive=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
#添加软连接
ln -s /usr/local/zabbix/sbin/* /usr/local/bin/
#启动server端服务
zabbix_server
#启动agentd端服务
zabbix_agentd
#配置zabbix的web页面
mv /usr/src/zabbix-3.4.11/frontends/php/ /var/www/html/zabbix
chown -R apache:apache /var/www/html/zabbix/
#修改PHP配置,使其兼容zabbix
vim /etc/php.ini
384 max_execution_time = 300 #请求方式接受数据时间
394 max_input_time = 300 #程序上传文件解析数据时间
672 post_max_size = 32M #post方式请求数据所允许的最大大小
405 memory_limit = 128M #设置PHP的内存限制
878 date.timezone = Asia/Shanghai #时区
854 extension=bcmath.so #加载zabbix程序需要的扩展模块 手动添加
十、启动服务,查看
systemctl restart httpd
netstat -lnupt | egrep '10050|10051|80'
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 39761/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 39699/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 39761/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 39699/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 39779/httpd
十一、web安装
十一、修改语言
图形附近有乱码
cd /var/www/html/zabbix/fonts/
[root@zabbix fonts]# ls
DejaVuSans.ttf
#上传一种中文字体,并修改为DejaVuSans.ttf命名
ls
DejaVuSans.ttf simkai.ttf
mv simkai.ttf DejaVuSans.ttf
mv:是否覆盖"DejaVuSans.ttf"? y
[root@zabbix fonts]# ls
DejaVuSans.ttf
刷新web页面