Posts tagged ‘oracle’

Win下的Oracle通过防火墙映射后不能访问的问题解决

一台Windows2003服务器,安装了Oracle数据库,互联网的某些特定用户需要访问该数据库的服务端口1521,在防火墙上做了公网地址至内网地址的转换,将公网地址的6000端口转换成内网数据库的1521端品,如下拓扑所示。

oracleerr01

但测试后发现,无论防火墙怎么设置,外网用户就不能连接上Oracle数据库服务,后来查找资料后发现需要虚拟Oracle服务器的注册表才能解决此问题,网上描述为:

原理:network listener 只是一个连接的中转跳板,客户端同监听连接后,监听根据配置关联到相关的数据库实例然后由listener 产生一个新的连接传递给客户端,这个连接直接Client 至数据库实例,同listener再无关系 ,新的连接端口是随机产生的(内网连接时通过netstat可以发现这一现象)。也就是说你在防火墙所映射的1521端口只能保证客户端连接到listener而无法连接到数据库实例。

修改注册表方法:

进入HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOME0下,增加字符串值USE_SHARED_SOCKET=true即可。

Oracle EXP自动备份脚本

Windows下实现Oracle通过EXP每天晚上备份,并保留十天的备份数据。

1、建立备份脚本oraclebackup.bat

首先建立一个备份bat文件,在D盘下新建备份目录oraclebackup,将oracle安装目录下的EXP.EXE复制到此目录下,再新建一个文本文件oraclebackup.txt,内容如下:

@echo off
echo 删除10天前的备分文件和日志

forfiles /p "D:\oraclebackup" /m *.dmp /d -10 /c "cmd /c del @path"
forfiles /p "D:\oraclebackup" /m *.log /d -10 /c "cmd /c del @path"

echo 正在备份 Oracle 数据库,请稍等……
exp system/oracle@orcl  file=D:/oraclebackup/mdb%date:~0,4%%date:~5,2%%date:~8,2%.dmp log=D:/oraclebackup/mdb%date:~0,4%%date:~5,2%%date:~8,2%.log full=y buffer=65535
echo 任务完成!

完成后,将该记事本的后缀txt改成bat即可。

双击oraclebackup.bat可以测试是否可以正常备份。

2、新建计划任务

进入windows的控制面板,打开计划与任务,新建任务,点击浏览,选择刚才新建的d盘oraclebackup目录下的oraclebackup.bat文件。接着选择每天晚上22:00点执行,再输入本机的administrator密码即可。

安装oracle rac时出现crs-1006和crs-0215错误

在安装clusterware时为避免运行root.sh时出现错误,需在第二个节点运行VIPCA,当运行VIPCA时,就出现了如下错误:

crs-1006:No more members to consider
crs-0215:Could not start resource ‘ora.node2.vip’

搜索发现为配置的网关主机不能PING通导致,立即接入一台笔记本,然后将笔记本IP设置为网关IP。点击[retry],故障排除。

创建ASM磁盘时出现错误:Marking disk "VOL1" as an ASM disk: [FAILED]

安装oracle rac(redhat平台)时,创建asm磁盘时出现failed错误,如下:

[root@node1 /]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk “VOL2” as an ASM disk: [FAILED]

首先查看了asm的状态,如下,状态正常。

[root@node1 /]# /etc/init.d/oracleasm status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes

接着查看asm的日志,如下:

[root@node1 /]# less /var/log/oracleasm
Creating /dev/oracleasm mount point: /dev/oracleasm
Loading module “oracleasm”: oracleasm
Mounting ASMlib driver filesystem: /dev/oracleasm
Reloading disk partitions: done
Cleaning any stale ASM disks…
Scanning system for ASM disks…
oracleasm-read-label: Unable to open device “/dev/sdb1”: No such file or directory
Disk “VOL1” does not exist or is not instantiated
Instantiating disk “VOL1”
Disk “VOL2” does not exist or is not instantiated
Instantiating disk “VOL2”
Disk “VOL1” is a valid ASM disk
Disk “VOL2” is a valid ASM disk
Device “/dev/sdb1” is already labeled for ASM disk “VOL1”
Reloading disk partitions: done
Cleaning any stale ASM disks…
Validating disk “VOL1”
Validating disk “VOL2”
Scanning system for ASM disks…
oracleasm-read-label: Unable to open device “/dev/sdb1”: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Disk “VOL1” is a valid ASM disk
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Disk “VOL2” is a valid ASM disk
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Disk “VOL1” is a valid ASM disk
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Disk “VOL2” is a valid ASM disk
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Device “/dev/sdb1” is already labeled for ASM disk “VOL1”
Device “/dev/sdc1” is already labeled for ASM disk “VOL2”

