天道酬勤

Oracle and My Life

新手拍微距

2 comments

前段时间入手了Nikon D90,主要是用来记录果果的成长的,由于从来没有玩过单反,真的是七窍通了六窍啊,惭愧之至。抓紧时间在他/她出生前练练手,不然我这个老爸也太逊了^-^。来张在楼下试拍的微距以资鼓励:
flower
-The End-

Written by ochef

May 19th, 2010 at 12:39 PM

Posted in Life

Tagged with

expdp的network_link参数

leave a comment

expdp是server端工具,但可以通过NETWORK_LINK参数实现远端导出,但是前提是远端也安装有Oracle数据库,只有CLIENT端是没有办法利用数据泵的。

这里要指出的是:network_link不支持远端导出分区表中的某一个分区,但可以导整个分区表。以下为测试过程:

创建分区表sales:

[oracle@ora10g ~]$ sqlplus ‘/as sysdba’

SQL> CREATE TABLE sales

(sale_date DATE NOT NULL)

PARTITION BY RANGE (sale_date)

(PARTITION sales2010_q1

VALUES LESS THAN (TO_DATE(’2010-04-01′,’YYYY-MM-DD’))

TABLESPACE sp1,

PARTITION sales2010_q2

VALUES LESS THAN (TO_DATE(’2010-07-01′,’YYYY-MM-DD’))

TABLESPACE sp2,

PARTITION sales2010_q3

VALUES LESS THAN (TO_DATE(’2010-10-01′,’YYYY-MM-DD’))

TABLESPACE sp3);

插入4条记录:

SQL> select count(*) from sales;

COUNT(*)

———-

4

SQL> select * from sales partition(sales2010_q1);

SALE_DATE

————

23-MAR-10

SQL> select * from sales partition(sales2010_q2);

SALE_DATE

————

23-JUN-10

22-JUN-10

SQL> select * from sales partition(sales2010_q3);

SALE_DATE

————

23-SEP-10

远端机器上创建 directory目录、赋权、创建dblink:

[oracle@node1 /]$ sqlplus ‘/as sysdba’

SQL> create directory dump_dir as ‘/backup’;

Directory created.

SQL> grant read,write on directory dump_dir to ochef;

Grant succeeded.

SQL> create database link test connect to ochef identified by oracle using ‘primary’;

Database link created.

SQL> select count(*) from ochef.sales@test;

COUNT(*)

———-

4

远程导出整个分区表:

[oracle@node1 ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options

Starting “OCHEF”.”SYS_EXPORT_TABLE_01″:  ochef/******** directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales

Estimate in progress using BLOCKS method…

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 384 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

. . exported “OCHEF”.”SALES”                             4.960 KB       4 rows

Master table “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully loaded/unloaded

******************************************************************************

Dump file set for OCHEF.SYS_EXPORT_TABLE_01 is:

/backup/sales.dmp

Job “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully completed at 11:12:43

远程导出分区表的某个分区:

[oracle@node1 ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp network_link=test tables=sales:sales2010_q2

ORA-39001: invalid argument value

ORA-39203: Partition selection is not supported over a network link.

本地导出分区表的某个分区:

[oracle@ora10g ~]$ expdp ochef/oracle directory=dump_dir dumpfile=sales.dmp tables=sales:sales2010_q2

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 – Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting “OCHEF”.”SYS_EXPORT_TABLE_01″:  ochef/******** directory=dump_dir dumpfile=sales.dmp tables=sales:sales2010_q2

Estimate in progress using BLOCKS method…

Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

Total estimation using BLOCKS method: 128 KB

Processing object type TABLE_EXPORT/TABLE/TABLE

. . exported “OCHEF”.”SALES”:”SALES2010_Q2″              4.937 KB       2 rows

Master table “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully loaded/unloaded

******************************************************************************

Dump file set for OCHEF.SYS_EXPORT_TABLE_01 is:

/backup/sales.dmp

Job “OCHEF”.”SYS_EXPORT_TABLE_01″ successfully completed at 11:07:07

关于远程expdp用户权限问题,请移步这里

-The End-

Written by ochef

May 19th, 2010 at 12:27 PM

Posted in Database

Tagged with ,

db_unique_name与service_name

leave a comment

为了data guard在角色切换时不用事先准备好二个init.ora参数文件,那么就需要配置valid_for参数,类似如下配置(备库):

db_unique_name=ora10gstd

log_archive_dest_1=’location=/u01/app/oracle/oradata/ora10g/archive valid_for=(all_logfiles,all_roles) db_unique_name=ora10gstd’

log_archive_dest_2=’service=standby lgwr async valid_for=(online_logfiles,primary_role)   db_unique_name=ora10g’

db_unique_name在oracle的高可用dataguard的应用中会经常使用,有和db_name不一样的作用,在物理dg中,要求主、从库都有一样的db_name(虽然他们和rac不一样,并不是同一个库),但是他们的db_unique_name是不一样的,用以进行不同的标示。

注意:如果修改了db_unique_name的值,会影响到Service_names,也会影响到动态监听的service_name,因此,也应修改tnsnames.ora文件中service_name的服务名,否则,即使tnsping能通,但无法提供相应的服务。

-The End-

Written by ochef

May 19th, 2010 at 9:59 AM

Posted in Database

Tagged with ,

Oracle Restart

leave a comment

上一篇文章,我用同样的安装方法同样的配置成功了,也许还真是版本不兼容的问题。

[oracle@ora11gr2 ~]$ cat /etc/issue
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)

[oracle@ora11gr2 ~]$ uname -a
Linux ora11gr2 2.6.18-128.el5 #1 SMP Wed Jan 21 07:58:05 EST 2009 i686 i686 i386 GNU/Linux

[oracle@ora11gr2 ~]$ srvctl config database -d ora11gr2 -a
Database unique name: ora11gr2
Database name:
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile:
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups:
Services:
Database is enabled
[oracle@ora11gr2 ~]$

模拟了进程异常终止之后,restart将其启动的过程:

[oracle@ora11gr2 ~]$ srvctl start database -d ora11gr2
[oracle@ora11gr2 ~]$ ps -ef|grep ora_
oracle    4881     1  0 12:42 ?        00:00:00 ora_pmon_ora11gr2
oracle    4883     1  0 12:42 ?        00:00:00 ora_vktm_ora11gr2
oracle    4887     1  0 12:42 ?        00:00:00 ora_gen0_ora11gr2
oracle    4889     1  0 12:42 ?        00:00:00 ora_diag_ora11gr2
oracle    4891     1  0 12:42 ?        00:00:00 ora_dbrm_ora11gr2
oracle    4893     1  1 12:42 ?        00:00:00 ora_psp0_ora11gr2
oracle    4895     1  1 12:42 ?        00:00:00 ora_dia0_ora11gr2
oracle    4897     1 21 12:42 ?        00:00:03 ora_mman_ora11gr2
oracle    4899 1  0 12:42 ?        00:00:00 ora_dbw0_ora11gr2
oracle    4901     1  2 12:42 ?        00:00:00 ora_lgwr_ora11gr2
oracle    4903     1  0 12:42 ?        00:00:00 ora_ckpt_ora11gr2
oracle    4905     1  1 12:42 ?        00:00:00 ora_smon_ora11gr2
oracle    4907     1  0 12:42 ?        00:00:00 ora_reco_ora11gr2
oracle    4909     1  6 12:42 ?        00:00:00 ora_mmon_ora11gr2
oracle    4911     1  0 12:42 ?        00:00:00 ora_mmnl_ora11gr2
oracle    4913     1  0 12:42 ?        00:00:00 ora_d000_ora11gr2
oracle    4915     1  0 12:42 ?        00:00:00 ora_s000_ora11gr2
oracle    4985     1  0 12:42 ?        00:00:00 ora_p000_ora11gr2
oracle    4987     1  0 12:42 ?        00:00:00 ora_p001_ora11gr2
oracle    4989     1  0 12:42 ?        00:00:00 ora_qmnc_ora11gr2
oracle    5007     1  7 12:42 ?        00:00:00 ora_cjq0_ora11gr2
oracle    5011     1 34 12:42 ?        00:00:00 ora_j000_ora11gr2
oracle    5013     1  8 12:42 ?        00:00:00 ora_j001_ora11gr2
oracle    5015  3000  0 12:42 pts/0    00:00:00 grep ora_
[oracle@ora11gr2 ~]$ date
Wed Apr 21 12:42:59 CST 2010
[oracle@ora11gr2 ~]$ kill -9 4899
[oracle@ora11gr2 ~]$ ps -ef|grep ora_
oracle    5100     1 10 12:43 ?        00:00:00 ora_pmon_ora11gr2
oracle    5102     1 11 12:43 ?        00:00:00 ora_vktm_ora11gr2
oracle    5106     1  9 12:43 ?        00:00:00 ora_gen0_ora11gr2
oracle    5108     1  9 12:43 ?        00:00:00 ora_diag_ora11gr2
oracle    5110     1 10 12:43 ?        00:00:00 ora_dbrm_ora11gr2
oracle    5112     1  7 12:43 ?        00:00:00 ora_psp0_ora11gr2
oracle    5114  3000  0 12:43 pts/0    00:00:00 grep ora_
[oracle@ora11gr2 ~]$ ps -ef|grep ora_
oracle    5100     1  1 12:43 ?        00:00:00 ora_pmon_ora11gr2
oracle    5102     1  0 12:43 ?        00:00:00 ora_vktm_ora11gr2
oracle    5106     1  0 12:43 ?        00:00:00 ora_gen0_ora11gr2
oracle    5108     1  0 12:43 ?        00:00:00 ora_diag_ora11gr2
oracle    5110     1  1 12:43 ?        00:00:00 ora_dbrm_ora11gr2
oracle    5112     1  1 12:43 ?        00:00:00 ora_psp0_ora11gr2
oracle    5116     1  1 12:43 ?        00:00:00 ora_dia0_ora11gr2
oracle    5118     1 24 12:43 ?        00:00:02 ora_mman_ora11gr2
oracle    5120 1  1 12:43 ?        00:00:00 ora_dbw0_ora11gr2
oracle    5122     1  1 12:43 ?        00:00:00 ora_lgwr_ora11gr2
oracle    5124     1  1 12:43 ?        00:00:00 ora_ckpt_ora11gr2
oracle    5126     1  2 12:43 ?        00:00:00 ora_smon_ora11gr2
oracle    5128     1  0 12:43 ?        00:00:00 ora_reco_ora11gr2
oracle    5130     1  6 12:43 ?        00:00:00 ora_mmon_ora11gr2
oracle    5132     1  1 12:43 ?        00:00:00 ora_mmnl_ora11gr2
oracle    5134     1  0 12:43 ?        00:00:00 ora_d000_ora11gr2
oracle    5136     1  0 12:43 ?        00:00:00 ora_s000_ora11gr2
oracle    5206     1  2 12:43 ?        00:00:00 ora_p000_ora11gr2
oracle    5208     1  1 12:43 ?        00:00:00 ora_p001_ora11gr2
oracle    5210     1  1 12:43 ?        00:00:00 ora_qmnc_ora11gr2
oracle    5228     1  2 12:43 ?        00:00:00 ora_cjq0_ora11gr2
oracle    5232  3000  0 12:43 pts/0    00:00:00 grep ora_
[oracle@ora11gr2 ~]$ date
Wed Apr 21 12:43:35 CST 2010

这里你还可以参考kamus大师的文章。

-The End-

Written by ochef

April 21st, 2010 at 1:21 PM

Posted in Database

Tagged with ,

无觅相关文章插件,快速提升流量