Zabbix4.0安装部署(Centos7.4)

环境说明:
服务器名 IP 地址 OS 角色 安装的软件
LC001 192.168.19.129 CentOS7.4 zabbix应用服务器 Zabbix_Server,zabbix_agent
LC002 192.168.19.130 CentOS7.4 zabbix数据库服务器 Mysql5.7.18,zabbix_agent
LC003 192.168.19.131 CentOS7.4 nginx服务器 zabbix_agent,nginx-1.9.9
LNTS001 192.168.19.128 Windows2016 AD域控\DNS AD\DNS
1、数据库安装:
[root@lc002 data]# yum install gcc gcc-c++ kernel-devel ncurses-devel bison cmake
[root@lc002 data]# rpm -qa | grep -i mariadb
mariadb-libs-5.5.52-1.el7.x86_64
[root@lc002 data]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
[root@lc002 data]# mkdir /usr/local/mysql /data/mysqldata
[root@lc002 data]# tar -zxf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@lc002 data]# mv mysql-5.7.18-linux-glibc2.5-x86_64/* /usr/local/mysql/
[root@lc002 data]# rm -rf mysql-5.7.18-linux-glibc2.5-x86_64
[root@lc002 data]# ls -l
total 639120
drwx------. 2 root root 16384 Oct 17 19:46 lost+found
-rw-r–r--. 1 root root 654430368 Oct 15 16:59 mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 2 root root 4096 Oct 19 09:21 mysqldata
[root@lc002 data]# groupadd mysql
[root@lc002 data]# useradd -r -g mysql mysql
[root@lc002 data]# chown -R mysql:mysql /data/mysqldata/
[root@lc002 data]# cd /usr/local/mysql/
[root@lc002 mysql]# ./bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysqldata/ --initialize
2018-10-19T02:08:14.551269Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-10-19T02:08:14.774499Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-10-19T02:08:14.808323Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-10-19T02:08:14.869206Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d66f5af0-d343-11e8-b407-000c2920b371.
2018-10-19T02:08:14.903662Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed’ cannot be opened.
2018-10-19T02:08:14.904553Z 1 [Note] A temporary password is generated for root@localhost: yyl=<>e-j7#C
[root@lc002 mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysqld
[root@lc002 mysql]# cp -a ./support-files/mysql.server /etc/init.d/mysqld
[root@lc002 mysql]# systemctl daemon-reload
[root@lc002 mysql]# vim /etc/my.cnf
[mysql]

# CLIENT #
port = 3306
socket = /mysql/mysqldata/mysql.sock
[mysql]

# CLIENT #
port = 3306
socket = /data/mysqldata/mysql.sock
default-character-set = utf8

[mysqld]

# GENERAL #
user = mysql
#default-storage-engine = InnoDB
socket = /data/mysqldata/mysql.sock
pid-file = /data/mysqldata/mysql.pid
character-set-server = utf8

# MyISAM #
key-buffer-size = 32M
#myisam-recover = FORCE,BACKUP

# SAFETY #
max-allowed-packet = 16M
max-connect-errors = 1000000
skip-name-resolve
sql-mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sysdate-is-now = 1
innodb = FORCE

# DATA STORAGE #
datadir = /data/mysqldata/

# BINARY LOGGING #
log-bin = /data/mysqldata/mysql-bin
expire-logs-days = 14
sync-binlog = 1
binlog_format = mixed
server-id = 1

# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 500
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 4096

# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb-buffer-pool-size = 26G

扫描二维码关注公众号,回复: 4269980 查看本文章

“/etc/my.cnf” [New] 62L, 1980C written
[root@lc002 mysql]#
[root@lc002 mysql]#
[root@lc002 mysql]# systemctl daemon-reload
[root@lc002 mysql]# systemctl start mysqld.service
[root@lc002 mysql]# systemctl status mysqld.service
● mysqld.service - LSB: start and stop MySQL
Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)
Active: active (running) since Fri 2018-10-19 09:28:13 CST; 22s ago
Docs: man:systemd-sysv-generator(8)
Process: 24820 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS)
CGroup: /system.slice/mysqld.service
├─24832 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysqldata/ --pid-file=/data/mysqldata/mysql.pid
└─25357 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysqldata --plugin-dir=/usr/local/mysql/lib/…