显示为VOL1和VOL2已经存在,所以当我再次创建时就出现了问题。马上把当时创建的这两个ASM删除,如下操作:

[root@node1 /]# /etc/init.d/oracleasm deletedisk VOL1
Removing ASM disk “VOL1”: [ OK ]
[root@node1 /]# /etc/init.d/oracleasm deletedisk VOL2
Removing ASM disk “VOL2”: [ OK ]

然后再次运行创建命令,可以创建了。

[root@node1 /]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk “VOL1” as an ASM disk: [ OK ]
[root@node1 /]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk “VOL2” as an ASM disk: [ OK ]
[root@node1 /]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@node1 /]# /etc/init.d/oracleasm listdisks
VOL1
VOL2

Oracle 10g RAC for AS 4.8 for x64开启归档日志

环境说明:需要在这个RAC环境中布置NBU备份,ORACLE数据库没启归档所以不能用NBU。只能手工启用归档,并将节点1和节点2的归档放置相应文件夹中。本次配置时NBU客户端安装在节点2上,NBU通过节点2来备份这个RAC数据库。

在节点2上操作查看归档是否启用:

su – oracle
sqlplus /nolog
connect / as sysdba;
archive log list;

数据库日志模式             非存档模式
自动存档             禁用
存档终点            USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列     1
当前日志序列           3

查看后发现未启用归档,进行如下操作可以启用归档:

在节点2上操作:

mkdir /arch1
mkdir /arch2
chown -R oracle:oinstall /arch1
chown -R oracle:oinstall /arch2
chmod -R 777 /arch1
chmod -R 777 /arch2

在节点1上操作:

mkdir /arch1
chown -R oracle:oinstall /arch1
chmod -R 777 /arch1

在节点2上操作(设置归档路径):

su – oracle
sqlplus /nolog
connect / as sysdba;
alter system set log_archive_dest_1=”location=/arch1″ scope=spfile sid=’sid1′;
alter system set log_archive_dest_1=”location=/arch2″ scope=spfile sid=’sid2′;

 在节点2上操作(停止集群中的数据库,然后MOUNT数据库,开始启用归档):

srvctl stop database -d sid
su – oracle
startup mount
alter database archivelog;
alter database open;
srvctl start database -d sid

在节点2上操作(强制生成归档,来查看归档启用是否成功):

su – oracle
sqlplus /nolog
connect / as sysdba;
alter system switch logfile;

然后进/arch2,查看目录是否生成了归档日志文件

接下来需要将节点1上的/arch1通过NFS映射给节点2上的/arch1目录。因为NBU备份客户端只装在节点2上,当NBU开始备份/arch1下的归档文件时,会因为目录下没有文件而出错,所以这里要求将节点1上的/arch1目录映射给节点2上的/arch1目录,操作如下:

在节点1上开NFS:
首先查看是否安装:

rpm -qa | grep nfs
rpm -qa | grep portmap

若没有安装,需安装相应包:

rpm -ivh nfs*
rpm -ivh portmap

配置NFS:

vi /etc/exports

添加如下一行:

/arch1 *(rw)


添加完后保存退出

启动NFS:

service portmap start
service nfs start

在节点2上操作,挂载节点1上的/arch1目录:

mount -t nfs -o rw,bg,hard,nointr,rsize=32768,wsize=32768,tcp,vers=3,timeo=600,actimeo=0 10.10.10.1:/arch1 /arch1

Symantec NetBackup6.5在win下的常用命令

写下WIN下常用的NETBACKUP6.5命令:

1、默认安装位置:C:Program FilesVERITASNetBackup

2、启动及停止netbackup

(1)停止

C:Program FilesVERITASNetBackupbin>bpdown

NetBackup 6.5 — Shutdown Utility

NetBackup software will be shutdown.  This may cause backups to fail.
Do you wish to proceed? (y/n) y
Shutting down services
Calling nbproxyreq to cleanup nbproxy processes.

Shutdown completed successfully.

(2)启动

C:Program FilesVERITASNetBackupbin>bpup

NetBackup 6.5 — Startup Utility

NetBackup services are about to be started.
Do you wish to proceed? (y/n) y
Starting services

Start up completed successfully.

3、列出可用磁带信息

C:Program FilesVERITASNetBackupbingoodies>available_media.cmd

media   media   robot   robot   robot   side/   ret    size     status
ID     type    type      #     slot    face    level  KBytes
—————————————————————————-
CatalogBackup pool

DataStore pool

NetBackup pool

0401L3  HCART3   TLD      0       2      –       –     –        AVAILABLE
0402L3  HCART3   TLD      0       3      –       –     –        AVAILABLE
0403L3  HCART3   TLD      0       4      –       –     –        AVAILABLE
0404L3  HCART3   TLD      0       5      –       –     –        AVAILABLE
0405L3  HCART3   TLD      0       6      –       –     –        AVAILABLE
0406L3  HCART3   TLD      0       7      –       –     –        AVAILABLE
0407L3  HCART3   TLD      0       8      –       –     –        AVAILABLE
0408L3  HCART3   TLD      0       9      –       –     –        AVAILABLE
0409L3  HCART3   TLD      0       10     –       –     –        AVAILABLE

wxgadpt pool

0420L3  HCART3   TLD      0       73     –       3     55693440 ACTIVE
041YL3  HCART3   TLD      0       71     –       –     –        AVAILABLE
041ZL3  HCART3   TLD      0       72     –       –     –        AVAILABLE
0421L3  HCART3   TLD      0       74     –       –     –        AVAILABLE
0422L3  HCART3   TLD      0       75     –       –     –        AVAILABLE
0423L3  HCART3   TLD      0       76     –       –     –        AVAILABLE
0424L3  HCART3   TLD      0       77     –       –     –        AVAILABLE
0425L3  HCART3   TLD      0       78     –       –     –        AVAILABLE
0426L3  HCART3   TLD      0       79     –       –     –        AVAILABLE
0427L3  HCART3   TLD      0       80     –       –     –        AVAILABLE
040AL3  HCART3   TLD      0       11     –       3     356334144        FULL
040BL3  HCART3   TLD      0       12     –       3     356334144        FULL
040CL3  HCART3   TLD      0       13     –       3     356334240        FULL
040DL3  HCART3   TLD      0       14     –       3     356334240        FULL
040EL3  HCART3   TLD      0       15     –       3     356333888        FULL
040FL3  HCART3   TLD      0       16     –       3     356333888        FULL
040GL3  HCART3   TLD      0       17     –       3     356333984        FULL
040HL3  HCART3   TLD      0       18     –       3     356334240        FULL
040IL3  HCART3   TLD      0       19     –       3     356334240        FULL
040JL3  HCART3   TLD      0       20     –       3     356334240        FULL

wxgajwpt pool

040UL3  HCART3   TLD      0       31     –       3     5679104  ACTIVE
040VL3  HCART3   TLD      0       32     –       3     22806528 ACTIVE
040WL3  HCART3   TLD      0       33     –       3     8496672  ACTIVE
040YL3  HCART3   TLD      0       35     –       –     –        AVAILABLE
0410L3  HCART3   TLD      0       37     –       –     –        AVAILABLE
0411L3  HCART3   TLD      0       38     –       –     –        AVAILABLE
0412L3  HCART3   TLD      0       39     –       –     –        AVAILABLE
0413L3  HCART3   TLD      0       40     –       –     –        AVAILABLE
040XL3  HCART3   TLD      0       34     –       3     0        FROZEN
040ZL3  HCART3   TLD      0       36     –       3     0        FROZEN

wxgaqbpt pool

