CentOS7 企业级分布式监控系统Zabbix(01)
本次以CentOS 7.2 x64系统为例系统环境
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# uname -r
3.10.0-327.el7.x86_64
# uname -m
x86_64
# hostname
centos72-node1.wangdong.com
# ifconfig | grep -w "inet" | awk '{print $2}'
192.168.56.51
127.0.0.1
设置yum源和epel源为阿里
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
......
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
......
安装Apache
# yum install httpd -y
......
启动Apache
# systemctl start httpd
设置开机启动
# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
设置防火墙策略(若不启用防火墙,此步骤跳过)
# firewall-cmd --permanent --add-service=http
success
# systemctl restart firewalld
测试Apache(Apache默认使用TCP/80端口,确保没有其他程序占用此端口)
http://s4.运维网.com/wyfs02/M02/8A/97/wKioL1g1DQTQfQxXAAUAlG4Cgok636.jpg
安装MariaDB(即MySQL)
# yum install mariadb-server mariadb -y
......
启动MariaDB
# systemctl start mariadb
设置开机启动
# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
初始化MariaDB
# mysql_secure_installation
......
Enter current password for root (enter for none): # 输入MySQL的root原密码,密码为空,直接回车
......
Set root password? Y # 是否设置root密码,是
New password: # 输入新密码,我设置123456
Re-enter new password: # 输入新密码,我设置123456
......
Remove anonymous users? Y
......
Disallow root login remotely? n
......
Remove test database and access to it? Y
......
Reload privilege tables now? Y
......
安装PHP
# yum install php php-mysql php-gd php-pear -y
......
测试PHP
# vim /var/www/html/testphp.php # 创建php测试文件,将下面3行内容写入文件保存
# systemctl restart httpd
使用浏览器访问服务器地址的/testphp.php
http://s2.运维网.com/wyfs02/M02/8A/9B/wKiom1g1DRbjtQXXAALpV6kLPRU340.png
配置zabbix源
# yum install epel-release -y
......
# rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
# rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
Preparing packages...
zabbix-release-2.4-1.el7.noarch
安装zabbix和相关
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway -y
......
设置zabbix
# vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
Options FollowSymLinks
AllowOverride None
Require all granted
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 date.timezone Asia/Shanghai # 设置时区为上海
# php_value date.timezone Europe/Riga
Require all denied
Require all denied
# systemctl restart httpd
MariaDB创建zabbix库
# mysql -u root -p123456
......
MariaDB [(none)]> create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;
Bye
#
MariaDB导入zabbix模板
# mysql -u zabbix -pzabbix
......
MariaDB [(none)]> use zabbix;
Database changed
MariaDB > source /usr/share/doc/zabbix-server-mysql-2.4.7/create/schema.sql
......
MariaDB > source /usr/share/doc/zabbix-server-mysql-2.4.7/create/images.sql
......
MariaDB > source /usr/share/doc/zabbix-server-mysql-2.4.7/create/data.sql
......
MariaDB > exit;
Bye
配置zabbix server
# vim /etc/zabbix/zabbix_server.conf
......
DBName=zabbix
......
DBUser=zabbix
......
DBPassword=zabbix
......
配置zabbix agent
# vim /etc/zabbix/zabbix_agentd.conf
......
Server=127.0.0.1 # 约在85行
......
ServerActive=127.0.0.1 # 约在126行
......
Hostname=127.0.0.1 # 约在137行
......
修改PHP配置
# vim /etc/php.ini
......
max_execution_time = 600 # 约384行
......
max_input_time = 600 # 约394行
......
memory_limit = 256 # 约405行
......
post_max_size = 32M # 约672行
......
upload_max_filesize = 16M # 约800行
......
......
date.timezone = Asia/Shanghai # 此项默认没有配置,需要添加,约880行
......
修改防火墙配置(若没有开启防火墙,则忽略)
# firewall-cmd --permanent --add-port=10050/tcp
success
# firewall-cmd --permanent --add-port=10051/tcp
success
# systemctl restart firewalld
重启服务
# systemctl start zabbix-server
# systemctl start zabbix-agent
# systemctl restart httpd
# systemctl restart mariadb
# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
配置zabbix,访问服务器地址的/zabbix/
点击“Next”按钮
http://s2.运维网.com/wyfs02/M02/8A/97/wKioL1g1DSjTfebKAAF1YTFq_yo409.jpg
检查各种测试,应全部显示OK,点击“Next”
http://s2.运维网.com/wyfs02/M00/8A/97/wKioL1g1DT7hNLB5AAHwWnJ0kfI205.jpg
选择数据库类型为MySQL,库名为zabbix,用户名zabbix,密码我使用的zabbix,点击“Test connection”,显示OK后点击“Next”
http://s3.运维网.com/wyfs02/M01/8A/9B/wKiom1g1DV3CJ7_TAAHbWEhrsZE593.jpg
输入Server Name(可选)
http://s4.运维网.com/wyfs02/M00/8A/97/wKioL1g1DXKweeQ-AAGSqq4BsGU183.jpg
检查信息是否有误,点击“Next”按钮
http://s5.运维网.com/wyfs02/M01/8A/97/wKioL1g1DYaRfnFVAAHT4PmWWLY083.jpg
配置完成,点击“Finish”按钮
http://s1.运维网.com/wyfs02/M02/8A/9B/wKiom1g1DZahDDK4AAGY3KFQkcw838.jpg
进入Zabbix的管理界面,默认用户名为admin,默认密码为zabbix
http://s1.运维网.com/wyfs02/M02/8A/97/wKioL1g1DarjtMcmAAFMgfdkyfY970.jpg
进入界面后,如果想要使用中文,可以点击进入Profile
http://s1.运维网.com/wyfs02/M00/8A/9B/wKiom1g1DcjRJogKAAMBSmhRx-c666.pnghttp://s2.运维网.com/wyfs02/M00/8A/97/wKioL1g1DdzwzuWqAAHMx8yCMnA518.png
页:
[1]