2010年3月19日星期五

如何查找redo file?

備忘一下

SQL> select group#, members, status from v$log;

    GROUP#    MEMBERS STATUS
---------- ---------- ----------------
         1          2 INACTIVE
         2          2 CURRENT
         3          2 INACTIVE
         4          2 CURRENT

 

SQL> desc v$logfile
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
GROUP#                                             NUMBER
STATUS                                             VARCHAR2(7)
TYPE                                               VARCHAR2(7)
MEMBER                                             VARCHAR2(513)
IS_RECOVERY_DEST_FILE                              VARCHAR2(3)

SQL> col member for a30
SQL> select * from v$logfile;

 

SQL> set linesize 300
SQL> /

    GROUP# STATUS  TYPE    MEMBER                         IS_
---------- ------- ------- ------------------------------ ---
         1         ONLINE  +CRPROD_DATA/crprod/onlinelog/ NO
                           group_1.257.686193451

         1         ONLINE  +FLASH_RECOVERY_AREA/crprod/on YES
                           linelog/group_1.257.686193459

         2         ONLINE  +CRPROD_DATA/crprod/onlinelog/ NO
                           group_2.258.686193481

         2         ONLINE  +FLASH_RECOVERY_AREA/crprod/on YES
                           linelog/group_2.258.686193491

    GROUP# STATUS  TYPE    MEMBER                         IS_
---------- ------- ------- ------------------------------ ---

         3         ONLINE  +CRPROD_DATA/crprod/onlinelog/ NO
                           group_3.265.686198773

         3         ONLINE  +FLASH_RECOVERY_AREA/crprod/on YES
                           linelog/group_3.259.686198787

         4         ONLINE  +CRPROD_DATA/crprod/onlinelog/ NO
                           group_4.266.686198801

         4         ONLINE  +FLASH_RECOVERY_AREA/crprod/on YES

    GROUP# STATUS  TYPE    MEMBER                         IS_
---------- ------- ------- ------------------------------ ---
                           linelog/group_4.260.686198809

8 rows selected.

2010年3月17日星期三

solaris 7 force umount cmd

在一個超級古老的機器上mount 了一個nfs, 但是nfs server移除以後就沒有辦法 umount 這個目錄了

umount /backup

報錯如下:

nfs umount: /backup: is busy


怎麼辦呢?



google了一下,使用如下命令可以幹掉



Solaris 2.6 and Solaris 7: umount -o force /mount-point



試用了一下, 還是報錯



不過df -k的時候 發現已經很順暢了,感覺已經去掉了



當然還有另一種辦法



try following ...

unshare /backup
umount /backup


沒有測試過,等下次有機會測試一下



記錄一下備忘!

2010年3月5日星期五

How to Delete a node from RAC test

在測試環境中做一個一個RAC delete node的實驗記錄一下

環境是vmware

OS: OEL 5.2

DB: oracle 11gR1

 

http://docs.google.com/Doc?docid=0AbicX7azhQtmZGs3NzQ2Ml85NjBmbWMyZjRjZw&hl=en

2010年3月3日星期三

Awk 做url

學習了一個小技巧

ls | awk '{print "<a href="$0">"$0"</a><br />"}' > index.html 

將目錄下的東西寫道成href

ref:

http://ithelp.ithome.com.tw/question/10021489

2010年3月2日星期二

BBED complie

發現一個有用的工具BBED,處理壞塊使用的, 根據網上提供的方法,自己做了一個實驗:

我的環境是openSolaris 其他的*nix也是類似

1,源文件在哪裡?

cd $ORACLE_HOME

 

oracle@opensolaris:/opt/oracle/product/10.2.0/db_1$ find . -name ins_rdbms.mk
./rdbms/lib/ins_rdbms.mk

2,編譯:

oracle@opensolaris:/opt/oracle/product/10.2.0/db_1/rdbms/lib$ make -f ins_rdbms.mk /opt/oracle/product/10.2.0/db_1/rdbms/lib/bbed

