安装mysql
1
2
3
4
5
6
7
8
9
10
11
|
wget https: //dev .mysql.com /get/mysql80-community-release-el7-2 .noarch.rpm rpm -ivh mysql80-community-release-el7-2.noarch.rpm vi /etc/yum .repos.d /mysql-community .repo [mysql56-community] enabled=1 [mysql80-community] enabled=0 yum install mysql-server |
安装lamp
1
|
yum install -y httpd php php-mysql php-gd libjpeg* php-xml php-xmlrpc php-mbstring php-bcmath php-mhash |
安装zabbix
安装详见:https://www.zabbix.com/download
安装yum源:
1
2
|
rpm -Uvh https: //repo .zabbix.com /zabbix/4 .0 /rhel/7/x86_64/zabbix-release-4 .0-1.el7.noarch.rpm yum clean all |
安装zabbix服务器:
1
|
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent |
创建数据库:
1
2
3
4
5
|
# mysql -uroot -p password mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password' ; mysql> quit; |
导入数据库:
1
|
zcat /usr/share/doc/zabbix-server-mysql * /create .sql.gz | mysql -uzabbix -p zabbix |
配置数据库密码:
1
2
|
vim /etc/zabbix/zabbix_server .conf DBPassword=password |
为Zabbix前端配置PHP:
1
2
|
vim /etc/httpd/conf .d /zabbix .conf php_value date .timezone Asia /Shanghai |
重启和开机自启动:
1
2
|
systemctl restart zabbix-server zabbix-agent httpd systemctl enable zabbix-server zabbix-agent httpd |
访问并安装前端:
1
|
http: //server_ip_or_name/zabbix |
安装好后初始用户名和密码为:Admin zabbix
安装agent
安装yum源:
1
|
rpm -Uvh https: //repo .zabbix.com /zabbix/4 .0 /rhel/7/x86_64/zabbix-release-4 .0-1.el7.noarch.rpm |
安装agent:
1
|
yum -y install zabbix-agent |
配置:
1
2
3
4
5
|
vim /etc/zabbix/zabbix_agentd .conf Hostname=nginx02 # 主机名 UnsafeUserParameters=1 # 启用脚本监控 Server=192.168.1.119 # server地址 ServerActive=192.168.1.119 # server地址 |
zabbix_get工具
安装在server端:
1
|
yum install zabbix-get -y |
使用:可以查看某主机是否可以被监控
1
|
zabbix_get -s 192.168.1.107 -k system. uname # -k 要被监控的key |
其他工具
查看可监控的key:在要被监控的机器上查看
1
|
zabbix_agentd -p |