LAMP环境部署
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
运维之道 | Centos7源码安装配置Apache
[root@localhost ~]# yum remove -y mariadb
[root@localhost ~]# rm -rf /etc/my.cnf
[root@localhost ~]# rm -rf /var/lib/mysql
[root@localhost ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# mv mysql-5.6.39-linux-glibc2.12-x86_64/* /usr/local/mysql/
[root@localhost mysql]# systemctl start mysqld
[root@localhost mysql]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
运维之道 | Centos7安装mysql5.6
[root@localhost ~]# yum install -y php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
[root@localhost html]# php -v
PHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
OneinStack自动部署PHP
以上四步骤或者直接选择通过 OneinStack 进行LNMP环境自动部署
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
ServerName www.zwl.com //修改为主机名,或映射域名
DirectoryIndex index.html index.php //新增index.php
[root@localhost ~]# vi /etc/hosts
192.168.146.129 www.zwl.com
[root@localhost ~]# vi /etc/php.ini
date.timezone = PRC //修改为中国时区
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start httpd.service //启动httpd服务
[root@localhost ~]# systemctl start mysql.service //启动mysql服务
注释:mariadb数据库需要初始化数据库,mysql已自动初始化
[root@localhost ~]# mysql_secure_installation //初始化mysql数据库,并配置root用户密码
[root@localhost ~]# vi /var/www/html/index.php //创建一个测试页,测试LAMP是否搭建成功
<?php
phpinfo();
?>
[root@localhost ~]# mysql -u root -p //root用户登陆数据库
mysql> CREATE DATABASE zabbix character set utf8 collate utf8_bin; //创建zabbix数据库(中文编码格式)
mysql> GRANT all ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY '123456'; //授予zabbix用户zabbix数据库的所有权限,密码123456
mysql> flush privileges; //刷新权限
mysql> quit //退出数据库
[root@localhost ~]# vi /var/www/html/index.php
<?php
$link=mysql_connect('192.168.146.129','zabbix','123456');
if($link) echo "Success!!
";
else echo "Fail!!";
mysql_close();
?>
Zabbix监控服务搭建
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
[root@localhost ~]# yum update ///可选择进行更新
[root@localhost ~]# yum -y install yum-utils
[root@localhost ~]# yum-config-manager --enable rhel-7-server-optional-rpms
[root@localhost ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
PS:如果安装提示没有可用的镜像,可以一直执行这个命令,发现进度条会进一步安装
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | /usr/local/mysql/bin/mysql -uzabbix -p -h 192.168.146.129 zabbix
以上为导入数据到数据库zabbix中(最后一个zabbix是数据库zabbix),且因为用户zabbix是%(任意主机),所以登录时需要加上当前主机ip(-h 192.168.146.129),密码是用户zabbix登陆密码123456
[root@localhost ~]# vi/etc/zabbix/zabbix_server.conf
DBPassword=123456
编辑文件/etc/httpd/conf.d/zabbix.conf,取消注释并为您设置正确的时区
[root@localhost ~]# vi/etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/shanghai
启动Zabbix服务器和代理进程,并设置开机自启
[root@localhost ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@localhost ~]# systemctl enable zabbix-server zabbix-agent httpd
Zabbix监控服务部署
Zabbix监控平台配置
设置中文环境:Administrator-Users-点击用户Admin-语言中设置:
/usr/share/zabbix/assets/fonts/
目录[root@localhost fonts]# rz
rz waiting to receive.
Starting zmodem transfer. Press Ctrl+C to cancel.
Transferring stxingka.ttf...
100% 3922 KB 3922 KB/sec 00:00:01 0 Errors
[root@localhost fonts]# mv stxingka.ttf song.ttf
[root@localhost fonts]# chmod a+x song.ttf
[root@localhost ~]# vi /usr/share/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'song'); ///修改原有字体为“song”
保存退出,重新加载web界面即可生成
仅供学习
1、zabbix概念
2、zabbix安装
3、zabbix添加主机
4、zabbix监控项
5、zabbix带有参数的监控项
6、zabbix触发器、动作、事件相关概念
7、zabbix创建触发器
8、zabbix触发器语法
9、zabbix定义报警媒介
10、zabbix动作详解
11、zabbix触发警报