040TL3  HCART3   TLD      0       30     –       3     284681952        ACTIVE
040PL3  HCART3   TLD      0       26     –       –     –        AVAILABLE
040QL3  HCART3   TLD      0       27     –       –     –        AVAILABLE
040KL3  HCART3   TLD      0       21     –       3     356330752        FULL
040LL3  HCART3   TLD      0       22     –       3     356330464        FULL
040ML3  HCART3   TLD      0       23     –       3     356330976        FULL
040NL3  HCART3   TLD      0       24     –       3     356330752        FULL
040OL3  HCART3   TLD      0       25     –       3     356331008        FULL
040RL3  HCART3   TLD      0       28     –       3     356330752        FULL
040SL3  HCART3   TLD      0       29     –       3     356330848        FULL

4、单盘磁带信息

C:Program FilesVERITASNetBackupbinadmincmd>bpmedialist -m 040JL3
Server Host = p570b01

id                rl     images      allocated                    last updated                 density     kbytes     restores
vimages    expiration                     last read                        <——- STATUS ——->
——————————————————————————–
040JL3   3          22            2010-06-18 02:19   2010-06-19 02:48   hcart3   356334240     0
22            2010-07-20 02:48        N/A                                               FULL

5、解除冻结(FROZEN)的磁带

C:Program FilesVERITASNetBackupbinadmincmd>bpmedia -unfreeze -m 040XL3

6、使磁带过期及可写

C:Program FilesVERITASNetBackupbinadmincmd>bpexpdate -m 040ZL3 -d 0

7、列出备份文件目录

C:Program FilesVERITASNetBackupbin>bplist -C p570b01 -t 4 -R /

cntrl_236_1_722661541:
al_235_1_722661254:
al_234_1_722661063:
al_233_1_722661063:
bk_232_1_722660906:
bk_231_1_722660580:
bk_230_1_722660175:
bk_229_1_722659849:

利用NBU6.5备份AIX5.3下的ORACLE 10G数据库

声明:此文档仅作参考,如出现任何问题,文档编写者不承担任何责任!水平有限,文中定有错误之处,见谅!编写:老管,email:funpower#gmail.com

NBU服务器端由一台IBM 226服务器及一台昆腾虚拟带库组成,需备份的客户端为安装AIX5.3的IBM小机,备份的对象为ORACLE 10G数据库。

整个备份的拓扑图如下:

环境说明:
1、NBU备份主服务器与昆腾虚拟带库已配置完成
2、次只为增加的一台Oracle数据库服务器安装NBU客户端相关软件并调试,然后在NBU备份主服务器上添加此客户端并建立备份策略等相关调试
3、IP地址(化名):
NBU备份主服务器:10.31.111.111
Oracle数据库服务器:10.31.111.100

操作步骤:

1、配置Oracle数据库服务器的hosts文件

#cd /etc
#vi hosts

添加一行:
10.31.111.111 nbuserver
保存退出。

2、安装NBU clients软件
通过FTP将NBU客户端软件上传至小机的TMP目录下,然后运行:

#cd /tmp
#chmod –R 777 unixclients
#cd unixclients
#./install

Symantec Installation Script
Copyright 1993 – 2007 Symantec Corporation, All Rights Reserved.

        Installing NetBackup Client Software

 NOTE:  To install NetBackup Server software, insert the appropriate
        NetBackup Server cdrom.

Do you wish to continue? [y,n] (y)   //输入y
Do you want to install the NetBackup client software for this client? [y,n] (y)      //输入y
This package will install RS6000/AIX5 client.
This package will install NetBackup client 6.5.
Enter the name of the NetBackup server : nbuserver       //输入NBU备份主服务器hostname
Would you like to use “oracle1” as the configured
name of the NetBackup client? [y,n] (y)       //输入y,使用原小机的hostsname:oracle1

确认后,就开始安装NBU客户端软件,安装的默认路径为/usr/openv/netbackup。

3、配置和查看bp.conf

#cd /usr/openv/netbackup
#cat bp.conf

SERVER = nbuserver
CLIENT_NAME = oracle1

4、安装database agent
将database agent安装文件上传至上机的/tmp文件夹中,然后:

#cd /tmp
#chmod –R 777 /agents
#./install

Symantec Installation Script
Copyright 1993 – 2007 Symantec Corporation, All Rights Reserved.

        Installation Options

        1 NetBackup Add-On Product Software
        2 NetBackup Database Agent Software

        q To quit from this script
