溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

LAMP 搭建zabbix監(jiān)控Oracle 數(shù)據(jù)庫 for Linux

發(fā)布時(shí)間:2020-06-15 15:26:59 來源:網(wǎng)絡(luò) 閱讀:3000 作者:崔樣樣 欄目:數(shù)據(jù)庫

準(zhǔn)備環(huán)境介紹

文檔簡(jiǎn)介想要實(shí)現(xiàn)的功能為在zabbix服務(wù)器端再增加orabbix插件以此訪問oracle數(shù)據(jù)庫進(jìn)行監(jiān)控操作。

環(huán)境介紹CentOS 7 zabbix 2.4.2 。

yum介紹因公司電腦無法訪問外網(wǎng)則進(jìn)行了本地yum源的配置。

可自行根據(jù)php-common下載相應(yīng)的rpm包或者去我的網(wǎng)盤瞅瞅有木有大家需要的地址如下
鏈接http://pan.baidu.com/s/1skGbrat 密碼n9p3

實(shí)施過程介紹
1.首先是LAMP的搭建其中Linux環(huán)境搭建此處不多介紹MySQL數(shù)據(jù)庫的搭建可參考上篇文檔

搭建 Apache 和 PHP前面也提到因沒有外網(wǎng)只能使用CentOS 7提供的包然后mount到我本地
yum 源的配置
vi /etc/yum.repo.d/CentOS-Local.repo

name=This is a local repo source for lamp
baseurl=file:///mnt/Package
gpgcheck=0
enabled=1

:x  -- 保存退出

ps將yum.repo.d下使用不到的repo文件注釋使其失效

vim /etc/fstab

/dev/sr0  /mnt/Package iso9660 default 0 0

:x  -- 保存退出

mount -a  重新掛載

=======================至此本地yum源配置完成================

修改主機(jī)名配置hostnamectl set-hostname 確認(rèn)修改的名字

修改防火墻配置vi /etc/selinux/config 修改為disabled

# systemctl disable firewalld.service

# systemctl stop firewalld.service

修改時(shí)區(qū)配置timedatectl set-timezone Asia/Shanghai

timedatectl set-local-rtc 1 -- 時(shí)間將與本地電腦時(shí)間同步

timedatectl set-time YYYY-MM-DD -- 設(shè)置日期

timedatectl set-time HH:MM:SS  -- 設(shè)置時(shí)間

修改網(wǎng)卡配置CentOS 7的網(wǎng)卡名稱

第一步修改eth0文件信息

mv ifcfg-eno16777736 ifcfg-eth0

 vi /etc/udev/rules.d/70-persistent-ipoib.rules

添加一行關(guān)于eth0的信息進(jìn)行注冊(cè)。

ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", ATTR{address}=="00:0C:29:97:E4:F2", NAME="eth0"

第二步修改grub配置信息

輸入如下命令進(jìn)入對(duì)應(yīng)目錄編輯文件

vim /etc/sysconfig/grub

然后往這個(gè)文件中添加“net.ifnames=0 biosdevname=0”內(nèi)容如下圖所示

LAMP 搭建zabbix監(jiān)控Oracle 數(shù)據(jù)庫 for Linuxgrub2-mkconfig -o /boot/grub2/grub.cfg

效果如下

LAMP 搭建zabbix監(jiān)控Oracle 數(shù)據(jù)庫 for Linux然后重啟系統(tǒng)后查看網(wǎng)卡名稱

========================至此為L(zhǎng)AMP準(zhǔn)備的基礎(chǔ)環(huán)境已完成建議重啟服務(wù)器===================

Apache配置

yum -y install httpd  //安裝

systemctl start httpd.service //開啟apache服務(wù)

systemctl enable httpd.service //設(shè)置開機(jī)啟動(dòng)

在瀏覽器中輸入ip地址ifconfig如果能夠看到test 123...的字樣則表示成功

PHP配置

yum -y install php //安裝

systemctl restart httpd.service //重啟Apache服務(wù)

vi /var/www/html/info.php //編輯一個(gè)文件做測(cè)試順便看一下自己安裝的PHP版本


<?php         

phpinfo();      

?>


