赞
踩
主机 | 角色 |
192.168.20.38 CentOS7.9 | oracle 19c server |
192.168.20.38 CentOS7.9 | zabbix-agent2 client |
192.168.20.36 Ubuntu 23.04 | zabbix-server |
oracle 19c安装可以参考 Linux安装oracle 19c_linux 安装oracle19c_ethnicitybeta的博客-CSDN博客
- a. Install Zabbix repository
- # wget https://repo.zabbix.com/zabbix/6.5/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.5-1+ubuntu22.04_all.deb
- # dpkg -i zabbix-release_6.5-1+ubuntu22.04_all.deb
- # apt update
- ---------------------------------------------
- b. Install Zabbix server, frontend, agent
- # apt install mysql-server zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
- ---------------------------------------------
- c. Create initial database
- Documentation
- Make sure you have database server up and running.
- Run the following on your database host.
- # mysql -uroot -p
- password
- mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin;
- mysql> create user zabbix@localhost identified by 'password';
- mysql> grant all privileges on zabbix.* to zabbix@localhost;
- mysql> set global log_bin_trust_function_creators = 1;
- mysql> quit;
- ---------------------------------------------
- On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.
- # zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
- ---------------------------------------------
- Disable log_bin_trust_function_creators option after importing database schema.
- # mysql -uroot -p
- password
- mysql> set global log_bin_trust_function_creators = 0;
- mysql> quit;
- ---------------------------------------------
- d. Configure the database for Zabbix server
- Edit file /etc/zabbix/zabbix_server.conf
-
- DBPassword=password
- ---------------------------------------------
- e. Configure PHP for Zabbix frontend
- Edit file /etc/zabbix/nginx.conf uncomment and set 'listen' and 'server_name' directives.
-
- # listen 8080;
- # server_name example.com;
- ---------------------------------------------
- f. Start Zabbix server and agent processes
- Start Zabbix server and agent processes and make it start at system boot.
-
- # systemctl restart zabbix-server zabbix-agent nginx php8.1-fpm
- # systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm
- ---------------------------------------------
-
- a. Install Zabbix repository
- # apt install zabbix-agent2 zabbix-agent2-plugin-*
- # systemctl restart zabbix-agent2
- # systemctl enable zabbix-agent2
- [root@oracle-server admin]# ls /opt/oracle/product/19c/dbhome_1/network/admin/
- listener.ora samples shrept.lst sqlnet.ora tnsnames.ora
- --------------------------------------------------------------
- [root@oracle-server ~]# cat /etc/hosts
- 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
- 192.168.20.38 oracle-server
- --------------------------------------------------------------
- [root@oracle-server ~]# cat /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
- # listener.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
- # Generated by Oracle configuration tools.
-
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-server)(PORT = 1521))
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- )
- )
-
- --------------------------------------------------------------
- [root@oracle-server ~]# cat /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
- # tnsnames.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
- # Generated by Oracle configuration tools.
-
- ORCLCDB =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-server)(PORT = 1521))
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = ORCLCDB)
- )
- )
-
- LISTENER_ORCLCDB =
- (ADDRESS = (PROTOCOL = TCP)(HOST = oracle-server)(PORT = 1521))
-
- --------------------------------------------------------------
- [root@oracle-server ~]# cat /opt/oracle/product/19c/dbhome_1/network/admin/shrept.lst
- # function entry points for genclntsh.sh
-
- network : snaumihi_inithostinfo
- network : snaumbg_gmt
- network : naedpwd_encrypt
- network : naumbsb_bld_singlebyte
- network : nlgh
- network : nsdhctx_establish
- network : nsdhctx_respond
- network : nsdhctx_close
- network : nsdhctx_inuse
- network : snlsmDscFromString
- network : snlsmCreate
- network : snlsmDestroy
- network : snlsmDscToString
- network : ngsmutl_init_ul
- network : ngsmutl_init_com
- network : ngsmutl_destroy
- network : ngsmutl_add_value
- network : ngsmutl_add_type
- network : ngsmutl_convert_key
- network : ngsmutl_make_hash_type
- network : ngsmutl_key_hash
- network : ngsmutl_key_init
- network : ngsmutl_key_save
- network : ngsmutl_key_copy
- network : ngsmutl_key_free
- network : ngsmutl_key_cmpns
- network : ngsmutl_key_cmp_optimistic
- network : ngsmutl_sort
- network : ngsmuit_new
- network : ngsmuit_root
- network : ngsmuit_find_node
- network : ngsmuit_find_nodes
- network : ngsmuit_find_insts
- network : ngsmuit_insert
- network : ngsmuit_delete
- network : ngsmuit_remove_inst_opt
- network : ngsmuit_add_inst
- network : ngsmuit_destroy
- network : ngsmsl_init
- network : ngsmsl_terminate
- network : ngsmsl_sdbctx_init
- network : ngsmsl_sdbctx_terminate
- network : ngsmsl_key_init
- network : ngsmsl_shardkey_add_column
- network : ngsmsl_key2base64
- network : ngsmsl_shardkey_free
- network : ngsmsl_build_topology
- network : ngsmsl_lookup_insts
- network : ngsmsl_chunk_down
- network : ngsmsl_chunk_up
- network : ngsmsl_remove_inst
- network : snlsinf
- network : snlsinfs
- network : snlsinfwf
- network : snlsinfi
- network : snlsinft
- --------------------------------------------------------------
- [root@oracle-server ~]# cat /opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora
- # sqlnet.ora Network Configuration File: /opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora
- # Generated by Oracle configuration tools.
-
- NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
- [root@oracle-server ~]# cat /usr/lib/systemd/system/zabbix-agent2.service
- [Unit]
- Description=Zabbix Agent 2
- After=syslog.target
- After=network.target
-
- [Service]
- Environment="ORACLE_HOME=/opt/oracle/product/19c/dbhome_1"
- Environment="LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH"
- Environment="TNS_ADMIN=$ORACLE_HOME/network/admin/"
- Environment="PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin"
- Environment="LANG=en_US.UTF-8"
- Environment="NLS_LANG=AMERICAN_AMERICA.AL32UTF8"
- Environment="CONFFILE=/etc/zabbix/zabbix_agent2.conf"
- EnvironmentFile=-/etc/sysconfig/zabbix-agent2
- Type=simple
- Restart=on-failure
- PIDFile=/run/zabbix/zabbix_agent2.pid
- KillMode=control-group
- ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE
- ExecStop=/bin/kill -SIGTERM $MAINPID
- RestartSec=10s
- User=zabbix
- Group=zabbix
- LimitNOFILE=8192
-
- [Install]
- WantedBy=multi-user.target
- ---------------------------------------------
- 或者在 /etc/sysconfig/zabbix-agent2中添加如下内容也可以(哪种方式都可以)
- [root@oracle-server ~]# cat /etc/sysconfig/zabbix-agent2
- ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
- LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
- TNS_ADMIN=$ORACLE_HOME/network/admin/
- PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
- LANG=en_US.UTF-8
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
-
- 但是需要保证环境变量里有
- ---------------------------------------------
- [root@oracle-server ~]# systemctl daemon-reload
- ---------------------------------------------
- [root@oracle-server ~]# systemctl restart zabbix-agent2
- ---------------------------------------------
- 验证环境变量设置
- 1、获取PID
- [root@oracle-server ~]# ps -ef |grep zabbix
- zabbix 14550 1 0 16:08 ? 00:00:00 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf
- root 14702 13516 0 16:11 pts/1 00:00:00 grep --color=auto zabbix
- 2、验证
- [root@oracle-server ~]# strings -a /proc/14550/environ
- LANG=en_US.UTF-8
- PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
- HOME=/var/lib/zabbix
- LOGNAME=zabbix
- USER=zabbix
- SHELL=/sbin/nologin
- ORACLE_HOME=/opt/oracle/product/19c/dbhome_1
- LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
- TNS_ADMIN=$ORACLE_HOME/network/admin/
- NLS_LANG=AMERICAN_AMERICA.AL32UTF8
- CONFFILE=/etc/zabbix/zabbix_agent2.conf
3、验证是如下结果是正确的
- [root@oracle-server ~]# /usr/local/bin/tnsping 192.168.20.38:1521/ORCLCDB
-
- TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 12-JUL-2023 16:12:21
-
- Copyright (c) 1997, 2019, Oracle. All rights reserved.
-
- Used parameter files:
- /opt/oracle/product/19c/dbhome_1/network/admin/sqlnet.ora
-
- Used HOSTNAME adapter to resolve the alias
- Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=ORCLCDB))(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.20.38)(PORT=1521)))
- OK (0 msec)
-
- --------------------------------------------------------------
- [root@oracle-server ~]# sqlplus system/123456@ORCLCDB
-
- SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 12 16:20:19 2023
- Version 19.3.0.0.0
-
- Copyright (c) 1982, 2019, Oracle. All rights reserved.
-
- Last Successful login time: Wed Jul 12 2023 16:09:24 +08:00
-
- Connected to:
- Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
- Version 19.3.0.0.0
-
- SQL>
zabbix的web页面--数据采集--主机---依赖模板(Oracle by Zabbix agent 2)
2、设置主机宏(根据自己的实际情况写)
宏 | 值 |
{$ORACLE.DRIVER} | /opt/oracle/product/19c/dbhome_1/lib/libsqora.so.19.1 |
{$ORACLE.HOST} | 192.168.20.38 |
{$ORACLE.PASSWORD} | 123456 |
{$ORACLE.PORT} | 1521 |
{$ORACLE.SERVICE} | ORCLCDB |
{$ORACLE.USER} | system |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。