评论

收藏

[Linux] Zabbix5-0企业级监控告警平台详细部署

服务系统 服务系统 发布于:2021-08-10 11:29 | 阅读数:417 | 评论:0

软件版本:
centos7.7
nginx:1.16.1
PHP:7.2.34
mysql:5.7.30
Zabbix: 5.0
零:注意事项

  • 需要关闭selinux。
  • 需要关闭iptables。
  • 需要关闭firewalld。
一、通过二进制安装Mysql 5.7.30
1.安装mysql服务
[root@leoheng src]# pwd
/usr/local/src
[root@leoheng src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
[root@leoheng src]# yum remove mariadb-libs -y
[root@leoheng src]# rpm -aq |grep mariadb
[root@leoheng src]# useradd -s /sbin/nologin mysql
[root@leoheng src]# mkdir -p /data/mysql/mysql3306/{data,logs,binlog}
[root@leoheng src]# tar -xf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
[root@leoheng src]# mv mysql-5.7.30-linux-glibc2.12-x86_64  /usr/local/mysql-5.7.30
[root@leoheng src]# ln -s /usr/local/mysql-5.7.30  /usr/local/mysql
[root@leoheng src]# echo  "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
[root@leoheng src]# source /etc/profile
[root@leoheng src]# yum install -y libaio-devel
[root@leoheng src]# chown -R mysql.mysql /usr/local/mysql/ /data/
[root@leoheng mysql3306]# pwd
/data/mysql/mysql3306
[root@leoheng mysql3306]# vim my3306.cnf
[mysql]
prompt = "\u@\h [\d]>"
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3306/data
log-error = /data/mysql/mysql3306/data/error_3306.log
server_id = 6
port = 3306
log_bin = /data/mysql/mysql3306/binlog/mysql-bin
binlog_format = row
gtid_mode = on
enforce-gtid-consistency=true
socket = /tmp/mysql3306.sock
[root@leoheng mysql3306]# /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf  —initialize
[root@leoheng mysql3306]# grep password /data/mysql/mysql3306/data/error_3306.log 
2021-06-01T10:54:54.762373Z 1 [Note] A temporary password is generated for root@localhost: (hzpDzB(07=i
[root@leoheng mysql3306]#
2.配置systemctl启动mysqld服务
[root@leoheng mysql3306]# vim /etc/systemd/system/mysqld.service
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=mutil-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf
LimitNOFILE = 5000
[root@leoheng ~]# chown -R mysql.mysql /usr/local/mysql* /data/
[root@leoheng ~]# systemctl status  mysqld
● mysqld.service - MYSQL SERVER
   Loaded: loaded (/etc/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-06-01 22:54:40 CST; 4s ago
   Docs: man:mysqld(8)
       http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 4791 (mysqld)
   CGroup: /system.slice/mysqld.service
       └─4791 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3306/my3306.cnf
Jun 01 22:54:40 leoheng systemd[1]: Started MYSQL SERVER.
[root@leoheng ~]# mysql -V 
mysql  Ver 14.14 Distrib 5.7.30, for linux-glibc2.12 (x86_64) using  EditLine wrapper
[root@leoheng ~]#
3.修改数据库密码
[root@leoheng ~]# grep password /data/mysql/mysql3306/data/error_3306.log 
2021-06-01T10:54:54.762373Z 1 [Note] A temporary password is generated for root@localhost: (hzpDzB(07=i
[root@leoheng ~]# mysql -uroot -p  -S /tmp/mysql3306.sock
mysql> alter user user() identified by 'leoheng';
Query OK, 0 rows affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database       |
+--------------------+
| information_schema |
| mysql        |
| performance_schema |
| sys        |
+--------------------+
4 rows in set (0.00 sec)
mysql>
二、部署zabbix环境
1.安装配置nginx、php、zabbix服务
[root@monitor ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@monitor ~]# yum clean all
[root@monitor ~]# yum install zabbix-server-mysql zabbix-agent -y
[root@monitor ~]# yum install centos-release-scl -y
[root@monitor ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
.
.
enabled=1
.
.
[root@monitor ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
[root@monitor ~]# mysql -uroot -p  -S /tmp/mysql3306.sock
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;
[root@monitor ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
[root@monitor ~]# vim /etc/zabbix/zabbix_server.conf
DBPassword=password
DBSocket=/tmp/mysql3306.sock
[root@monitor ~]# ln -s /etc/opt/rh/rh-nginx116/nginx  /etc/nginx
[root@monitor ~]# vim /etc/nginx/conf.d/zabbix.conf
listen      80;
    server_name   _;
    root  /usr/share/zabbix;
[root@monitor ~]# ln -s /etc/opt/rh/rh-php72  /etc/php72
[root@monitor ~]# vim /etc/php72/php-fpm.d/zabbix.conf
listen.acl_users = apache,nginx
php_value[date.timezone] = Asia/Shanghai
[root@monitor ~]# systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
[root@monitor ~]# systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
2.处理中文显示乱码
[root@monitor ~]# yum install wqy-microhei-fonts -y
[root@monitor ~]# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
cp: overwrite ‘/usr/share/fonts/dejavu/DejaVuSans.ttf’? y
[root@monitor ~]# systemctl restart zabbix-server
[root@monitor ~]# systemctl status  zabbix-server
● zabbix-server.service - Zabbix Server
   Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-06-01 23:50:36 CST; 5s ago
  Process: 5835 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 5838 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
 Main PID: 5840 (zabbix_server)
[root@monitor ~]# netstat -tunlp |grep  10051
tcp    0    0 0.0.0.0:10051       0.0.0.0:*         LISTEN    5840/zabbix_server  
tcp6     0    0 :::10051        :::*          LISTEN    5840/zabbix_server  
[root@monitor ~]#
三、图形化安装zabbix
1.浏览器访问zabbix前端页面
2.按照配置一步步下去
3.把上面的数据库信息、主机信息按要求填写在图形页面上
4.自定义仪表盘监控项即可
原文链接

关注下面的标签,发现更多相似文章