Oct 19 09:27:45 lc002 systemd[1]: Starting LSB: start and stop MySQL…
Oct 19 09:27:45 lc002 mysqld[24820]: Starting MySQL.Logging to ‘/data/mysqldata/mysql-error.log’.
Oct 19 09:28:13 lc002 mysqld[24820]: … SUCCESS!
Oct 19 09:28:13 lc002 systemd[1]: Started LSB: start and stop MySQL.
[root@lc002 mysql]# ln -s /usr/local/mysql/bin/mysql /usr/bin
[root@lc002 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-log

Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> set password for ‘root’@localhost = password(‘gdsz@dba’);
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘your_password’ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@lc002 mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>
mysql>
mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
±-------------------+
4 rows in set (0.00 sec)

mysql> exit
Bye
[root@lc002 mysql]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[root@lc002 mysql]#
[root@lc002 mysql]#
[root@lc002 mysql]# ls -l
total 36
drwxr-xr-x. 2 root root 4096 Oct 19 09:22 bin
-rw-r–r--. 1 7161 31415 17987 Mar 18 2017 COPYING
drwxr-xr-x. 2 root root 55 Oct 19 09:22 docs
drwxr-xr-x. 3 root root 4096 Oct 19 09:21 include
drwxr-xr-x. 5 root root 229 Oct 19 09:22 lib
drwxr-xr-x. 4 root root 30 Oct 19 09:22 man
-rw-r–r--. 1 7161 31415 2478 Mar 18 2017 README
drwxr-xr-x. 28 root root 4096 Oct 19 09:22 share
drwxr-xr-x. 2 root root 90 Oct 19 09:22 support-files
[root@lc002 mysql]# cd /data/
[root@lc002 data]# ls -l
total 639120
drwx------. 2 root root 16384 Oct 17 19:46 lost+found
-rw-r–r--. 1 root root 654430368 Oct 15 16:59 mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x. 5 mysql mysql 4096 Oct 19 09:28 mysqldata
2、zabbix应用安装
[root@lc001 app]# wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
–2018-10-19 09:30:37-- https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Resolving repo.zabbix.com (repo.zabbix.com)… 162.243.159.138
Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 13712 (13K) [application/x-redhat-package-manager]
Saving to: ‘zabbix-release-4.0-1.el7.noarch.rpm’

100%[===============================================================================================>] 13,712 --.-K/s in 0s

2018-10-19 09:30:38 (254 MB/s) - ‘zabbix-release-4.0-1.el7.noarch.rpm’ saved [13712/13712]

[root@lc001 app]# rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm
warning: zabbix-release-4.0-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:zabbix-release-4.0-1.el7 ################################# [100%]

[root@lc001 app]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

3、数据库服务器创建数据库zabbix,用户zabbix,密码z@bb1xdb
[root@lc002 data]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.02 sec)

mysql> grant all privileges on zabbix.* to zabbix@’%’ identified by ‘z@bb1xdb’;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye
4、复制zabbix-server-mysql的脚本到数据库服务器上
[root@lc001 ~]# scp /usr/share/doc/zabbix-server-mysql*/create.sql.gz [email protected]:/data
[email protected]’s password:
create.sql.gz 100% 1274KB 1.2MB/s 00:00
5、将脚本导入到数据库中
[root@lc002 data]# zcat create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
[root@lc002 data]# mysql -uzabbix -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-log MySQL Community Server (GPL)

Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| zabbix |
±-------------------+
2 rows in set (0.00 sec)

mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
±---------------------------+
| Tables_in_zabbix |
±---------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
±---------------------------+
144 rows in set (0.01 sec)

6、配置zabbix_server.conf文件中DBHost,DPPassword,DBPort
[root@lc001 app]# vim /etc/zabbix/zabbix_server.conf
DBHost=192.168.19.130
DBPassword=z@bb1xdb
DBPort=3306
7、配置时区
[root@lc001 app]# vim /etc/httpd/conf.d/zabbix.conf
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
8、启动zabbix和zabbix agent服务并设置开机自动启动
[root@lc001 ~]# systemctl restart zabbix-server zabbix-agent httpd
[root@lc001 ~]# systemctl enable zabbix-server zabbix-agent httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
9、打开Web URl,进入zabbix配置向导,点击“Next Step" ,
在这里插入图片描述
10、检查Check of pre-requisites,是否条件都满足,都满足为ok
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

11、点击next setp,配置DB连接,输入Database host:192.168.19.130,Database Port:3306,Database name:zabbix,user:zabbix,密码z@bb1xdb,
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

配置LDAN认证
在AD中新建zabbixadmin账号用于配置zabbix LDAP。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/xiaohuibin0541/article/details/83414064