Linking BBED utility (bbed)
rm -f /opt/oracle/product/10.2.0/db_1/rdbms/lib/bbed
/usr/ccs/bin/ld -64 -o /opt/oracle/product/10.2.0/db_1/rdbms/lib/bbed -L/opt/oracle/product/10.2.0/db_1/rdbms/lib/ -L/opt/oracle/product/10.2.0/db_1/lib/ -dy /opt/oracle/product/10.2.0/db_1/lib/prod/lib/amd64/crti.o /opt/oracle/product/10.2.0/db_1/lib/prod/lib/amd64/crt1x.o /opt/oracle/product/10.2.0/db_1/lib/s0main.o /opt/oracle/product/10.2.0/db_1/rdbms/lib/ssbbded.o /opt/oracle/product/10.2.0/db_1/rdbms/lib/sbbdpt.o `cat /opt/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 /opt/oracle/product/10.2.0/db_1/rdbms/lib/defopt.o  -ldbtools10 -lclntsh  `cat /opt/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10  -lvsn10  -lcommon10 -lgeneric10 -lmm -lsnls10 -lnls10  -lcore10 -lsnls10  -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10  -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /opt/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /opt/oracle/product/10.2.0/db_1/lib/ldflags`    -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10  -lvsn10  -lcommon10 -lgeneric10   -lsnls10 -lnls10  -lcore10 -lsnls10  -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10  -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10  -lclient10 -lnnetd10  -lvsn10  -lcommon10 -lgeneric10 -lsnls10 -lnls10  -lcore10 -lsnls10  -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10  -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10   `cat /opt/oracle/product/10.2.0/db_1/lib/sysliblist` -R /opt/SUNWcluster/lib:/opt/oracle/product/10.2.0/db_1/lib:/opt/ORCLcluster/lib/  -Y P,:/opt/SUNWcluster/lib:/opt/ORCLcluster/lib/:/usr/ccs/lib/amd64:/usr/lib/amd64  -Qy -lc  -lrt  -laio -lposix4 -lkstat -lm  /opt/oracle/product/10.2.0/db_1/lib/prod/lib/amd64/crtn.o

驗證一下:

oracle@opensolaris:/opt/oracle/product/10.2.0/db_1/rdbms/lib$ ls -al bbed
-rwxr-xr-x 1 oracle oinstall 862016 2010-03-03 10:06 bbed

執行

oracle@opensolaris:/opt/oracle/product/10.2.0/db_1/rdbms/lib$ ./bbed
Password:(blockedit 為default password)

BBED: Release 2.0.0.0.0 - Limited Production on Wed Mar 3 10:07:15 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED>

這個工具是內部人員使用的哦

BBED> help all
SET DBA [ dba | file#, block# ]
SET FILENAME 'filename'
SET FILE file#
SET BLOCK [+/-]block#
SET OFFSET [ [+/-]byte offset | symbol | *symbol ]
SET BLOCKSIZE bytes
SET LIST[FILE] 'filename'
SET WIDTH character_count
SET COUNT bytes_to_display
SET IBASE [ HEX | OCT | DEC ]
SET OBASE [ HEX | OCT | DEC ]
SET MODE  [ BROWSE | EDIT ]
SET SPOOL [ Y | N ]
SHOW [ <SET parameter> | ALL ]
INFO
MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]
DUMP[/v] [ DBA | FILENAME | FILE | BLOCK | OFFSET | COUNT ]
PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
EXAMINE[/Nuf] [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
</Nuf>:
N - a number which specifies a repeat count.
u - a letter which specifies a unit size:
  b - b1, ub1 (byte)
  h - b2, ub2 (half-word)
  w - b4, ub4(word)
  r - Oracle table/index row
f - a letter which specifies a display format:
  x - hexadecimal
  d - decimal
  u - unsigned decimal
  o - octal
  c - character (native)
  n - Oracle number
  t - Oracle date
  i - Oracle rowid
FIND[/x|d|u|o|c] numeric/character string [ TOP | CURR ]
COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]
MODIFY[/x|d|u|o|c] numeric/character string
      [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
ASSIGN[/x|d|u|o] <target spec>=<source spec>
<target spec> : [ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]
<source spec> : [ value | <target spec options> ]
SUM [ DBA | FILE | FILENAME | BLOCK ] [ APPLY ]
PUSH [ DBA | FILE | FILENAME | BLOCK | OFFSET ]
POP [ALL]
REVERT [ DBA | FILE | FILENAME | BLOCK ]
UNDO
HELP [ <bbed command> | ALL ]
VERIFY [ DBA | FILE | FILENAME | BLOCK ]
CORRUPT [ DBA | FILE | FILENAME | BLOCK ]

BBED>

記錄一下,備忘,繼續學習!

ref:

http://www.databasejournal.com/features/oracle/article.php/3835546/Installing-Oracle-Block-Browser-and-Editor-tool-bbed.htm

http://www.eygle.com/archives/2005/09/how_to_compile.html

add a disk to linux

在xen上增加一個disk,當人是vritual的:)


[root@Mocktrade dev]# fdisk /dev/xvdb  # xvdb 難道xen下的disk都是xvdx嗎?
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 4895.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4895, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4895, default 4895):
Using default value 4895
Command (m for help): p
Disk /dev/xvdb: 40.2 GB, 40265318400 bytes
255 heads, 63 sectors/track, 4895 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        4895    39319056   83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@ dev]#
[root@ dev]#
[root@ dev]# mkfs
mkfs         mkfs.cramfs  mkfs.ext2    mkfs.ext3
[root@ dev]# mkfs.ext3 -b 4096 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4915200 inodes, 9829764 blocks
491488 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
300 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 29 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@ /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda3            26306612   7741500  17207220  32% /
/dev/xvda1              101086     19708     76159  21% /boot
tmpfs                  1572864         0   1572864   0% /dev/shm
[root@ /]# mkdir /u01


[root@/]# mount /dev/xvdb1 /u01
[root@ /]# cd /u01
[root@ u01]# touch reame.txt
[root@ u01]# ls
lost+found  reame.txt
[root@ u01]# cd /etc
[root@ etc]# vi fstab

cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/xvdb1             /u01                   ext3    defaults        1 1
LABEL=SWAP-xvda2        swap                    swap    defaults        0 0


[root@ etc]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda3             26G  7.4G   17G  32% /
/dev/xvda1             99M   20M   75M  21% /boot
tmpfs                 1.5G     0  1.5G   0% /dev/shm
/dev/xvdb1             37G  177M   35G   1% /u01
[root@]#

reboot

記錄一下,備忘!

lower_case_table_names 可以引發mysql replication 不成功

很早以前配置過一個mysql的replication, 跑的很好,突然客戶的mysql database replicaiton失效了

重新配置replication也無效

[crhk@_Slave bin]$ cat mysqld_slave.sh
#!/bin/sh
/usr/bin/mysqld_safe --skip-slave-start &
[crhk@_Slave bin]$

------------------------------------slave----------------------------------
[root@_Slave bin]# ./mysqld_slave.sh
[root@_Slave bin]# Starting mysqld daemon with databases from /var/lib/mysql

 

[root@_Slave mysql]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.45-log Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show slave status;
Empty set (0.00 sec)
mysql>
mysql> change master to
    -> master_host='A.B.C.D',
    -> master_port=3306,
    -> master_user='repl',
    -> master_password='password',
    -> master_log_file='mysql-bin.000031',
    -> master_log_pos=201937405;
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
mysql>

將同步所需文件全部刪除

rm /var/lib/mysql/relay-log.info 
rm /var/lib/mysql/master.info 
rm /var/run/mysqld/*

重新做,問題依然

只能跟蹤log了

。。。。

100301 22:26:38  mysqld started
100301 22:26:38 [Warning] /usr/libexec/mysqld: ignoring option '--innodb_file_per_table' due to invalid value 'ON'
100301 22:26:38 [Warning] /usr/libexec/mysqld: ignoring option '--innodb_file_per_table' due to invalid value 'ON'
100301 22:26:39  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
100301 22:26:39  InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 8 2665319758.
InnoDB: Doing recovery: scanned up to log sequence number 8 2665319758
InnoDB: Last MySQL binlog file position 0 3092, file name /var/lib/mysql/mysql-bin.000037
100301 22:26:39  InnoDB: Started; log sequence number 8 2665319758
100301 22:26:39 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.45-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
100301 22:27:47 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.000037' at position 3268, relay log '/var/run/mysqld/mysqld-relay-bin.000001' position: 4
100301 22:27:47 [Note] Slave I/O thread: connected to master 'repl@172.16.12.29:3306',  replication started in log 'mysql-bin.000037' at position 3268
100301 22:27:47 [ERROR] Slave: Error 'Table 'databasename.GuessFall' doesn't exist' on query. Default database: 'databasename'. Query: 'insert into GuessFall (GuessFallId,UserId,StockCode,State,StartPrice,EndPrice,CreateDate,StopDate) values ('ff52146c-81f6-4334-8920-ef3f059ff3e8','b27e0e77-9cf2-aa9b-e040-10ac0d0c2f1f', '02777', 0, -1, 0.000, '2010-03-01 22:14:40','2010-03-01 22:14:40')', Error_code: 1146
100301 22:27:47 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000037' position 3268

。。。。

發現插入不了

這是開始懷疑master/slave 的配置問題不一致了

diff一下,果然,slave庫中少了

lower_case_table_names=1

修改之slave my.cnf文件,重新配置,正常了

Myql 官方解釋:

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

簡而言之就是 寫入不區分大小寫

0  --名字對大小寫敏感 ,default

1 - -table name on disk是小寫, 名字對大小寫敏感

2--存儲根據create table or create database 的語句,mysql 查詢的時候轉換小寫,對大小寫不敏感

教訓:

1. replication 方式下的 master /slave的環境配置一致很重要,

2.lower_case_table_names 這類常用參數,應該在database配置的時候設置好了,避免不必要的改動。