Choose an option [default: q]: 2   //选择2,安装database agent

**********

There are two ways to install database agent software.

1.  Remote Installation:  Loads the software on a server with
    the intent of pushing database software out to affected clients.

2.  Local Installation:   Loads and installs the software only to this
    local machine.

**********

Do you want to do a local installation? [y,n] (n) y     //进行本地安装
**********

        NetBackup Database Agent Installation

Choose the Database Agents you wish to install
one at a time or select Install All Database Agents.

        1)  NetBackup for DB2
        2)  NetBackup for Informix
        3)  NetBackup for Lotus Notes
        4)  NetBackup for Oracle
        5)  NetBackup for SAP
        6)  NetBackup for Sybase

        7)  Install All Database Agents

        q)  Done Selecting Agents
        x)  Exit from this Script

Choose an option: 4      //选择oracle

Choose an option: q       //完成选择操作

You have chosen to install these Database Agents:
        NetBackup for Oracle
Is this list correct? [y,n] (y)        //确定安装oracle agents

5、编辑sh备份脚本
Database agent安装完后,会在/usr/openv/netbackup/ext/db_ext/oracle/samples/rman中有一些例子文件,利用其中的一个,运行:

#cd /usr/openv/netbackup/ext/db_ext/oracle/samples/rman
#cp hot_database_backup.sh hot_database_backup.10.31.111.100.sh

然后使用vi编辑该sh,只需修改如下参数:
ORACLE_HOME=/oracle/product/10G
export ORACLE_HOME
ORACLE_SID=orcl2
export ORACLE_SID
ORACLE_USER=oracle
TARGET_CONNECT_STR=/

完成设置后,保存退出。

6、链接NetBackup for Oracle 和RMAN

#su – oracle
#cd /usr/openv/netbackup/bin
#./oracle_link

Mon Mar 15 11:29:34 BEIST 2010
All Oracle instances should be shutdown before running this script.

Please log into the Unix system as the Oracle owner for running this script

Do you want to continue? (y/n) [n] y     //输入y,开始安装

LIBOBK path: /usr/openv/netbackup/bin
ORACLE_HOME: /oracle/product/10G
Oracle version: 10.2.0.3.0
Linking LIBOBK:
ln -s /usr/openv/netbackup/bin/libobk.a64 /oracle/product/10G/lib/libobk.a
Done

Please check the trace file located in /tmp/make_trace.856304
to make sure the linking process was successful.

出现上面文字后,说明动态链接库已链接成功。

7、NBU备份主服务器设置

首先设置主服务器的hosts文件,将IBM小机的hostname:oracle1添加至hosts中,用记事本打开c:windowssystem32driversetchosts,添加如下:
10.31.111.100 oracle1

打开NBU主界面,开始为10.31.111.100创建一个备份策略

在policies上点右键选择new policy,输入相应策略名称后点击确定

设置attributes选项卡,policy类型选择oracle,policy storage unix选择有效的存储单元

设置Schedules选项卡,点击选项卡下面的New…按扭,新建一个备份日程,选择automatic full backup,全备,frequency选择每星期一次备份,retention选择保留两个星期

备份开始时间为星期日晚上9点开始

设置完后,schedules有两个备份策略,全备和增量备份

设置clients,输入IBM小机的hostname:oracle1,操作系统选择RS6000/AIX5

设置backup selections,将上面新建并编辑好的.sh备份脚本输入至对话框中,点击确定后,完成策略的新建

开始测试备份,在新建的policies的10.31.111.100上点右键选择Manual Backup…,手动启动备份
 

转至Activity Monitor,查看备份情况

至此,IBM小机上的ORACLE已经可以定期的备份至昆腾虚拟磁带库中。

ORACLE收购SUN

123

ORACLE收购SUN已经是旧新闻了,真不知道下来MYSQL的命运如何,有外媒评论说ORACLE收购SUN就是想要MYSQL。如果说收购很大程度上是因为MYSQL那也不是。但应该占了不少的决定砝码。

也有说可能会对现在的LAMP(L inux+Apache+Mysql+PHP)组合受到影响。如果ORACLE真完全把MYSQL给扼杀了,应该会有MYSQL的分支出现。