常用Linux命令和脚本

解决”Argument list too long”

在linux中删除大量文件时,直接用rm会出现:-bash: /bin/rm: Argument list too long参数列表过长,的错误。
这时可以用以下命令来删除

find . -name "childqp_ora_*.aud" | xargs rm -rf "childqp_ora_*.aud"
# 或者
ls | xargs -n 10 rm -fr ls
# 输出所有的文件名(用空格分割) xargs就是将ls的输出,每10个为一组(以空格为分隔符),作为rm -rf的参数也就是说将所有文件名10个为一组,由rm -rf删除

Docker学习笔记_15 docker应用 - 部署Goldengate

OGG on docker准备

OGG MA是从OGG 12.3起被引入的,是一种以云计算为视角设计的架构。原有架构称为Traditional or Classic Architecture

GoldenGate Image没有现成的,需要手工生成。
由于ogg for oracle需要有OCI才能正常运行,所以可以直接使用docker oracle instant client image,在此基础上再安装ogg for oracle.
oracle docker images: https://github.com/oracle/docker-images

Oracle主库添加datafile备库空间不足错误处理

故障重现

# 主库添加datafile成功
alter tablespace crm2 add datafile
'+DATA' size 20g autoextend on next 500m maxsize unlimited;

# 备库报错信息如下
Tue Sep 11 14:33:11 2018
Errors in file /u01/app/oracle/diag/rdbms/crmsn/crmsn/trace/crmsn_pr00_9744.trc:
ORA-01119: error in creating database file '+DATA'
ORA-17502: ksfdcre:4 Failed to create file +DATA
ORA-15041: diskgroup "DATA" space exhausted
File #29 added to control file as 'UNNAMED00029'.
Originally created as:
'+DATA/crmpn/datafile/crm2.290.986567455'
Recovery was unable to create the file as a new OMF file.
MRP0: Background Media Recovery terminated with error 1274
Errors in file /u01/app/oracle/diag/rdbms/crmsn/crmsn/trace/crmsn_pr00_9744.trc:
ORA-01274: cannot add datafile '+DATA/crmpn/datafile/crm2.290.986567455' - file could not be created
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 14132183932
Tue Sep 11 14:33:12 2018
MRP0: Background Media Recovery process shutdown (crmsn)

crfclust.bdb文件过大处理

故障现象

grid所在目录空间满

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdw2              40G   22G   17G  58% /
tmpfs                  16G  219M   16G   2% /dev/shm
/dev/sdw1              50G   46G  1.5G  97% /u01

# 使用find命令找出来大文件
find ./ type f -size +1024M
./crf/db/wldb01/crfclust.bdb

由于文件crfclust.bdb是Cluster Health Monitor (CHM) file,他的默认大小是1G,但是有在一些平台和版本中由于bug原因导致过大.

Oracle Cluster Health Monitor (CHM) using large amount of space (more than default) (Doc ID 1343105.1)
Bug 20186278 – crfclust.bdb Becomes Huge Size Due to Sudden Retention Change (Doc ID 20186278.8)