保存退出后再次登陸瀏覽器輸入ip/info.php若是可以看到PHP版本信息則表示成功

將PHP和MySQL鏈接起來不然會(huì)在安裝的界面中顯示鏈接數(shù)據(jù)庫類型為 SQLit3因?yàn)樽约悍高^這方面的報(bào)錯(cuò)記錄一下 yum -y install php-mysql 

yum -y groupinstall "Development Tools" "Development Libraries"

安裝常用的PHP關(guān)聯(lián)模塊
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

重啟Apache服務(wù)和PHP服務(wù)LAMP環(huán)境已完成


zabbix 搭建

zabbix 服務(wù)器是在MySQL服務(wù)器上進(jìn)行的

tar -zxvf zabbix-2.4.2.tar.gz
cd zabbix-2.4.2
./configure --with-mysql=/home/mysql/mysql/bin/mysql_config --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix


過程中遇到的報(bào)錯(cuò) 

第一種過程中如出現(xiàn)configure: error: MySQL library not found錯(cuò)誤是因?yàn)槿鄙賛ariadb-devel該軟件包使用yum install mariadb-devel進(jìn)行安裝后再重新執(zhí)行

第二種過程中若出現(xiàn)configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config使用 yum -y install net-snmp-devel 然后重新運(yùn)行

第三種error while loading shared libraries:libmysqlclient.so.20錯(cuò)誤,查找libmysqlclient.so.20的位置可以使用find命令查找后

ln -s /home/mysql/mysql/lib/libmysqlclient.so.20 /usr/lib64 


重新執(zhí)行

./configure --with-mysql=/home/mysql/mysql/bin/mysql_config --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix

沒有警告后執(zhí)行接下來的命令

# make

# make install


拷貝相關(guān)的配置文件到/etc下并進(jìn)行相關(guān)配置修改

# mkdir -p /etc/zabbix

# cp -r /soft/zabbix-2.4.2/conf/* /etc/zabbix/

# chown -R zabbix:zabbix /etc/zabbix

# ln -s /usr/local/zabbix/etc /etc/zabbix/

# ln -s /usr/local/zabbix/bin/* /usr/bin/

# ln -s /usr/local/zabbix/sbin/* /usr/sbin/


修改zabbix_server.conf  服務(wù)端

vi /etc/zabbix/zabbix_server.conf

LogFile=/tmp/zabbix_server.log   // 日志文件地址

DBHost=localhost            // 數(shù)據(jù)庫主機(jī)

DBName=zabbix              // 數(shù)據(jù)庫名

DBUser=zabbix              // 數(shù)據(jù)庫用戶名

DBPassword=zabbix           // 數(shù)據(jù)庫密碼

ListenIP=xxx              //數(shù)據(jù)庫IP地址

AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts //zabbix運(yùn)行腳本存放目錄


修改zabbix_agentd.conf  客戶端

vi /etc/zabbix/zabbix_agentd.conf

PidFile=/tmp/zabbix_agentd.pid     // 進(jìn)程PID

LogFile=/tmp/zabbix_agentd.log     // 日志保存位置

EnableRemoteCommands=1          // 允許執(zhí)行遠(yuǎn)程命令

Server=xxx                  // agent端的ip本機(jī)ip

ServerActive=xxx

Hostname=Zabbix server          // 必須與zabbix創(chuàng)建的hostname相同

Include=/usr/local/etc/zabbix_agentd.conf.d/

UnsafeUserParameters=1          // 啟動(dòng)自定義key


修改PHP相關(guān)參數(shù)

vi /etc/php.ini

max_execution_time = 300

max_input_time = 300

memory_limit = 128M

upload_max_filesize = 2M

date.timezone = Asia/Shanghai

post_max_size = 28M

配置web站點(diǎn)

# cd zabbix-2.4.2/

# cp -r frontends/php /var/www/html/zabbix

 

修改httpd.conf的參數(shù)

vi /etc/httpd/conf/httpd.conf

<IfModule dir_module>

     DirectoryIndex index.html index.php

 </IfModule>


創(chuàng)建與zabbix相關(guān)的組及庫和用戶

groupadd zabbix   // 創(chuàng)建組

