本次部署用到三个节点:
资源库装在 192.168.1.1 【建议选择mysql做资源库】
tomcat监控网站装在 192.168.1.2 【采集中心装在监控节点或者再加一个节点192.168.1.4安装采集中心】
被监控集群装在 192.168.1.3 【采集代理装在集群节点,集群的每一个节点都要安装采集代理】
安装资源库mysql
Linux 安装Mysql 详细教程(图文教程)_bai_shuang的博客-CSDN博客_linux安装mysql
[root@hw-00 ~]# yum install cmake ncurses-devel gcc gcc-c++ vim lsof bzip2 openssl-devel -y
[root@hw-00 ~]# useradd mysql
[root@hw-00 ~]# passwd mysql
[root@hw-00 ~]# visudo
mysql ALL=(ALL) ALL
[mysql@tx ~]$ ll
-rw-r--r-- 1 mysql mysql 492490461 Nov 9 21:17 mysql-8.0.30-el7-x86_64.tar.gz
[mysql@tx ~]$ tar -zxvf mysql-8.0.30-el7-x86_64.tar.gz
[mysql@tx ~]$ su - root
Password:
Last login: Wed Nov 9 21:16:48 CST 2022 from 111.199.219.192 on pts/0
[root@tx ~]# mkdir -p /data/mysql
[root@tx ~]# chown -R mysql:mysql /data/mysql
[root@tx ~]# vi /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
[root@tx mysql]# pwd
/home/mysql
[root@tx mysql]# ll
drwxrwxr-x 9 mysql mysql 4096 Nov 9 21:22 mysql-8.0.30-el7-x86_64
[root@tx mysql]# mv mysql-8.0.30-el7-x86_64 /usr/local/mysql
[root@tx mysql]# cd /usr/local/mysql/bin/
[root@tx bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
[root@tx bin]# cat /data/mysql/mysql.err
2022-11-09T13:30:19.051113Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Js******5&<
[root@tx bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@tx bin]# chown -R mysql.mysql /usr/local/mysql
[root@tx bin]# chown -R mysql.mysql /data/mysql
[root@tx bin]# su - mysql
[mysql@tx ~]$ service mysql start
[root@tx ~]# vi /etc/my.cnf
[root@tx ~]# service mysql restart
[root@tx ~]# systemctl restart mysqld
[mysqld]
skip-grant-tables
[root@tx ~]# /usr/local/mysql/bin/mysql -u root -p
mysql> use mysql;
mysql> update user set host='%' where user='root';
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER "root"@"%" IDENTIFIED BY "*****0531!";
mysql> create user 'gbase'@'%' identified by 'gbase****';
mysql> grant all on monitor.* to gbase;
[root@tx ~]# vi /etc/my.cnf
[root@tx ~]# systemctl restart mysqld
[root@tx ~]# which mysql
/bin/mysql
[root@tx ~]# rm /bin/mysql
rm: remove regular file ‘/bin/mysql’? y
[root@tx ~]# ln -s /usr/local/mysql/bin/mysql /bin/mysql
[root@tx ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
[root@tx ~]# firewall-cmd --reload
[mysqld]
#skip-grant-tables
初始化monito数据库
使用mysql做资源库的话必须,使用8a做资源库的话 可以不手工初始化,但是我用8a有点问题,后来还是改用mysql 5.7 了
[gbase@tx monitor]$ pwd
/opt/monitor
[gbase@tx monitor]$ ll
total 168
-rw-r--r-- 1 gbase gbase 171867 Sep 27 2021 dbupdate_db8a_9.5.1.0.sql
[gbase@tx monitor]$ gccli -ugbase -p******110531! < dbupdate_db8a_9.5.1.0.sql
[gbase@tx ~]$ gccli -ugbase -p
Enter password:
GBase client 9.5.3.27.14_patch.1b41b5c1. Copyright (c) 2004-2022, GBase. All Rights Reserved.
gbase> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| performance_schema |
| gbase |
| gctmpdb |
| db1 |
| gclusterdb |
| monitor |
+--------------------+
7 rows in set (Elapsed: 00:00:00.00)
gbase> use monitor;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> show tables;
+-----------------------------+
| Tables_in_monitor |
+-----------------------------+
| center |
| center_temp_conf |
| cluster |
| cluster_area |
| cluster_log |
| cluster_node |
| cluster_process |
| cluster_type |
| collection_mode |
| conf_backup_log |
| db_resource_control_history |
| device_type |
| equipment_info |
| gbase8tinfo |
| gbaseinfo |
| gbs_info |
| gbt_info |
| gbt_mtd_info |
| gbt_multi_info |
| load_his_error_data |
| load_his_info |
| log_type |
| monitor_clear_log |
| monitor_config |
| monitor_config_manage |
| monitor_index |
| monitor_index_mib |
| monitor_index_summary_type |
| monitor_item_conf |
| monitor_item_user |
| monitor_level |
| monitor_log |
| monitor_strategy |
| net_device_basic_info |
| net_device_port_info |
| process_type |
| processinfo |
| qingcloud_info |
| resources |
| resources_role |
| role |
| rtsync_basic_info |
| server_info |
| server_sensor_info |
| sqltrace |
| sqltrace_iter |
| sync_his_info |
| sysinfo |
| us_info |
| user |
| user_cluster |
| user_role |
| warning |
| warning_conf |
| xinghuan_info |
+-----------------------------+
55 rows in set (Elapsed: 00:00:00.01)
安装监控网站
注意:这里安装到单独的服务器,不要跟资源数据库在一起,一个是资源抢占问题,一个是装在一起 ssh登录失败,后面不能安装采集中心(这里我不确定是我机器的问题 还是本来就不能装在一起,反正分开装肯定没问题)
[gbase@tx ~]$ pwd
/home/gbase
[gbase@tx ~]$ ll
-rw-r--r-- 1 gbase gbase 342596917 Nov 6 09:38 GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64.zip
[gbase@tx ~]$ unzip GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64.zip
[gbase@tx web]$ cd GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/
[gbase@tx web]$ ll
-rw-r--r-- 1 gbase gbase 302858327 Sep 27 2021 apache-tomcat-8.5.65.zip
[gbase@tx web]$ unzip apache-tomcat-8.5.65.zip
[gbase@tx web]$ chmod -R 755 apache-tomcat-8.5.65
[gbase@tx web]$ cd apache-tomcat-8.5.65/bin/
[gbase@tx bin]$ sh startup.sh
Using CATALINA_BASE: /home/gbase/GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/apache-tomcat-8.5.65
Using CATALINA_HOME: /home/gbase/GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/apache-tomcat-8.5.65
Using CATALINA_TMPDIR: /home/gbase/GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/apache-tomcat-8.5.65/temp
Using JRE_HOME: ../jre
Using CLASSPATH: /home/gbase/GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/apache-tomcat-8.5.65/bin/bootstrap.jar:/home/gbase/GBaseGMonitor-9.5.1.0_build21-Redhat_x86-64/web/apache-tomcat-8.5.65/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
开放端口
如果是阿里云或者腾讯云什么云,需要在阿里云网站配置防火墙规则,开放端口,只在服务器开放端口没用(原来资源库用的8a 开的5258端口,如果是mysql 开3306端口)
[root@tx bin]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@tx bin]# firewall-cmd --reload
success
[root@tx bin]# firewall-cmd --list-ports
5258/tcp 8080/tcp
用另一台机器验证端口
[root@hw-00 ~]# telnet 13.143.154.13 8080
Trying 13.143.154.13...
Connected to 13.143.154.13.
Escape character is '^]'.
^CConnection closed by foreign host.
如果端口通了 但是网页还是无法访问 可以试试重启防火墙
[root@tx apache-tomcat-8.5.65]# systemctl stop firewalld
[root@tx apache-tomcat-8.5.65]# systemctl start firewalld
[root@tx apache-tomcat-8.5.65]# systemctl restart firewall
访问监控页面
http://13.143.154.13:8080/gcmonitor
8a数据库如果没有手工初始化资源库 这里需要勾上
这里主机的IP地址 写 资源库的IP 不是要监控的数据库的IP,所有的监控数据存放在资源库中
admin/admin
安装采集中心
点击右上角 platform manage
添加监控集群
采集策略 全选
点击采集中心管理 添加采集中心
采集中心负责将采集代理采集的信息持久化到资源库、并进行节点报警处理等。一个集群只能通过一个采集中心对采集代理进行采集
这里的主机 写监控服务器的IP,这个是采集中心装在哪个节点,可以跟监控服务器装在一起,也可以新增一个节点 专门做采集中心
勾选然后安装
填写操作系统用户
如果发生下面错误,检查IP地址是否正确,我第一次监控跟数据库装在同一台服务器,这样ssh不通,监控必须是单独的服务器
监控服务器(刚才填的采集中心的地址)可以看到 已经多了采集中心的目录
[root@hw-00 gbase]# pwd
/home/gbase
[root@hw-00 gbase]# ll
drwxr-xr-x 5 gbase gbase 4096 Nov 6 20:22 gcmonitor_center
安装采集代理
采集代理需要部署在 GCluster 集群节点上。该模块负 责采集集群节点的操作系统、磁盘、内存、CPU、网络流量、节点运行状态、节点 进程、以及集群的运行情况。
这里写要监控的节点的IP ,跟服务器类型这个选项保持一致,如果选gcluster 就写gcluster的IP 如果是gnode 就写gnode的IP, 把集群的每个IP都配上,如果是gcluster就写gcluster的IP 做相应的勾选,gnode也是同样的道理
这里不知道为什么 已经添加了 但是显示不出来 导致无法安装【确定是数据库的问题,用8a 953做资源库 确实显示不出来,后来改成mysql5.7 就可以正常显示了】
最后一步就是安装采集代理了,然后该启动的启动就好了