oracle11安装完成后, 实例名: zbx01
oracle创建zbx01用户:
col file_name for a60;
set linesize 160;
select file_name,tablespace_name,bytes from dba_data_files;
create tablespace ZBX01 datafile '/u01/oracle/oradata/zbx01/zbx01.dbf' size 5g autoextend on ;
CREATE USER zbx01 IDENTIFIED BY zbx01 DEFAULT TABLESPACE ZBX01;
GRANT DBA TO zbx01 WITH ADMIN OPTION;
GRANT ALTER SESSION TO ZBX01 ;
授权ZBX01用户可以修改会话
GRANT CREATE SESSION TO ZBX01 ;
创建会话
GRANT CONNECT TO ZBX01 ;
连接数据库
ALTER USER ZBX01 DEFAULT ROLE ALL;
修改数据库用户ZBX01拥有所有默认角色
GRANT SELECT ON DBA_REGISTRY TO ZBX01 ;
GRANT SELECT ON DBA_SEGMENTS TO ZBX01 ;
GRANT SELECT ON DBA_DATA_FILES TO ZBX01 ;
GRANT SELECT ON DBA_TEMP_FILES TO ZBX01 ;
GRANT SELECT ON DBA_FREE_SPACE TO ZBX01 ;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZBX01 ;
创建zabbix用户
useradd zabbix
导入表结构:
下载zabbix-4.2.1源码包
cd /home/zabbix/
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.1/zabbix-4.2.1.tar.gz
解压
tar -zxvf zabbix-4.2.1.tar.gz -C /home/zabbix/
cd /home/zabbix/zabbix-4.2.1/database/oracle
有三个文件,data.sql images.sql schema.sql
先要执行schema.sql
因为里面有个oracle不支持的字符长度,所以先要修改字符串长度
sed -i 's/2048/2000/g' schema.sql
第二个脚本是images.sql
里面有个目录/home/zabbix/zabbix-4.2.1/create/output_png
这目录里面应该放图片,oracle对个目录权限,所以我们将这个目录替换。
sed -i 's%/home/zabbix/zabbix/create/output_png%/home/zabbix/output_png/%g' images.sql
然后将图片拷贝到/tmp/zabbix/create/images目录中
mkdir /home/zabbix/output_png/
cp -r /home/zabbix/zabbix-4.2.1/misc/images/* /home/zabbix/output_png/
chown -R oracle:dba /home/zabbix/output_png
chmod 775 /home/zabbix/
执行三个sql 脚本 注意是zbx01用户(proxy环境只需要导入schema.sql文件)
sqlplus zbx01/zbx01
sqlplus> @schema.sql
sqlplus> @images.sql
sqlplus> @data.sql
调整字段的长度:
SQL> alter table items add(new_description nvarchar2(2000));
SQL> update items set new_description = DESCRIPTION;
SQL> alter table items drop column DESCRIPTION;
SQL> alter table items rename column new_description to DESCRIPTION;
关闭防火墙(iptable, firewalld), selinux
安装php5.5
CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-mbstring.x86_64 php55w-pdo.x86_64 php55w-xml.x86_64 php55w-xmlrpc.x86_64 php55w-fpm php55w-devel php55w-xml
yum install -y php55w-bcmath-5.5.38-1.w7.x86_64 --skip-broken
安装相关组件:
yum update
yum install -y wget libmicro httpd-devel httpd-devel httpd-tools libmicrohttpd.x86_64 lrzsz httpd net-snmp-devel java-devel openldap openldap-devel libssh2-devel.x86_64 unixODBC-devel.x86_64 OpenIPMI-devel OpenIPMI-libs.x86_64 net-snmp-devel libxml2 curl-devel libxml2-devel gcc gcc-c++ compat-libstdc++-33
[iyunv@test1 zabbix]# php -v
PHP 5.5.38 (cli) (built: Jul 21 2016 12:25:20)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
[iyunv@test1 ~]# which phpize
/usr/bin/phpize
安装oracle client
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
安装OCI8
wget http://pecl.php.net/get/oci8-2.0.12.tgz
tar -xf oci8-2.0.12.tgz
cd oci8-2.0.12
phpize
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib --with-php-config=/usr/bin/php-config
make
make test
make install
启用OCI8(此步也是启用PHP database support中对oracle的支持)
echo "/usr/lib/oracle/11.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf
echo "extension=oci8.so" >> /etc/php.ini
ldconfig
安装完成后可以测试一下是否安装OCI成功
echo "<?php phpinfo(); ?>">/var/www/html/test.php
systemctl restart httpd
有以下部分显示则表示安装成功
配置环境变量:(可以将配置放在root和zabbix用户下)
将以下内容写入/etc/profile文件
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:/usr/lib/oracle/11.2/client64/bin:$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export TNS_ADMIN=/usr/lib/oracle/11.2/client64/network/admin
export PATH=$PATH:/usr/lib/oracle/11.2/client64/bin
network/admin两个目录自己建一下,然后把zabbixDB的tnsname.ora复制到admin目录下
把11G的/u01/app/oracle/product/11.2.0/db_1/bin/tnsping文件上传到/usr/lib/oracle/11.2/client64/bin/目录下
cp /u01/oracle/product/db11g/bin/tnsping /usr/lib/oracle/11.2/client64/bin/
zabbix源码安装
创建文件
mkdir /etc/zabbix
编译
cd /home/zabbix/zabbix-4.2.1
创建/usr/lib/oracle/11.2/client64/rdbms/public 然后将/usr/include/oracle/11.2/client64/的内容复制到/usr/lib/oracle/11.2/client64/rdbms/public之下
mkdir /usr/lib/oracle/11.2/client64/rdbms/public -p
cp -r /usr/include/oracle/11.2/client64/* /usr/lib/oracle/11.2/client64/rdbms/public/
#OpenIPMI-devel安装一直有问题, 就强制安装即可
yum -y install OpenIPMI libssh2-devel ncurses-devel OpenIPMI-devel libevent-devel unixODBC-devel net-snmp-devel java*
server
./configure --prefix=/etc/zabbix/ --enable-server --enable-agent --enable-java --with-ssh2 --enable-ipv6 --with-oracle=/usr/lib/oracle/11.2/client64/ --with-unixodbc --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
5、configure: error: Unable to find "javac" executable in path
#yum install java-1.6.0-openjdk-devel
编译结果如下:
Configuration:
Detected OS: linux-gnu
Install path: /home/zabbix/zabbix/
Compilation arch: linux
Compiler: cc
Compiler flags: -g -O2
Library-specific flags:
database: -I/usr/lib/oracle/11.2/client64//rdbms/public -I/usr/lib/oracle/11.2/client64//rdbms/demo
libXML2: -I/usr/include/libxml2
unixODBC: -I/usr/include
Net-SNMP: -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include
OpenIPMI: -I/usr/include
libssh2: -I/usr/include
Enable server: yes
Server details:
With database: Oracle
WEB Monitoring: cURL
SSL certificates: /home/zabbix/zabbix/share/zabbix/ssl/certs
SSL keys: /home/zabbix/zabbix/share/zabbix/ssl/keys
Native Jabber: no
SNMP: yes
IPMI: yes
SSH: yes
TLS: no
ODBC: yes
Linker flags: -L/usr/lib/oracle/11.2/client64//lib -L/usr/lib64 -L/usr/lib64 -L/usr/lib -L/usr/lib -rdynamic
Libraries: -lclntsh -lnnz11 -lxml2 -lodbc -lnetsnmp -lssh2 -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /home/zabbix/zabbix/etc/zabbix_server.conf
External scripts: /home/zabbix/zabbix/share/zabbix/externalscripts
Alert scripts: /home/zabbix/zabbix/share/zabbix/alertscripts
Modules: /home/zabbix/zabbix/lib/modules
Enable proxy: no
Enable agent: yes
Agent details:
TLS: no
Linker flags: -rdynamic
Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /home/zabbix/zabbix/etc/zabbix_agentd.conf
Modules: /home/zabbix/zabbix/lib/modules
Enable Java gateway: yes
Java gateway details:
Java compiler: javac
Java archiver: jar
LDAP support: no
IPv6 support: yes
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
安装
make && make install
make[2]: Entering directory `/source/zabbix-4.2.1/misc'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/source/zabbix-4.2.1/misc'
make[1]: Leaving directory `/source/zabbix-4.2.1/misc'
make[1]: Entering directory `/source/zabbix-4.2.1'
make[2]: Entering directory `/source/zabbix-4.2.1'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/source/zabbix-4.2.1'
make[1]: Leaving directory `/source/zabbix-4.2.1'
[root@zbx01 zabbix-4.2.1]#
建软连接
ln -s /home/zabbix/zabbix/etc /etc/zabbix
配置zabbix服务
修改zabbix.conf 配置文件
vi /etc/zabbix/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=xxx.xxx.xxx.xxx
DBName=zabbix
DBUser=zabbix
Password=zabbix
DBPort=1521
Timeout=4
LogSlowQueries=3000
修改php.ini(sed不太会用的使用vim进行手动改)
sed -i 's@;date.timezone [email protected] = Asia/Shanghai@g' /etc/php.ini
sed -i 's@max_execution_time = 30@max_execution_time = 300@g' /etc/php.ini
sed -i 's@post_max_size = 8M@post_max_size = 32M@g' /etc/php.ini
sed -i 's@max_input_time = 60@max_input_time = 300@g' /etc/php.ini
sed -i 's@;ambstring.func_overload = [email protected]_overload = 2@g' /etc/php.ini
sed -i 's@upload_max_filesize = 2M@upload_max_filesize = 32M@g' /etc/php.ini
sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.in
添加zabbix服务启动及开机启动
cp /home/zabbix-3.2.3/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
cp /home/zabbix-3.2.3/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
sed -i "s@ZABBIX_BIN=\"/usr/local/sbin/zabbix_server\"@ZABBIX_BIN=\"/home/zabbix/sbin/zabbix_server\"@g" /etc/init.d/zabbix_server
sed -i "s@ZABBIX_BIN=\"/usr/local/sbin/zabbix_agentd\"@ZABBIX_BIN=\"/home/zabbix/sbin/zabbix_agentd\"@g" /etc/init.d/zabbix_agentd
chkconfig --add zabbix_server
chkconfig --add zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on
设置运行权限
chmod 700 /etc/init.d/zabbix_*
启动httpd服务
将zabbix 的php文件拷贝到 httpd 的 根路径/var/www/html/下
cp -r /home/zabbix/zabbix-4.2.1/frontends/php/* /var/www/html/zabbix/
chmod 777 /var/www/html/conf
启动服务 service httpd restart
进入http://IP/
登陆用户: Admin/zabbix
数据库自启:
[oracle@zbx01 ~]$ sqlplus / as sysdba
SQL> startup #开启数据库
[oracle@zbx01 bin]$ lsnrctl start
[oracle@zbx01 bin]$ /etc/oratab
zbx01:/u01/app/oracle/product/11.2.0/db_1:Y #默认N改成Y
[oracle@zbx01 bin]$ dbstart ${ORACLE_HOME}
Processing Database instance "zbx01": log file /u01/app/oracle/product/11.2.0/db_1/startup.log
[root@zbx01 ~]# cat /etc/rc.local
su - oracle -lc "sh /home/oracle/start.sh"
[root@zbx01 ~]# cat /home/oracle/start.sh
source ~/.bash_profile
dbstart ${ORACLE_HOME}
lsnrctl start
附加: 修改http和php-fpm进程用户
https://blog.csdn.net/qq_14824885/article/details/84197579
zabbix+oracle 分离做法
zabbix安装端不需要安装oracle, 只需要安装oracle client即可. 在配置web页面时填写dbname应该填写数据库端的实例明/配置文件的dbname一样