最近在执行一个大数据量查询时报如下错误:
ORA-01114: IO error writing block to file 201 (block # 523913)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
OSD-04026: Invalid parameter passed. (OS 523927)
ORA-01114: IO error writing block to file 201 (block # 523913)
经查询file 201是临时表空间的第一个文件,该文件初始大小为2GB,自动扩展,每次扩展640K,当到达4G时出现以上错误。后来又测试了一下,发现在跨越8G时也会出现以上错误:
SQL> select * from v_offtake_profit_inv_national;
ERROR:
ORA-01114: IO error writing block to file 201 (block # 1048178)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
OSD-04026: Invalid parameter passed. (OS 1048192)
ORA-01114: IO error writing block to file 201 (block # 1048178)
ORA-27069: skgfdisp: attempt to do I/O beyond the range of the file
OSD-04026: Invalid parameter passed. (OS 1048192) (more…)
今天在SQL Server中attach数据库时出现如下错误:
错误5173 不能使文件与不同的数据库相关
该问题可以尝试用如下步骤解决:
1.新建一个同名的数据库
2.再停掉sql server(注意不要分离数据库)
3.用要附加的数据文件覆盖掉这个新建的数据库
4.再重启sql server
5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)
USE MASTER
GO
SP_CONFIGURE ‘ALLOW UPDATES’,1
GO
RECONFIGURE WITH OVERRIDE
GO
UPDATE SYSDATABASES SET STATUS =32768 WHERE NAME=’置疑的数据库名’
Go
sp_dboption ‘置疑的数据库名’, ’single user’, ‘true’
Go
DBCC CHECKDB(’置疑的数据库名’)
Go
update sysdatabases set status =28 where name=’置疑的数据库名’
Go
sp_configure ‘allow updates’, 0
GO
reconfigure with override
Go
sp_dboption ‘置疑的数据库名’, ’single user’, ‘false’
Go
6.完成后一般就可以访问数据库中的数据了,这时,数据库本身一般还要问题,解决办法是,利用数据库的脚本创建一个新的数据库,并将数据导进去就行了.
昨天同事在执行一个存储过程时报如下错误:
ERROR at line 1: ORA-06502: PL/SQL: numeric or value error ORA-06512: at “D_INSIGHT.CREATE_EXTEND_TABLE”, line 53
ORA-01653: unable to extend table D_INSIGHT.DMS_DSR_MAIN by 128 in tablespace USERS ORA-27059: skgfrsz: could not reduce file size
OSD-04005: SetFilePointer() failure, unable to read from file O/S-Error: (OS 112) There is not enough space on the disk.
ORA-06512: at line 1
查看了一下该表对应的表空间(该表空间为LMT,段空间管理为自动),发现文件使用率已经达到99.92%,文件大小为4G,但检查该表空间的数据文件,发现已经设置为自动扩展,文件大小限制为32767MB,再检查硬盘分区,还有4GB的空间,那就奇怪了,按道理 oracle 会自动扩展文件大小来增加空间…再看一下错误信息:OSD-04005: SetFilePointer() failure, unable to read from file O/S-Error: (OS 112) There is not enough space on the disk. (more…)
今天执行autotrace时,出现如下错误:
SQL> set autotrace on
SP2-0618: 无法找到会话标识符。启用检查 PLUSTRACE 角色
SP2-0611: 启用STATISTICS报告时出错
SQL> show user
USER 为”D_INSIGHT” –D_INSIGHT为普通用户
检查dba_role_privs:
SQL> conn sys/xxx@dd as sysdba
已连接。
SQL> select * from dba_role_privs where grantee=’D_INSIGHT’;
GRANTEE GRANTED_ROLE ADM DEF
—————————— —————————————————— —
D_INSIGHT PLUSTRACE NO NO
SQL> (more…)
今天一同事在用SQL Server的OPENROWSET函数从Excel中导数据到SQL Server时出现中文数据变成NULL,其语句是这样的:
select a.* from OPENROWSET(’Microsoft.JET.OLEDB.4.0′,
‘Excel 8.0;Database=c:\students.xls;’,
‘SELECT * FROM [sheet1$]‘) as a
执行结果如下:
学籍管理 F2 F3
—————————– —————————— ————————————————-
NULL NULL NULL
1.0 1234.0 23.0
2.0 1235.0 24.0
3.0 1234.0 25.0
4.0 1235.0 26.0
5.0 1234.0 27.0
6.0 1235.0 28.0
7.0 1234.0 29.0
8.0 1235.0 30.0
9.0 1234.0 31.0
10.0 1235.0 32.0
11.0 1234.0 33.0
12.0 1235.0 34.0
13.0 1234.0 35.0
14.0 1235.0 36.0
NULL NULL NULL
以上是测试数据
帮忙查了一些资料,原因是这样的:
当通过OLEDB来读取Excel数据时,默认情况是将注册表中HKLM\Software\Microsoft\Jet\4.0\Engines\Excel\TypeGuessRows的值(该值默认是8)作为判断数据类型的行数,根据这些行数中最常被发现的数据类型来决定数据类型。如果有限制,将由下列顺序来决定数据类型:Number, Currency, Date, Text, Long Text 。如果遇到的数据不符合字段的推测的数据类型时,它会作为 Null 值返回。在导入时,如果一个字段有混合数据类型,整个字段将根据 ImportMixedTypes 设置来转换。
对于上述例子,根据上面的规则,把数字类型作为主要的数据类型进行导入,而中文数据不符合该推断的数据类型,所以返回NULL。
那么如何解决该问题呢?
看上面粗体红色部分,如果把读取数据的模式设置成导入模式,那么整个字段就会根据ImportMixedTypes指定的类型来转换。在OLEDB中,可以指定连接字串扩展属性来指定模式,这个属性就是IMEX,意义如下:
0 is Export mode
1 is Import mode
2 is Linked mode (full update capabilities)
所以指定IMEX=1即可解决问题:
select a.* from OPENROWSET(’Microsoft.JET.OLEDB.4.0′,
‘Excel 8.0;Database=c:\students.xls;IMEX=1′,
‘SELECT * FROM [sheet1$]‘) as a
学籍管理 F2 F3
—————————– —————————— ————————————————-
姓名 序号 年龄
1.0 1234.0 23.0
2.0 1235.0 24.0
3.0 1234.0 25.0
4.0 1235.0 26.0
5.0 1234.0 27.0
6.0 1235.0 28.0
7.0 1234.0 29.0
8.0 1235.0 30.0
9.0 1234.0 31.0
10.0 1235.0 32.0
11.0 1234.0 33.0
12.0 1235.0 34.0
13.0 1234.0 35.0
14.0 1235.0 36.0
OLEDB for Excel连接字串还有另外一个扩展属性HDR(Header Row),表示是否将第一行当作栏位。
附:
1.OLEDB for excel参数说明
win32 Msexcl35.dll 的位置。这个完整路径在安装时就已确定。
TypeGuessRows 被检查数据类型的行数。根据在选择中最常被发现的数据类型来决定数据类型。如果有限制,将由下列顺序来决定数据类型:Number, Currency, Date, Text, Long Text 。如果遇到的数据不符合字段的推测的数据类型时,它会作为 Null 值返回。在导入时,如果一个字段有混合数据类型,整个字段将根据 ImportMixedTypes 设置来转换。被检查的行数缺省值是 8。
ImportMixedTypes 可以被设置成 Majority Type 或是 Text。如果设置成 Majority Type,混合数据类型的字段将会在导入时改变成占主导地位的数据类型。如果设置成 Text,混合数据类型的字段将在导入时改变成 Text 的数据类型。缺省值是 Text。
AppendBlankRows 在增加新数据前,添加至 3.5 版或 4.0 版工作表末端的空白行数。例如,如果 AppendBlankRows 设置成 4,Microsoft Jet 将在增加包含数据的行之前添加 4 行空白至工作表末端。此设置的整型值范围从 0 到 16;缺省值是 01(追加一附加行)。
FirstRowHasNames 指示表的第一行是否包含字段名的二进制值。01 的值指示在导入期间将从第一行取得字段名。00 的值指示在第一行中没有字段名;字段名显示为 F1、F2、F3等等。缺省值是 1。
2.参考文档
http://support.microsoft.com/default.aspx?kbid=194124
1.vmstat
vmstat是Virtual Meomory Statistics(虚拟内存统计)的缩写,可用来纪录 processes, memory, paging, block IO, traps, 与 cpu activity
[root@raclinux1 ~]# vmstat –help
usage: vmstat [-V] [-n] [delay [count]]
-V prints version.
-n causes the headers not to be reprinted regularly.
-a print inactive/active page stats.
-d prints disk statistics
-D prints disk table
-p prints disk partition statistics
-s prints vm table
-m prints slabinfo
-S unit size
delay is the delay between updates in seconds.
unit size k:1000 K:1024 m:1000000 M:1048576 (default is K)
count is the number of updates.
其中红色部分是新选项,2.5.70及以上内核适用
2.举例:
[ oracle @raclinux1 ~]$ vmstat 3
procs —————–memory—————swap– —–io—- –system– —-cpu—-
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 1672 29032 108664 0 0 66 16 1012 259 2 7 87 3
0 0 0 1672 29040 108664 0 0 0 11 930 199 1 4 95 0
0 0 0 1676 29040 108664 0 0 0 39 949 202 1 3 96 0
0 0 0 1680 29048 108664 0 0 0 4 937 199 1 3 96 0
0 0 0 1680 29048 108664 0 0 0 25 932 198 1 4 95 0
0 0 0 1680 29056 108664 0 0 0 4 944 206 1 3 96 0
0 0 0 1680 29056 108664 0 0 0 0 932 198 1 3 96 0
0 0 0 1680 29064 108664 0 0 0 4 935 196 1 3 96 0
0 0 0 1680 29064 108664 0 0 0 0 941 198 1 3 96 0
0 0 0 1680 29072 108664 0 0 0 4 949 202 1 2 96 0
0 0 0 1680 29072 108664 0 0 0 0 938 196 1 3 96 0
其中:
Procs
r: The number of processes waiting for run time.
b: The number of processes in uninterruptible sleep.
Memory
swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (-a option)
active: the amount of active memory. (-a option)
Swap
si: Amount of memory swapped in from disk (/s).
so: Amount of memory swapped to disk (/s).
IO
bi: Blocks received from a block device (blocks/s).
bo: Blocks sent to a block device (blocks/s).
System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.
CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.
3.解读:
A.CPU问题:
下面几列需要被察看,以确定cpu是否有问题
Processes in the run queue (procs r)
User time (cpu us)
System time (cpu sy)
Idle time (cpu id)
问题情况:
1.) 如果processes in run queue (procs r)的数量远大于系统中cpu的数量,将会使系统便慢。
2.) 如果这个数量是cpu的4倍的话,说明系统正面临cpu能力短缺,这将使系统运行速度大幅度降低
3.) 如果cpu的idle时间经常为0的话,或者系统占用时间(cpu sy)是用户占用时间(cpu us)两辈的话,系统面临缺少cpu资源
解决方案 :
解决这些情况,涉及到调整应用程序,使其能更有效的使用cpu,同时增加cpu的能力或数量
B.内存问题:
主要查看页导入的数值(swap中的si),如果该值比较大就要考虑内存,大概方法如下:
1).最简单的,加大RAM
2).改小SGA,使得对RAM需求减少
3).减少RAM的需求(如:减少PGA)
4.新参数:
1).vmstat -D 显示磁盘信息(只能一次性,delay参数无效)
[ oracle @raclinux1 ~]$ vmstat -D
25 disks
6 partitions
17577 total reads
4140 merged reads
587320 read sectors
248149 milli reading
6889 writes
13672 merged writes
164444 written sectors
167353 milli writing
0 inprogress IO
178 milli spent IO
2).vmstat -d 查看磁盘统计信息
[ oracle @raclinux1 ~]$ vmstat -d | grep -v ram
disk- ————reads———— ————writes———– —–IO——
total merged sectors ms total merged sectors ms cur sec
hdc 13 88 680 249 0 0 0 0 0 0
sda 17396 2644 580819 243635 6983 13749 165836 167797 0 178
sdb 46 657 1185 1808 0 0 0 0 0 0
sdc 53 420 1436 1667 6 4 56 7 0 1
sdd 24 132 1248 348 0 0 0 0 0 0
disk- ————reads———— ————writes———– —–IO——
total merged sectors ms total merged sectors ms cur sec
sde 36 135 1368 288 0 0 0 0 0 0
sdf 9 64 584 154 0 0 0 0 0 0
fd0 0 0 0 0 0 0 0 0 0 0
md0 0 0 0 0 0 0 0 0 0 0
3).vmstat -s (一次性,delay参数无效)
[ oracle @raclinux1 ~]$ vmstat -s
256044 total memory
254428 used memory
153584 active memory
70960 inactive memory
1616 free memory
33976 buffer memory
104140 swap cache
1044184 total swap
0 used swap
1044184 free swap
13214 non-nice user cpu ticks
3759 nice user cpu ticks
43122 system cpu ticks
827934 idle cpu ticks
14246 IO-wait cpu ticks
98 IRQ cpu ticks
27960 softirq cpu ticks
293660 pages paged in
83714 pages paged out
0 pages swapped in
0 pages swapped out
9369649 interrupts
2217323 CPU context switches
1143195570 boot time
29804 forks
oracle 常见事件如下:
10000 control file debug event, name ‘control_file’
10001 control file crash event1
10002 control file crash event2
10003 control file crash event3
10004 control file crash event4
10005 trace latch operations for debugging
10006 testing - block recovery forced
10007 log switch debug crash after new log select, thread %s
10008 log switch debug crash after new log header write, thread %s
10009 log switch debug crash after old log header write, thread %s
10010 Begin Transaction
10011 End Transaction
10012 Abort Transaction
10013 Instance Recovery
10014 Roll Back to Save Point
10015 Undo Segment Recovery
10016 Undo Segment extend
10017 Undo Segment Wrap
10018 Data Segment Create
10019 Data Segment Recovery
10020 partial link restored to linked list (KSG)
10021 latch cleanup for state objects (KSS) (more…)
Recent Comments: