[20180226]alter system archive log current.txt
--//当日志写满以后,切换日志归档大部分由归档进程ARCH负责将在线重做日志归档.
--//如果手工执行alter system archive log current,alter system switch logfie切换日志时,两者存在不同.
--//通过测试说明问题:
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SYS@book> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archivelog/book/
Oldest online log sequence 707
Next log sequence to archive 709
Current log sequence 709
2.测试:
SCOTT@book> @ &r/spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
274 11 10422 DEDICATED 10423 21 6 alter system kill session '274,11' immediate;
--//进程=10423
--//产生一些日志.
SYS@book> @ &r/currredo
Current log sequence No Percent Full bytes used exclude header Left space logfile size
----------------------- ------------ ------------------------- ---------- ------------
709 4.89941406 2568192 49860096 52428800
$ strace -f -p 10423 -o /tmp/sw.log
...
SCOTT@book> alter system archive log current ;
System altered.
$ strace -f -p 10423 -o /tmp/sw.log
Process 10423 attached - interrupt to quit
^CProcess 10423 detached
3.检查跟踪文件:
SCOTT@book> show parameter log_archive_dest_1
NAME TYPE VALUE
------------------ ------ -----------------------------------------------------------------------------------------------------------
log_archive_dest_1 string LOCATION=/u01/app/oracle/archivelog/book/ MANDATORY VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=book
$ ls -l /u01/app/oracle/archivelog/book/1_709_896605872.dbf
-rw-r----- 1 oracle oinstall 2594304 2018-02-26 09:43:10 /u01/app/oracle/archivelog/book/1_709_896605872.dbf
--//检查跟踪文件.
10423 lstat("/u01", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed99e40) = -1 ENOENT (No such file or directory)
10423 lstat("/u01", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 stat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 open("/u01/app/oracle/archivelog/book", O_RDONLY) = 11
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430009, f_bavail=58839499, f_files=411828224, f_ffree=411767731, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 stat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 close(11) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed9aec8) = -1 ENOENT (No such file or directory)
10423 lstat("/u01", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed99d60) = -1 ENOENT (No such file or directory)
10423 lstat("/u01", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 lstat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 stat("/u01/app/oracle/archivelog/book", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
10423 open("/u01/app/oracle/archivelog/book", O_RDONLY) = 11
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430009, f_bavail=58839499, f_files=411828224, f_ffree=411767731, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 stat("/u01/app/oracle/archivelog", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
10423 close(11) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 open("/etc/mtab", O_RDONLY) = 11
10423 fstat(11, {st_mode=S_IFREG|0644, st_size=392, ...}) = 0
10423 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f611b15c000
10423 read(11, "/dev/cciss/c0d0p2 / ext3 rw 0 0\n"..., 4096) = 392
10423 read(11, "", 4096) = 0
10423 close(11) = 0
10423 munmap(0x7f611b15c000, 4096) = 0
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed9afa8) = -1 ENOENT (No such file or directory)
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed9b0c0) = -1 ENOENT (No such file or directory)
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR|O_CREAT|O_EXCL|O_SYNC, 0660) = 11
10423 fstat(11, {st_mode=S_IFREG|0640, st_size=0, ...}) = 0
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430009, f_bavail=58839499, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 lseek(11, 0, SEEK_SET) = 0
10423 write(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 ftruncate(11, 2594304) = 0
10423 close(11) = 0
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {st_mode=S_IFREG|0640, st_size=2594304, ...}) = 0
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {st_mode=S_IFREG|0640, st_size=2594304, ...}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDONLY) = 11
10423 ioctl(11, BLKSSZGET, 0x7fff0ed92c98) = -1 ENOTTY (Inappropriate ioctl for device)
10423 close(11) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDONLY) = 11
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 lseek(11, 0, SEEK_SET) = 0
10423 read(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
10423 close(11) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR) = 11
10423 getrlimit(RLIMIT_NOFILE, {rlim_cur=64*1024, rlim_max=64*1024}) = 0
10423 fcntl(11, F_DUPFD, 256) = 263
10423 close(11) = 0
10423 fcntl(263, F_SETFD, FD_CLOEXEC) = 0
10423 fstatfs(263, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 fcntl(263, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
10423 fcntl(263, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 stat("/mnt/ramdisk/book/redo03.log", {st_mode=S_IFREG|0640, st_size=52429312, ...}) = 0
10423 stat("/mnt/ramdisk/book/redo03.log", {st_mode=S_IFREG|0640, st_size=52429312, ...}) = 0
10423 statfs("/mnt/ramdisk/book/redo03.log", {f_type=0x1021994, f_bsize=4096, f_blocks=2097152, f_bfree=1075079, f_bavail=1075079, f_files=16532649, f_ffree=16532631, f_fsid={0, 0}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/mnt/ramdisk/book/redo03.log", O_RDONLY) = 11
10423 lseek(11, 0, SEEK_SET) = 0
10423 read(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0g\310\0\0\0\2\0\0\0\220\1\0}|{z"..., 4096) = 4096
10423 close(11) = 0
10423 pread(262, "\1\"\0\0\1\0\0\0\305\2\0\0\0\200\"\213\0\0\0\0\0\4 \vn!\267OBOOK"..., 1048064, 512) = 1048064
10423 pwrite(263, "\1\"\0\0\1\0\0\0\305\2\0\0\0\200\3\213\0\0\0\0\0\4 \vn!\267OBOOK"..., 1048064, 512) = 1048064
10423 pread(262, "\1\"\0\0\0\10\0\0\305\2\0\0\0\200'\16 daaaa"..., 1048576, 1048576) = 1048576
10423 pwrite(263, "\1\"\0\0\0\10\0\0\305\2\0\0\0\200'\16 daaaa"..., 1048576, 1048576) = 1048576
10423 pread(262, "\1\"\0\0\0\20\0\0\305\2\0\0\0\200\16= "..., 497152, 2097152) = 497152
10423 pread(262, "\1\"\0\0\313\23\0\0\277\2\0\0\330\200\217l\5\1$\0\3\0\377\377f\35\300\0\276\375]\27"..., 4096, 2594304) = 4096
10423 pwrite(263, "\1\"\0\0\0\20\0\0\305\2\0\0\0\200\16= "..., 497152, 2097152) = 497152
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {st_mode=S_IFREG|0640, st_size=2594304, ...}) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79429374, f_bavail=58838864, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR) = 11
10423 lseek(11, 0, SEEK_SET) = 0
10423 write(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
10423 ftruncate(11, 2594304) = 0
10423 close(11) = 0
10423 fcntl(263, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 fcntl(263, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
10423 fcntl(263, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {st_mode=S_IFREG|0640, st_size=2594304, ...}) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79429374, f_bavail=58838864, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR) = 11
10423 lseek(11, 0, SEEK_SET) = 0
10423 write(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
10423 ftruncate(11, 2594304) = 0
10423 close(11) = 0
10423 fcntl(263, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 fcntl(263, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
10423 fcntl(263, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 fcntl(263, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=0}) = 0
10423 fsync(263) = 0
10423 close(263) = 0
10423 close(262) = 0
10423 pread(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4 \275\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
10423 pread(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4 \275\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
10423 pread(256, "\25\302\0\0\20\0\0\0007\216\0\0\377\377\1\4\273\n\0\0\200\2\0\0\0\0\0\0\0\0\0D"..., 16384, 262144) = 16384
10423 pread(256, "\25\302\0\0\22\0\0\0007\216\0\0\377\377\1\4\3&\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 294912) = 16384
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 pread(256, "\25\302\0\0\26\0\0\0007\216\0\0\377\377\1\4\335C\0\0\0\220\1\0\306\2\0\0\1\0\0\0"..., 16384, 360448) = 16384
10423 pread(256, "\25\302\0\0T\2\0\0\326\213\0\0\377\377\1\4\215\247\0\0+\1\0\0T\0\0\0\177Q\3157"..., 16384, 9764864) = 16384
10423 pread(256, "\25\302\0\0Z\2\0\0004\216\0\0\377\377\1\4\361\323\0\0)\363\3009\n\5\1\0\273\2\0\0"..., 16384, 9863168) = 16384
10423 pread(256, "\25\302\0\0\31\1\0\0000\216\0\0\377\377\1\4\356z\0\0\32\1\2\0\342\7\0\0\0\0\0\0"..., 16384, 4603904) = 16384
10423 pread(256, "\25\302\0\0T\2\0\0\326\213\0\0\377\377\1\4\215\247\0\0+\1\0\0T\0\0\0\177Q\3157"..., 16384, 9764864) = 16384
10423 pread(256, "\25\302\0\0Z\2\0\0004\216\0\0\377\377\1\4\361\323\0\0)\363\3009\n\5\1\0\273\2\0\0"..., 16384, 9863168) = 16384
10423 pread(256, "\25\302\0\0004\1\0\0.\216\0\0\377\377\1\4Hl\0\0\0@;\1\0\0\0\0\0\0\227\0"..., 16384, 5046272) = 16384
10423 pread(256, "\25\302\0\0T\2\0\0\326\213\0\0\377\377\1\4\215\247\0\0+\1\0\0T\0\0\0\177Q\3157"..., 16384, 9764864) = 16384
10423 pread(256, "\25\302\0\0Z\2\0\0004\216\0\0\377\377\1\4\361\323\0\0)\363\3009\n\5\1\0\273\2\0\0"..., 16384, 9863168) = 16384
10423 lstat("/u01/app/oracle/diag/rdbms/book/book/alert/log.xml", {st_mode=S_IFREG|0640, st_size=10065509, ...}) = 0
10423 stat("/u01/app/oracle/diag/rdbms/book/book/alert/log.xml", {st_mode=S_IFREG|0640, st_size=10065509, ...}) = 0
10423 lstat("/u01/app/oracle/diag/rdbms/book/book/alert/log.xml", {st_mode=S_IFREG|0640, st_size=10065509, ...}) = 0
10423 open("/u01/app/oracle/diag/rdbms/book/book/alert/log.xml", O_WRONLY|O_CREAT|O_APPEND, 0660) = 11
10423 fcntl(11, F_SETFD, FD_CLOEXEC) = 0
10423 write(11, "<msg time='2018-02-26T09:43:10.2"..., 292) = 292
10423 close(11) = 0
10423 stat("/u01/app/oracle/diag/rdbms/book/book/alert/log.xml", {st_mode=S_IFREG|0640, st_size=10065801, ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 lstat("/u01/app/oracle/diag/rdbms/book/book/trace/alert_book.log", {st_mode=S_IFREG|0640, st_size=2242370, ...}) = 0
10423 open("/u01/app/oracle/diag/rdbms/book/book/trace/alert_book.log", O_WRONLY|O_CREAT|O_APPEND, 0660) = 11
10423 fcntl(11, F_SETFD, FD_CLOEXEC) = 0
10423 write(11, "Archived Log entry 1259 added fo"..., 77) = 77
10423 write(11, "\n", 1) = 1
10423 close(11) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 pread(256, "\25\302\0\0\26\0\0\0007\216\0\0\377\377\1\4\335C\0\0\0\220\1\0\306\2\0\0\1\0\0\0"..., 16384, 360448) = 16384
10423 pwrite(256, "\25\302\0\0Y\2\0\0008\216\0\0\377\377\1\4\0J\0\0)\363\3009\n\5\1\0\273\2\0\0"..., 16384, 9846784) = 16384
10423 pwrite(257, "\25\302\0\0Y\2\0\0008\216\0\0\377\377\1\4\0J\0\0)\363\3009\n\5\1\0\273\2\0\0"..., 16384, 9846784) = 16384
10423 pwrite(256, "\25\302\0\0\25\0\0\0008\216\0\0\377\377\1\4\335C\0\0\0\220\1\0\306\2\0\0\1\0\0\0"..., 16384, 344064) = 16384
10423 pwrite(257, "\25\302\0\0\25\0\0\0008\216\0\0\377\377\1\4\335C\0\0\0\220\1\0\306\2\0\0\1\0\0\0"..., 16384, 344064) = 16384
10423 pwrite(256, "\25\302\0\0\21\0\0\0008\216\0\0\377\377\1\4\2&\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
10423 pwrite(257, "\25\302\0\0\21\0\0\0008\216\0\0\377\377\1\4\2&\0\0\0\0\0\0\0\0\0\0\256\36q5"..., 16384, 278528) = 16384
10423 pwrite(256, "\25\302\0\0\17\0\0\0008\216\0\0\377\377\1\4$\0\0\0\0\0\0\0\0\0\0\0\0\0\0D"..., 16384, 245760) = 16384
10423 pwrite(257, "\25\302\0\0\17\0\0\0008\216\0\0\377\377\1\4$\0\0\0\0\0\0\0\0\0\0\0\0\0\0D"..., 16384, 245760) = 16384
10423 pwrite(256, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4 \275\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
10423 pwrite(257, "\25\302\0\0\1\0\0\0\0\0\0\0\0\0\1\4 \275\0\0\0\0\0\0\0\4 \vn!\267O"..., 16384, 16384) = 16384
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 uname({sys="Linux", node="gxqyydg4", ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497018
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 semctl(222625793, 17, SETVAL, 0x1) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 182972}, ru_stime={0, 73988}, ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 183972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 183972}, ru_stime={0, 73988}, ...}) = 0
10423 getrusage(RUSAGE_SELF, {ru_utime={0, 183972}, ru_stime={0, 73988}, ...}) = 0
10423 times({tms_utime=18, tms_stime=7, tms_cutime=0, tms_cstime=0}) = 7418497019
10423 write(10, "\0\265\0\0\6\0\0\0\0\0\10\6\0\3255^\27\3\0\0\0\2\0\0\0\0\0\0\0\0\0\0"..., 181) = 181
10423 read(7, <unfinished ...>
$ grep 'pwrite(263' /tmp/sw.log
10423 pwrite(263, "\1\"\0\0\1\0\0\0\305\2\0\0\0\200\3\213\0\0\0\0\0\4 \vn!\267OBOOK"..., 1048064, 512) = 1048064
10423 pwrite(263, "\1\"\0\0\0\10\0\0\305\2\0\0\0\200'\16 daaaa"..., 1048576, 1048576) = 1048576
10423 pwrite(263, "\1\"\0\0\0\20\0\0\305\2\0\0\0\200\16= "..., 497152, 2097152) = 497152
$ ls -l /u01/app/oracle/archivelog/book/1_709_896605872.dbf
-rw-r----- 1 oracle oinstall 2594304 2018-02-26 09:43:10 /u01/app/oracle/archivelog/book/1_709_896605872.dbf
--//生成文件大小2594304.
$ man pwrite
PREAD(2) Linux Programmer's Manual PREAD(2)
NAME
pread, pwrite - read from or write to a file descriptor at a given offset
SYNOPSIS
#define _XOPEN_SOURCE 500
#include <unistd.h>
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
--//1048064+1048576+497152 = 2593792
--//2593792-2594304 = -512
--//前面的512字节,os头写入是看前面的命令,开始写入的.
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed9afa8) = -1 ENOENT (No such file or directory)
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", 0x7fff0ed9b0c0) = -1 ENOENT (No such file or directory)
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR|O_CREAT|O_EXCL|O_SYNC, 0660) = 11
10423 fstat(11, {st_mode=S_IFREG|0640, st_size=0, ...}) = 0
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430009, f_bavail=58839499, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 lseek(11, 0, SEEK_SET) = 0
10423 write(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10423 fstatfs(11, {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79430008, f_bavail=58839498, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 ftruncate(11, 2594304) = 0
10423 close(11) = 0
....
10423 stat("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {st_mode=S_IFREG|0640, st_size=2594304, ...}) = 0
10423 statfs("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", {f_type="EXT2_SUPER_MAGIC", f_bsize=4096, f_blocks=398913534, f_bfree=79429374, f_bavail=58838864, f_files=411828224, f_ffree=411767730, f_fsid={2019274029, -1076953238}, f_namelen=255, f_frsize=4096}) = 0
10423 open("/u01/app/oracle/archivelog/book/1_709_896605872.dbf", O_RDWR) = 11
10423 lseek(11, 0, SEEK_SET) = 0
10423 write(11, "\0\"\0\0\0\0\300\377\0\0\0\0\0\0\0\0\254K\0\0\0\2\0\0\312\23\0\0}|{z"..., 512) = 512
10423 ftruncate(11, 2594304) = 0
10423 close(11) = 0
--//最后完成后在写入一次.
--//你可以发现3次调用ftruncate(11, 2594304) = 0
$ xxd -c 16 /u01/app/oracle/archivelog/book/1_709_896605872.dbf | head -2
0000000: 0022 0000 0000 c0ff 0000 0000 0000 0000 ."....?........
0000010: ac4b 0000 0002 0000 ca13 0000 7d7c 7b7a .K......?..}|{z
--//strace 使用8进制,对比可以发现是一致的.
--//0300(八进制) = 3*8*8= 192 = 0xc0
--//0254 = 2*64+8*5+4 = 172 = 0xac.
3.如果执行alter system switch logfile ;
SCOTT@book> alter system switch logfile ;
System altered.
SCOTT@book> alter system switch logfile ;
System altered.
SCOTT@book> select dest_id,name,sequence#,creator from V$ARCHIVED_LOG where sequence#>=709 and dest_id=1;
DEST_ID NAME SEQUENCE# CREATOR
---------- ---------------------------------------------------- ---------- -------
1 /u01/app/oracle/archivelog/book/1_709_896605872.dbf 709 FGRD
1 /u01/app/oracle/archivelog/book/1_710_896605872.dbf 710 ARCH
1 /u01/app/oracle/archivelog/book/1_711_896605872.dbf 711 ARCH
--//参考我以前写的http://blog.itpub.net/267265/viewspace-1711428/ => [20150625]v$archived_log字段creator.txt
REATOR VARCHAR2(7) Creator of the archivelog:
ARCH - Archiver process
FGRD - Foreground process
RMAN - Recovery Manager
SRMN - RMAN at standby
LGWR - Logwriter process
--//也做一次跟踪看看:
$ strace -f -p 10423 -o /tmp/sw1.log
SCOTT@book> alter system switch logfile ;
System altered.
$ strace -f -p 10423 -o /tmp/sw1.log
Process 10423 attached - interrupt to quit
^CProcess 10423 detached
$ egrep -e 'read|write' /tmp/sw1.log
10423 read(7, "\0015\0\0\6\0\0\0\0\0\21iH\376\377\377\377\377\377\377\377\1\0\0\0\0\0\0\0\2\0\0"..., 8208) = 309
10423 write(10, "\0\265\0\0\6\0\0\0\0\0\10\6\0\317A^\27\3\0\0\0\7\0\0\0\0\0\0\0\0\0\0"..., 181) = 181
10423 read(7, <unfinished ...>
--//前台进程看不到读写.