useradd -r -g zabbix zabbix  // 創(chuàng)建用戶


mysql -uroot -p

mysql> create database zabbix character set utf8;

Mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';

Mysql> flush privileges;

mysql> use zabbix;  // 導(dǎo)入數(shù)據(jù)庫資源

mysql> source /soft/zabbix-2.4.2/database/mysql/schema.sql;

mysql> source /soft/zabbix-2.4.2/database/mysql/data.sql;

mysql> source /soft/zabbix-2.4.2/database/mysql/p_w_picpaths.sql;

mysql> quit


安裝web界面

#systemctl restart httpd.service

在瀏覽器中輸入http://ip地址/zabbix進(jìn)入zabbix的web配置頁面一路next有可能會(huì)遇上PHP依賴包缺少的現(xiàn)象找到rpm包下載安裝即可。

Zabbix的默認(rèn)賬號(hào)為Admin密碼為zabbix

遇到的問題可查看zabbix server日志


LAMP 搭建zabbix監(jiān)控Oracle 數(shù)據(jù)庫 for Linux

orabbix 搭建

orabbix 插件是在zabbix server上進(jìn)行的

下載orabbix插件版本是orabbix-1.2.3.zip

安裝好Java環(huán)境

在opt目錄下新建orabbix文件夾后將文件解壓好的文件或者未解壓的zip文件mv到/opt/orabbix下

chmod +x orabbix/ -R

chmod +x run.sh

將orabbix中的執(zhí)行文件Copy到系統(tǒng)服務(wù)目錄中

cp /opt/orabbix/init.d/orabbix/etc/init.d/orabbix

cp/opt/orabbix/conf/config.props.sample /opt/orabbix/conf/config.props

編輯剛剛生成的config.props文件

vi config.props

ZabbixServerList=ZabbixServer1

ZabbixServer1.Address=zabbix 服務(wù)器端的ip地址

ZabbixServer1.Port=10051   // 端口號(hào)為與Zabbix Server connection Port。

#ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER

#ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER

將不需要存在的行用 # 將它注銷了。

#pidFile

OrabbixDaemon.PidFile=./logs/orabbix.pid

#frequency of item's refresh

OrabbixDaemon.Sleep=300

#MaxThreadNumber should be >= than the number of your databases

OrabbixDaemon.MaxThreadNumber=100

#put here your databases in a comma separated list

DatabaseList=Monitor


#Configuration of Connection pool

#if not specified Orabbis is going to use default values (hardcoded)

#Maximum number of active connection inside pool

DatabaseList.MaxActive=10

#The maximum number of milliseconds that the pool will wait

#(when there are no available connections) for a connection to be returned

#before throwing an exception, or <= 0 to wait indefinitely.

DatabaseList.MaxWait=100

DatabaseList.MaxIdle=1

 

#define here your connection string for each database

Monitor.Url=jdbc:oracle:thin:@ip地址:端口號(hào):實(shí)例名 

Monitor.User=zabbix

Monitor.Password=orabbix

#Those values are optionals if not specified Orabbix is going to use thegeneral values.

Monitor.MaxActive=10

Monitor.MaxWait=100

Monitor.MaxIdle=1

Monitor.QueryListFile=./conf/query.props

 

#DB2.Url=jdbc:oracle:thin:@server2.domain.example.com:<LISTENER_PORT>:DB2

#DB2.User=zabbix

#DB2.Password=zabbix_password

#DB2.QueryListFile=./conf/query.props

 

#DB3.Url=jdbc:oracle:thin:@server3.domain.example.com:<LISTENER_PORT>:DB3

#DB3.User=zabbix

#DB3.Password=zabbix_password

#DB3.QueryListFile=./conf/query.props


保存以上配置后使用/etc/init.d/orabbix start來啟動(dòng)Orabbix服務(wù),若后期有別的主機(jī)加入則在databaselist后加再配置即可。


在oracle數(shù)據(jù)庫服務(wù)器端配置zabbix信息登陸sqlplus

GRANT ALTER SESSION TO zabbix;

GRANT CREATE SESSION TO zabbix;

GRANT CONNECT TO zabbix;

ALTER USER zabbix DEFAULT ROLE ALL;

GRANT SELECT ON V_$INSTANCE TO zabbix;

GRANT SELECT ON DBA_USERS TO zabbix;

GRANT SELECT ON V_$LOG_HISTORY TO zabbix;

 

GRANT SELECT ON V_$LOG TO zabbix;

GRANT SELECT ON V_$PARAMETER TO zabbix;

GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO zabbix;

GRANT SELECT ON V_$LOCK TO zabbix;

GRANT SELECT ON DBA_REGISTRY TO zabbix;

GRANT SELECT ON V_$LIBRARYCACHE TO zabbix;

GRANT SELECT ON V_$SYSSTAT TO zabbix;

 

GRANT SELECT ON V_$PARAMETER TO zabbix;

GRANT SELECT ON V_$LATCH TO zabbix;

GRANT SELECT ON V_$PGASTAT TO zabbix;

GRANT SELECT ON V_$SGASTAT TO zabbix;

 

GRANT SELECT ON V_$LIBRARYCACHE TO zabbix;

GRANT SELECT ON V_$PROCESS TO zabbix;

GRANT SELECT ON DBA_DATA_FILES TO zabbix;

GRANT SELECT ON DBA_TEMP_FILES TO zabbix;

GRANT SELECT ON DBA_FREE_SPACE TO zabbix;

GRANT SELECT ON V_$SYSTEM_EVENT TO zabbix;

GRANT SELECT ON V_$locked_object TO zabbix;

GRANT SELECT ON dba_objects TO zabbix;

GRANT SELECT ON dba_tablespaces TO zabbix;

GRANT SELECT ON v_$session TO zabbix;


Oracle 11g數(shù)據(jù)庫的話繼續(xù)添加以下命令

execdbms_network_acl_admin.create_acl(acl => 'resolve.xml',description =>'resolve acl', principal =>'ZABBIX', is_grant => true, privilege =>'resolve');

exec dbms_network_acl_admin.assign_acl(acl=> 'resolve.xml', host =>'*');

commit;


將Orabbix服務(wù)加入隨系統(tǒng)啟動(dòng)

chkconfig --add orabbix

chkconfig --level 345orabbix on


還有一個(gè)很頭疼的報(bào)錯(cuò)

[root@zabbix orabbix]# /etc/init.d/orabbix start

cat: /opt/orabbix/conf/config.props: No such file ordirectory

Starting Orabbix service:

[root@zabbix orabbix]# Stopping

java.lang.Exception: ERROR on main - Connections is empty

     atcom.smartmarmot.orabbix.Orabbixmon.run(Orabbixmon.java:101)

     atcom.smartmarmot.orabbix.bootstrap.main(bootstrap.java:50)

 

[root@zabbix orabbix]# ./run.sh

[root@zabbix orabbix]# Stopping

java.lang.Exception: ERROR on main - Connections is empty

     atcom.smartmarmot.orabbix.Orabbixmon.run(Orabbixmon.java:101)

     at com.smartmarmot.orabbix.bootstrap.main(bootstrap.java:50)。


web界面的orabbix的配置

導(dǎo)入ORACLE的監(jiān)測(cè)模板在orabbix目錄的template內(nèi)使用上傳下載工具放到本地然后選擇導(dǎo)入即可。然后剩下的界面比如說發(fā)短信或發(fā)微信或發(fā)郵件警告的打通方式寫了好久任督二脈都要堵了。休息一會(huì)。。。

=====

擴(kuò)展LAMP=Linux+Apache+MysQL+PHP 

    每次搭建都會(huì)遇到is not running的問題

    在Zabbix中添加Oracle 主機(jī)時(shí)必須用在此設(shè)定的名字Monitor否則無法監(jiān)測(cè)。                 文檔中 xxx 處和被粉紅色覆蓋處均是指實(shí)例命令

    標(biāo)紅處是認(rèn)為需要執(zhí)行的部分

     搭建 zabbix 2.4多多少少都會(huì)遇到一些問題正在挖掘新版本CentOS 6.7 + zabbix 3.0已成功實(shí)施有時(shí)間后期更新博客。。。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI