[linux] 修改docker端口映射


方法一:
1、关闭docker容器
docker stop 9656305ad917
2、关闭docker进程
systemctl stop docker
3、修改容器对应的配置文件
cd /var/lib/docker/container/<containid>
vim config.v2.json

1
2
3
4
5
"Config":{
....
"ExposedPorts":{"9999/tcp":{}},
....
}

如果配置文件中不存在ExposedPorts要自己手动加上,然后修改Ports内容,默认为null
vim config.v2.json

1
"Ports":{"9999/tcp":[{"HostIp":"0.0.0.0","HostPort":"9999"}]}

修改hostconfig.json:
vim hostconfig.json

1
"PortBindings":{"9999/tcp":[{"HostIp":"","HostPort":"9999"}]}

4、添加完成端口映射之后重启启动docker进程
systemctl start docker
5、启动容器
docker start 9656305ad917
6、查看容器的端口映射,9999端口映射添加成功

1
2
3
shell > docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9656305ad917 centos "/bin/bash" 28 hours ago Up About an hour 0.0.0.0:9999->9999/tcp jenkins

方法二:
1、停止容器
docker stop b693d1c304c5
2、从容器创建一个新的镜像
docker commit -m="install jenkins" -a="zeven0707" b693d1c304c5 zeven0707/jenkins:v1
3、启动提交后的镜像,并指定端口
docker run --name jenkins -p 9999:9999 -td zeven0707/jenkins:v1

点击阅读

[Oracle] oracle完全恢复、不完全恢复、闪回数据库


1、查看当前的表空间和数据文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
RMAN> report schema;
Report of database schema for database with db_unique_name BOSTON
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 750 SYSTEM *** /data/u01/app/oracle/oradata/boston/system01.dbf
2 1670 SYSAUX *** /data/u01/app/oracle/oradata/boston/sysaux01.dbf
3 70 UNDOTBS1 *** /data/u01/app/oracle/oradata/boston/undotbs01.dbf
4 300 USERS *** /data/u01/app/oracle/oradata/boston/users01.dbf
5 100 TEST *** /data/u01/app/oracle/oradata/boston/test001.dbf
6 100 TEST11 *** /home/oracle/test11101.dbf
7 100 ZEVEN *** /home/oracle/zeven01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 29 TEMP 32767 /data/u01/app/oracle/oradata/boston/temp01.dbf

2、查看数据库当前可用的备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
RMAN> RESTORE DATABASE PREVIEW SUMMARY;

Starting restore at 2019:04:14 23:39:42
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3


List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
644 B 0 A DISK 2019:04:14 23:36:43 1 1 YES TAG20190414T233619
652 B 1 A DISK 2019:04:14 23:37:36 1 1 YES TAG20190414T233735
645 B 0 A DISK 2019:04:14 23:36:56 1 1 YES TAG20190414T233619
653 B 1 A DISK 2019:04:14 23:37:36 1 1 YES TAG20190414T233735
641 B 0 A DISK 2019:04:14 23:36:24 1 1 YES TAG20190414T233619
655 B 1 A DISK 2019:04:14 23:37:40 1 1 YES TAG20190414T233735
640 B 0 A DISK 2019:04:14 23:36:21 1 1 YES TAG20190414T233619
654 B 1 A DISK 2019:04:14 23:37:36 1 1 YES TAG20190414T233735

archived logs generated after SCN 103084444 not found in repository
Media recovery start SCN is 103084444
Recovery must be done beyond SCN 103084453 to clear datafile fuzziness
Finished restore at 2019:04:14 23:39:42

3、完全恢复

1
2
3
4
5
6
startup force mount;
run {
restore database;
recover database;
alter database open;
}

4、根据scn值进行不完整恢复

1
2
3
4
5
6
startup force mount;
run {
restore database until scn 103233673;
recover database until scn 103233673;
alter database open resetlogs;
}

5、使用rman自带的Data Recovery Advisor进行诊断和修复问题

5.1、手动删除数据文件

1
2
3
4
[oracle@dax-mysql-slave boston]$ ls
control01.ctl redo02.log sysaux01.dbf temp01.dbf test101.dbf undotbs01.dbf
redo01.log redo03.log system01.dbf test001.dbf test201.dbf users01.dbf
[oracle@dax-mysql-slave boston]$ mv users01.dbf /tmp/

5.2、尝试关闭数据库,提示报错:

1
2
3
4
5
6
7
20:06:51 SYS@ boston> shutdown immediate;
ORA-01116: error in opening database file 4
ORA-01110: data file 4: '/data/u01/app/oracle/oradata/boston/users01.dbf'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
20:06:59 SYS@ boston> exit

5.3、使用rman的Data Recovery Advisor功能去修复:

列出信息list failure

1
2
3
4
5
6
7
8
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
98722 HIGH OPEN 2019:04:18 20:07:00 One or more non-system datafiles are missing

查看失败建议advise failure;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
RMAN> advise failure;

List of Database Failures
=========================

Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------------- -------
98722 HIGH OPEN 2019:04:18 20:07:00 One or more non-system datafiles are missing

analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=590 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=6 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=201 device type=DISK
analyzing automatic repair options complete

Mandatory Manual Actions
========================
no manual actions available

Optional Manual Actions
=======================
1. If file /data/u01/app/oracle/oradata/boston/users01.dbf was unintentionally renamed or moved, restore it

Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 4
Strategy: The repair includes complete media recovery with no data loss
Repair script: /data/u01/app/oracle/diag/rdbms/boston/boston/hm/reco_16185943.hm

修复失败问题repair failure;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
RMAN> repair failure;

Strategy: The repair includes complete media recovery with no data loss
Repair script: /data/u01/app/oracle/diag/rdbms/boston/boston/hm/reco_16185943.hm

contents of repair script:
# restore and recover datafile
sql 'alter database datafile 4 offline';
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';

Do you really want to execute the above repair (enter YES or NO)? YES
executing repair script

sql statement: alter database datafile 4 offline

Starting restore at 2019:04:18 20:11:30
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /data/u01/app/oracle/oradata/boston/users01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/backuporacle/db_BOSTON_20190417_s7tv8kue_1_1
channel ORA_DISK_1: piece handle=/tmp/backuporacle/db_BOSTON_20190417_s7tv8kue_1_1 tag=TAG20190417T234621
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2019:04:18 20:11:37

Starting recover at 2019:04:18 20:11:37
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00004: /data/u01/app/oracle/oradata/boston/users01.dbf
channel ORA_DISK_1: reading from backup piece /tmp/backuporacle/db_BOSTON_20190417_t6tv8ld5_1_1
channel ORA_DISK_1: piece handle=/tmp/backuporacle/db_BOSTON_20190417_t6tv8ld5_1_1 tag=TAG20190417T235413
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

starting media recovery

archived log for thread 1 with sequence 10 is already on disk as file /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_10_gchplpwh_.arc
archived log for thread 1 with sequence 11 is already on disk as file /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_11_gcjrv31m_.arc
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_DISK_1: reading from backup piece /tmp/backuporacle/arch_BOSTON_20190417_939_1.bak
channel ORA_DISK_2: starting archived log restore to default destination
channel ORA_DISK_2: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_2: reading from backup piece /tmp/backuporacle/arch_BOSTON_20190417_940_1.bak
channel ORA_DISK_1: piece handle=/tmp/backuporacle/arch_BOSTON_20190417_939_1.bak tag=TAG20190417T235425
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_8_gcjtcwnn_.arc thread=1 sequence=8
channel default: deleting archived log(s)
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_8_gcjtcwnn_.arc RECID=380 STAMP=1005941500
channel ORA_DISK_2: piece handle=/tmp/backuporacle/arch_BOSTON_20190417_940_1.bak tag=TAG20190417T235425
channel ORA_DISK_2: restored backup piece 1
channel ORA_DISK_2: restore complete, elapsed time: 00:00:02
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_9_gcjtcwsb_.arc thread=1 sequence=9
channel default: deleting archived log(s)
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_18/o1_mf_1_9_gcjtcwsb_.arc RECID=381 STAMP=1005941501
media recovery complete, elapsed time: 00:00:01
Finished recover at 2019:04:18 20:11:43

sql statement: alter database datafile 4 online
repair failure complete

RMAN> exit
Recovery Manager complete.

6、使用flashback闪回数据库

6.1、开启flashback闪回数据库,需要满足一下条件:

6.1.1、10g以上的库

6.1.2、数据库在归档模式

1
2
3
4
5
6
7
03:08:25 SYS@ boston> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1

6.1.3、fast recovery area配置

1
2
3
4
5
6
03:09:58 SYS@ boston> show parameter recover

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /data/u01/app/oracle/fast_reco
very_area

6.1.4、数据库下的所有表空间闪回功能必须都开启,有一个没有开启闪回,无没有办法闪回数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
03:10:58 SYS@ boston>  select name,flashback_on from v$tablespace;
NAME FLA
------------------------------ ---
SYSTEM YES
SYSAUX YES
UNDOTBS1 YES
USERS YES
TEMP YES
TEST YES
TEST11 YES
ZEVEN YES
8 rows selected.
如果某个表空间没有开启闪回,使用以下命令开启:
alter tablespace users flashback on;(注意与alter database flashback on的先后顺序,如果是tablespace的闪回开启在database的闪回之后,需要先关系database闪回alter database flashback off;在开启database 闪回alter database flashback on; 否则闪回的时候会报错:
ORA-38753: Cannot flashback data file 4; no flashback log data.
ORA-01110: data file 4: '/data/u01/app/oracle/oradata/boston/users01.dbf'

6.1.5、数据库开启闪回(alter database … flashback on),查看是否开启v$database.flashback_on

1
2
3
4
5
6
7
8
9
10
11
12
13
03:11:39 SYS@ boston> select flashback_on from v$database;
FLASHBACK_ON
------------------
NO
Elapsed: 00:00:00.00
03:12:01 SYS@ boston> alter database flashback on;
Database altered.
Elapsed: 00:00:02.06
03:12:08 SYS@ boston> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES
Elapsed: 00:00:00.00

6.1.6、flashback database不能用于恢复已经被修复的控制文件的前一个时间点,一旦一个数据库的控制文件被修复或者重新建立,那么存在的flashback log就作废了

6.2、闪回数据库

6.2.1、确保数据库处于mount状态

1
2
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;

6.2.2、闪回数据库

6.2.2.1、还原到某个scn号

1
2
3
4
5
6
7
FLASHBACK DATABASE TO SCN 103290531;

根据时间点查看scn
22:43:08 SYS@ boston> select timestamp_to_scn('18-Apr-19 10:41:41.000000000 PM') from dual;
TIMESTAMP_TO_SCN('18-APR-1910:41:41.000000000PM')
-------------------------------------------------
103290531

6.2.2.2、还原到某个还原点

1
2
3
4
5
6
7
8
9
FLASHBACK DATABASE  TO RESTORE POINT good_data;

创建还原点:
CREATE RESTORE POINT good_data;
查看还原点:
22:47:04 SYS@ boston> select * from v$restore_point;
SCN DATABASE_INCARNATION# GUA STORAGE_SIZE TIME RESTORE_POINT_TIME PRE NAME
---------- --------------------- --- ------------ ----------------------------------------------
103328091 19 NO 0 19-APR-19 10.47.04.000000000 PM NO GOOD_DATA

6.2.2.3 还原到某个时间点

1
2
3
4
5
6
7
FLASHBACK DATABASE  TO TIMESTAMP TO_DATE('18-Apr-19 10:41:41','DD-MON-YYYY HH24:MI:SS');

根据scn转换为对应的时间戳
SYS@ boston> select to_char(scn_to_timestamp('103290531'))from dual;
TO_CHAR(SCN_TO_TIMESTAMP('10329053
----------------------------------
18-APR-19 10.41.39.000000000 PM

6.2.3、打开数据库查看数据内容是否是自己想要还原到的点

ALTER DATABASE OPEN READ ONLY;

6.2.4、如果查询结果是自己想要的,那么关闭数据库并重新打开

1
2
3
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER DATABASE OPEN RESETLOGS;

点击阅读

[Oracle] 使用rman进行备份(全量、增量)


0、修改rman默认配置参数

1
2
3
4
CONFIGURE RETENTION POLICY TO REDUNDANCY 3; # 冗余三份
CONFIGURE BACKUP OPTIMIZATION ON; #开启备份自动优化
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK; #归档日志删除策略,备份过两次可以删除
CONFIGURE CONTROLFILE AUTOBACKUP ON; #控制文件自动备份

1、数据库备份完之后,不删除归档,不删除多余备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak';
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

2、数据库备份完之后,直接删除归档(备份达到两次的归档不会再被备份,删除归档时会被删除

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak' delete all input;
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

3、根据冗余策略,删除多余的备份、删除多余的归档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak' delete all input;
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

4、增量备份数据库

4.1、level 0 增量数据库备份

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
BACKUP INCREMENTAL LEVEL 0 DATABASE FORMAT '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak' delete all input;
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

4.2、level 1 差异增量备份数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
BACKUP INCREMENTAL LEVEL 1 DATABASE FORMAT '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak' delete all input;
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

4.3、level 1 累积增量备份数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
### sh rman_backup.sh ORACLE_SID(实例名)
export ORACLE_BASE=${ORACLE_BASE}
export ORACLE_HOME=${ORACLE_HOME}
export ORACLE_SID=$1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
backuptime=`date +"%Y%m%d-%H%M%S"`
backuppath=/tmp/backuporacle
if [ ! -d ${backuppath} ];then
sudo mkdir -p ${backuppath}
else
:
fi

$ORACLE_HOME/bin/rman target / log=${backuppath}/full_backup_${backuptime}.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
sql 'alter system archive log current';
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE FORMAT '/tmp/backuporacle/db_%d_%T_%U';
sql 'alter system archive log current';
backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak' delete all input;
backup current controlfile format '/tmp/backuporacle/ctl_%d_%T_%s_%p.bak';
delete noprompt obsolete;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

exit

EOF

4.4、可以查看增量备份的的数据大小,如果增量备份文件超过了20%,建议使用全量备份

1
2
3
4
5
6
SELECT   FILE#, INCREMENTAL_LEVEL, COMPLETION_TIME,
BLOCKS, DATAFILE_BLOCKS
FROM V$BACKUP_DATAFILE
WHERE INCREMENTAL_LEVEL > 0
AND BLOCKS / DATAFILE_BLOCKS > .2
ORDER BY COMPLETION_TIME;

点击阅读

[Oracle] oracle 开启关闭Block Change Tracking


0、Block Change Tracking功能

默认情况下Block Change Tracking是被禁用的,该功能通过读取小的位图文件来决定哪个块改变了,在增量备份的过程中,开启这个功能可以避免扫面所有的数据文件,加快备份效率。

1、检查是否开启Block Change Tracking

1
2
3
4
5
6
7
19:38:00 SYS@ boston> COL STATUS   FORMAT A8
19:38:06 SYS@ boston> COL FILENAME FORMAT A60
19:38:08 SYS@ boston> SELECT STATUS, FILENAME FROM V$BLOCK_CHANGE_TRACKING;

STATUS FILENAME
-------- ------------------------------------------------------------
DISABLED

2、开启block change tracking

设置 DB_CREATE_FILE_DEST参数
SHOW PARAMETER DB_CREATE_FILE_DEST

1
2
3
4
19:38:28 SYS@ boston> SHOW PARAMETER DB_CREATE_FILE_DEST
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string

如果db_create_file_dest参数没有设置,可以使用下面命令设置
ALTER SYSTEM SET DB_CREATE_FILE_DEST = '/home/oracle/' SCOPE=BOTH SID='*';

1
2
3
4
5
6
7
8
9
19:40:40 SYS@ boston> ALTER SYSTEM SET DB_CREATE_FILE_DEST = '/home/oracle/' SCOPE=BOTH SID='*';
System altered.

Elapsed: 00:00:00.12
19:41:48 SYS@ boston> SHOW PARAMETER DB_CREATE_FILE_DEST

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /home/oracle/

设置完成db_create_file_dest参数之后,开启block change tracking

ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;

1
2
3
4
5
6
7
8
19:41:51 SYS@ boston> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;
Database altered.
Elapsed: 00:00:04.49
19:44:18 SYS@ boston> SELECT STATUS, FILENAME FROM V$BLOCK_CHANGE_TRACKING;
STATUS FILENAME
-------- ------------------------------------------------------------
ENABLED /home/oracle/BOSTON/changetracking/o1_mf_gc678fqg_.chg
Elapsed: 00:00:00.00

如果没有指定db_create_file_dest参数,也可以在开启block change tracking参数时指定
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/tmp/rman_change_track.f' REUSE;

1
2
3
4
5
6
7
8
9
10
11
19:46:20 SYS@ boston> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
Database altered.
Elapsed: 00:00:01.35
19:46:57 SYS@ boston> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/tmp/rman_change_track.f' REUSE;
Database altered.
Elapsed: 00:00:05.02
19:47:03 SYS@ boston> SELECT STATUS, FILENAME FROM V$BLOCK_CHANGE_TRACKING;
STATUS FILENAME
-------- ------------------------------------------------------------
ENABLED /tmp/rman_change_track.f
Elapsed: 00:00:00.00

3、禁用Block Change Tracking

ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;

4、改变Block Change Tracking File位置

方法1:在不关闭数据库的情况下修改文件位置,可使用下面方法:

1
2
ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/tmp/rman_change_track.f' REUSE;

这种方法会丢失已经存在的Block Change Tracking File,要想不丢失Block Change Tracking File需要使用下面方法

方法2:查看Block Change Tracking File原来的位置:

SELECT FILENAME FROM V$BLOCK_CHANGE_TRACKING;

1
2
3
4
19:52:19 SYS@ boston> SELECT FILENAME FROM V$BLOCK_CHANGE_TRACKING;
FILENAME
------------------------------------------------------------
/tmp/rman_change_track.f

关闭数据库
SHUTDOWN IMMEDIATE
操作系统下拷贝物理文件到新的目标路径
mv /tmp/rman_change_track.f /home/oracle/new_rman_change_track.f
启动数据库到mount
startup mount
修改Block Change Tracking File
ALTER DATABASE RENAME FILE '/tmp/rman_change_track.f' TO '/home/oracle/new_rman_change_track.f';
打开数据库
ALTER DATABASE OPEN;
查看Block Change Tracking File的文件路径

1
2
3
4
20:03:18 SYS@ boston> SELECT FILENAME FROM V$BLOCK_CHANGE_TRACKING;
FILENAME
----------------------------------------------------------------------------------------------------------------------------------
/home/oracle/new_rman_change_track.f

点击阅读

[Oracle] rman configure基础参数配置


1、rman默认配置参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(OB_DEVICE=tape1)';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/disk1/oracle/dbs/snapcf_ev.f'; # default

2、show命令查看

1
2
3
show all;查看所有配置
show retention policy;查看保留策略
show default device type;查看默认设备类型

3、恢复修改后的策略为默认策略configure……clear

1
2
3
CONFIGURE backup optimization clear;修改备份优化策略为默认(默认为off)
CONFIGURE RETENTION POLICY CLEAR;修改保留策略默认为保留一天
CONFIGURE CONTROFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;

4、配置默认备份设备类型

1
2
3
4
5
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE DEFAULT DEVICE TYPE TO SBT;指定备份设备为system backup tape
也可以使用backup命令覆盖默认的configure配置参数
BACKUP DEVICE TYPE sbt DATABASE;
BACKUP DEVICE TYPE DISK DATABASE;

5、配置默认的备份类型

1
2
3
4
5
6
copy备份形式只能用于disk备份设备类型
sbt的备份设备类型只用用backup set备份形式
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # image copies不能压缩
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # uncompressed(默认)
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;(压缩备份到disk)
CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;(压缩备份到sbt)

6、配置通道

对于tape备份,每盘磁带分配一个通道。对于磁盘备份,每块物理磁盘分配一个通道,除非你可以优化磁盘子系统多通道架构。错误的通道数量会影响在io操作方面rman的性能。
默认情况下并行为1
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
如果不指定任何channel直接备份,系统会自动分配一个通道,例如ora_disk_1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
RMAN> backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
Starting backup at 2019:04:12 21:29:57
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=397 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/u01/app/oracle/oradata/boston/sysaux01.dbf
......
input datafile file number=00003 name=/data/u01/app/oracle/oradata/boston/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2019:04:12 21:29:57
channel ORA_DISK_1: finished piece 1 at 2019:04:12 21:31:02
piece handle=/tmp/backuporacle/db_BOSTON_20190412_cstur72l_1_1 tag=TAG20190412T212957 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2019:04:12 21:31:05
channel ORA_DISK_1: finished piece 1 at 2019:04:12 21:31:06
piece handle=/tmp/backuporacle/db_BOSTON_20190412_cttur74m_1_1 tag=TAG20190412T212957 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2019:04:12 21:31:06

如果自己指定分配通道,默认的PARALLELISM会被覆盖掉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
rman > run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
release channel c1;
release channel c2;
}

allocated channel: c1
channel c1: SID=10 device type=DISK
allocated channel: c2
channel c2: SID=203 device type=DISK
Starting backup at 2019:04:12 22:26:40
channel c1: starting compressed full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/u01/app/oracle/oradata/boston/sysaux01.dbf
input datafile file number=00003 name=/data/u01/app/oracle/oradata/boston/undotbs01.dbf
channel c1: starting piece 1 at 2019:04:12 22:26:41
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/u01/app/oracle/oradata/boston/system01.dbf
input datafile file number=00004 name=/data/u01/app/oracle/oradata/boston/users01.dbf
input datafile file number=00005 name=/data/u01/app/oracle/oradata/boston/test001.dbf
channel c2: starting piece 1 at 2019:04:12 22:26:41
channel c2: finished piece 1 at 2019:04:12 22:27:06
piece handle=/tmp/backuporacle/db_BOSTON_20190412_d3turad1_1_1 tag=TAG20190412T222640 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:25
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current control file in backup set
channel c2: starting piece 1 at 2019:04:12 22:27:09
channel c2: finished piece 1 at 2019:04:12 22:27:10
piece handle=/tmp/backuporacle/db_BOSTON_20190412_d4turadq_1_1 tag=TAG20190412T222640 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c2: starting piece 1 at 2019:04:12 22:27:10
channel c2: finished piece 1 at 2019:04:12 22:27:11
piece handle=/tmp/backuporacle/db_BOSTON_20190412_d5turadu_1_1 tag=TAG20190412T222640 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c1: finished piece 1 at 2019:04:12 22:27:25
piece handle=/tmp/backuporacle/db_BOSTON_20190412_d2turad1_1_1 tag=TAG20190412T222640 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:44
Finished backup at 2019:04:12 22:27:25
released channel: c1
released channel: c2

分配通道时可以指定多个路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
RMAN> run{
2> allocate channel c1 device type disk format '/tmp/oracle1/db_%d_%T_%U';
3> allocate channel c2 device type disk format '/tmp/oracle2/db_%d_%T_%U';
4> backup as compressed backupset full database;
5> release channel c1;
6> release channel c2;
7> }
allocated channel: c1
channel c1: SID=10 device type=DISK
allocated channel: c2
channel c2: SID=203 device type=DISK
Starting backup at 2019:04:12 22:35:16
channel c1: starting compressed full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/u01/app/oracle/oradata/boston/sysaux01.dbf
input datafile file number=00003 name=/data/u01/app/oracle/oradata/boston/undotbs01.dbf
channel c1: starting piece 1 at 2019:04:12 22:35:17
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/u01/app/oracle/oradata/boston/system01.dbf
input datafile file number=00004 name=/data/u01/app/oracle/oradata/boston/users01.dbf
input datafile file number=00005 name=/data/u01/app/oracle/oradata/boston/test001.dbf
channel c2: starting piece 1 at 2019:04:12 22:35:17
channel c2: finished piece 1 at 2019:04:12 22:35:42
piece handle=/tmp/oracle2/db_BOSTON_20190412_d7turat5_1_1 tag=TAG20190412T223516 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:25
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current control file in backup set
channel c2: starting piece 1 at 2019:04:12 22:35:45
channel c2: finished piece 1 at 2019:04:12 22:35:46
piece handle=/tmp/oracle2/db_BOSTON_20190412_d8turatu_1_1 tag=TAG20190412T223516 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c2: starting compressed full datafile backup set
channel c2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel c2: starting piece 1 at 2019:04:12 22:35:46
channel c2: finished piece 1 at 2019:04:12 22:35:47
piece handle=/tmp/oracle2/db_BOSTON_20190412_d9turau2_1_1 tag=TAG20190412T223516 comment=NONE
channel c2: backup set complete, elapsed time: 00:00:01
channel c1: finished piece 1 at 2019:04:12 22:35:53
piece handle=/tmp/oracle1/db_BOSTON_20190412_d6turat5_1_1 tag=TAG20190412T223516 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:36
Finished backup at 2019:04:12 22:35:53
released channel: c1
released channel: c2

在oracle1和oracle2的路径下存放了备份的所有文件,如果放到不同物理磁盘可以提升备份效率

1
2
3
4
5
6
bash > ls oracle1/ oracle2/
oracle1/:
db_BOSTON_20190412_d6turat5_1_1

oracle2/:
db_BOSTON_20190412_d7turat5_1_1 db_BOSTON_20190412_d8turatu_1_1 db_BOSTON_20190412_d9turau2_1_1

也可以在configure下面配置好多个路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/tmp/oracle1/%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/tmp/oracle2/%U';
CONFIGURE CHANNEL 3 DEVICE TYPE DISK FORMAT '/tmp/oracle3/%U';
BACKUP AS COPY DATABASE;

RMAN> BACKUP AS COPY DATABASE;
Starting backup at 2019:04:12 22:43:26
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=203 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=396 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/data/u01/app/oracle/oradata/boston/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00001 name=/data/u01/app/oracle/oradata/boston/system01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00004 name=/data/u01/app/oracle/oradata/boston/users01.dbf
output file name=/tmp/oracle2/data_D-BOSTON_I-2681136947_TS-SYSTEM_FNO-1_dbturbcf tag=TAG20190412T224326 RECID=20 STAMP=1005432219
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_2: starting datafile copy
input datafile file number=00005 name=/data/u01/app/oracle/oradata/boston/test001.dbf
output file name=/tmp/oracle3/data_D-BOSTON_I-2681136947_TS-USERS_FNO-4_dcturbcf tag=TAG20190412T224326 RECID=19 STAMP=1005432216
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:20
channel ORA_DISK_3: starting datafile copy
input datafile file number=00003 name=/data/u01/app/oracle/oradata/boston/undotbs01.dbf
output file name=/tmp/oracle1/data_D-BOSTON_I-2681136947_TS-SYSAUX_FNO-2_daturbce tag=TAG20190412T224326 RECID=21 STAMP=1005432227
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:21
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/tmp/oracle2/data_D-BOSTON_I-2681136947_TS-TEST_FNO-5_ddturbd3 tag=TAG20190412T224326 RECID=22 STAMP=1005432229
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:04
channel ORA_DISK_2: starting full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_2: starting piece 1 at 2019:04:12 22:43:51
output file name=/tmp/oracle3/data_D-BOSTON_I-2681136947_TS-UNDOTBS1_FNO-3_deturbd3 tag=TAG20190412T224326 RECID=23 STAMP=1005432230
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:04
output file name=/tmp/oracle1/cf_D-BOSTON_id-2681136947_dfturbd4 tag=TAG20190412T224326 RECID=24 STAMP=1005432231
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
channel ORA_DISK_2: finished piece 1 at 2019:04:12 22:43:52
piece handle=/tmp/oracle2/dgturbd7_1_1 tag=TAG20190412T224326 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
Finished backup at 2019:04:12 22:43:52

在oracle1、oracle2、oracle3路径下存储这备份的所有文件:

1
2
3
4
5
6
7
8
9
[oracle@dax-mysql-slave tmp]$ ls oracle1/ oracle2/ oracle3/
oracle1/:
cf_D-BOSTON_id-2681136947_dfturbd4 data_D-BOSTON_I-2681136947_TS-SYSAUX_FNO-2_daturbce

oracle2/:
data_D-BOSTON_I-2681136947_TS-SYSTEM_FNO-1_dbturbcf data_D-BOSTON_I-2681136947_TS-TEST_FNO-5_ddturbd3 dgturbd7_1_1

oracle3/:
data_D-BOSTON_I-2681136947_TS-UNDOTBS1_FNO-3_deturbd3 data_D-BOSTON_I-2681136947_TS-USERS_FNO-4_dcturbcf

恢复配置至默认
CONFIGURE CHANNEL DEVICE TYPE DISK clear;

7、控制文件自动备份

CONFIGURE CONTROLFILE AUTOBACKUP ON;(开启自动备份,默认为off)
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
指定备份的路径
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/oracle/cf_%F';
备份数据时,会自动备份控制文件和数据库参数文件

1
2
3
4
5
RMAN> BACKUP AS COPY DATABASE;
......
Starting Control File and SPFILE Autobackup at 2019:04:12 23:58:10
piece handle=/tmp/oracle/cf_c-2681136947-20190412-00 comment=NONE
Finished Control File and SPFILE Autobackup at 2019:04:12 23:58:17

清空自动备份控制文件参数
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
在run下面使用set controlfile autobackup format命令,可以覆盖掉configure下面的配置信息

1
2
3
4
5
6
7
8
9
10
RMAN> RUN
2> {
3> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/oracle/cf_%F.bck';
4> BACKUP AS BACKUPSET DEVICE TYPE DISK DATABASE;
5> }
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
......
Starting Control File and SPFILE Autobackup at 2019:04:13 00:07:28
piece handle=/tmp/oracle/cf_c-2681136947-20190413-00.bck comment=NONE
Finished Control File and SPFILE Autobackup at 2019:04:13 00:07:31

8、配置备份保留策略

配置基于冗余的保留策略(冗余3份)
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
配置基于时间窗口的保留策略(保留7天)
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
禁用保留策略
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

9、备份优化

CONFIGURE BACKUP OPTIMIZATION ON;(启动备份优化策略,默认为off)
开启备份优化策略,rman根据备份策略和备份双工特性在算法中的因素,来判断是否有足够的备份在rman指定的备份设备上,以此来决定是否对同一文件是否备份。

备份时想要覆盖优化策略可以使用FORCE选项:

1
2
BACKUP DATABASE FORCE;
BACKUP ARCHIVELOG ALL FORCE;

10、配置归档之日删除策略

备份两次的归档日志可以被删除:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;
该删除策略的意义是:每份归档日志只会备份两次,哪怕执行多次备份,已经满足2次备份的归档也不会备份。执行备份的时候不会自动删除已经满足删除策略的归档,需要使用delete archivelog all才行。且不满足两次的备份时不会被删除的。

1
2
3
4
5
6
7
8
9
10
11
20:07:02 SYS@ boston> select recid, sequence#, archived, deleted, backup_count from v$archived_log where deleted='NO';

RECID SEQUENCE# ARC DEL BACKUP_COUNT
---------- ---------- --- --- ------------
294 491 YES NO 2
295 492 YES NO 2
296 493 YES NO 2
297 494 YES NO 2
298 495 YES NO 2
299 496 YES NO 1
300 497 YES NO 1

执行删除策略

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
RMAN> delete archivelog all;
......
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_496_gc3n6kxk_.arc thread=1 sequence=496
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_497_gc3n7sfh_.arc thread=1 sequence=497
List of Archived Log Copies for database with db_unique_name BOSTON
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - -------------------
294 1 491 A 2019:04:13 19:26:37
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_491_gc3lq5ss_.arc

295 1 492 A 2019:04:13 19:41:25
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_492_gc3lq7m5_.arc

296 1 493 A 2019:04:13 19:41:27
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_493_gc3lrkc7_.arc

297 1 494 A 2019:04:13 19:42:08
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_494_gc3ltyl3_.arc

298 1 495 A 2019:04:13 19:43:26
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_495_gc3lwk6g_.arc
......
Deleted 5 objects

根据提示备份满足两次的可以删除,299和300需要更多的备份才能被删除。
删除完之后,查看没有被删除的归档:

1
2
3
4
5
6
20:07:36 SYS@ boston> select recid, sequence#, archived, deleted, backup_count from v$archived_log where deleted='NO';

RECID SEQUENCE# ARC DEL BACKUP_COUNT
---------- ---------- --- --- ------------
299 496 YES NO 1
300 497 YES NO 1

执行一次归档日志备份:

RMAN> backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak';
查看归档日志信息:

1
2
3
4
5
6
7
20:08:05 SYS@ boston> select recid, sequence#, archived, deleted, backup_count from v$archived_log where deleted='NO';

RECID SEQUENCE# ARC DEL BACKUP_COUNT
---------- ---------- --- --- ------------
299 496 YES NO 2
300 497 YES NO 2
301 498 YES NO 1

再次执行一次备份
RMAN> backup archivelog all format '/tmp/backuporacle/arch_%d_%T_%s_%p.bak';
查看归档日志信息:

1
2
3
4
5
6
7
8
20:10:38 SYS@ boston> select recid, sequence#, archived, deleted, backup_count from v$archived_log where deleted='NO';

RECID SEQUENCE# ARC DEL BACKUP_COUNT
---------- ---------- --- --- ------------
299 496 YES NO 2
300 497 YES NO 2
301 498 YES NO 2
302 499 YES NO 1

发现299、300只备份了两次,没有被多次备份。
再次删除归档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
RMAN> delete archivelog all;
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=580 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=11 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=199 device type=DISK
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_499_gc3nfwjg_.arc thread=1 sequence=499
List of Archived Log Copies for database with db_unique_name BOSTON
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - -------------------
299 1 496 A 2019:04:13 19:44:16
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_496_gc3n6kxk_.arc

300 1 497 A 2019:04:13 20:06:41
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_497_gc3n7sfh_.arc

301 1 498 A 2019:04:13 20:07:20
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_498_gc3nfgb6_.arc


Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_496_gc3n6kxk_.arc RECID=299 STAMP=1005509202
deleted archived log
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_497_gc3n7sfh_.arc RECID=300 STAMP=1005509241
deleted archived log
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_498_gc3nfgb6_.arc RECID=301 STAMP=1005509422
Deleted 3 objects

备份超过两次的归档被删除,如果想要强制删除,不使用删除策略,使用delete force archivelog all;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
RMAN> delete force archivelog all;
List of Archived Log Copies for database with db_unique_name BOSTON
=====================================================================

Key Thrd Seq S Low Time
------- ---- ------- - -------------------
302 1 499 A 2019:04:13 20:10:21
Name: /data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_499_gc3nfwjg_.arc


Do you really want to delete the above objects (enter YES or NO)? yes
deleted archived log
archived log file name=/data/u01/app/oracle/fast_recovery_area/BOSTON/archivelog/2019_04_13/o1_mf_1_499_gc3nfwjg_.arc RECID=302 STAMP=1005509436
Deleted 1 objects

11、查看关于rman的高级配置参数,点击此处

点击阅读

[Oracle] rman 参数配置(advanced)


1、设置每个通道创建备份集的最大值:

CONFIGURE MAXSETSIZE TO UNLIMITED; # default
设置每个通道能够创建备份集的最大值为1G;
CONFIGURE MAXSETSIZE TO 1 G;
使用backupset备份时,如果存在某个表空间文件大于1G,则会提示报错

1
2
RMAN-03002: failure of backup command at 04/13/2019 23:32:46
RMAN-06183: datafile or datafile copy /data/u01/app/oracle/oradata/boston/sysaux01.dbf (file number 2) larger than MAXSETSIZE

2、设置每个通道创建备份块的最大值,如果达到最大值会创建下一个备份块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
如果系统参数配置了多个通道,可以直接添加maxpiecesize:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK MAXPIECESIZE 100 M;
CONFIGURE CHANNEL 2 DEVICE TYPE DISK MAXPIECESIZE 50 M;
CONFIGURE CHANNEL 3 DEVICE TYPE DISK MAXPIECESIZE 50 M;

RMAN> backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
Starting backup at 2019:04:14 00:17:11
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
......
channel ORA_DISK_3: finished piece 1 at 2019:04:14 00:17:15
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kituu587_1_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_2: finished piece 1 at 2019:04:14 00:17:19
piece handle=/tmp/backuporacle/db_BOSTON_20190414_khtuu587_1_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_2: starting piece 2 at 2019:04:14 00:17:19
channel ORA_DISK_2: finished piece 2 at 2019:04:14 00:17:26
piece handle=/tmp/backuporacle/db_BOSTON_20190414_khtuu587_2_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_2: starting piece 3 at 2019:04:14 00:17:26
channel ORA_DISK_1: finished piece 1 at 2019:04:14 00:17:29
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kgtuu587_1_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_1: starting piece 2 at 2019:04:14 00:17:29
channel ORA_DISK_2: finished piece 3 at 2019:04:14 00:17:36
piece handle=/tmp/backuporacle/db_BOSTON_20190414_khtuu587_3_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_2: starting piece 4 at 2019:04:14 00:17:36
channel ORA_DISK_2: finished piece 4 at 2019:04:14 00:17:43
piece handle=/tmp/backuporacle/db_BOSTON_20190414_khtuu587_4_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_2: starting piece 5 at 2019:04:14 00:17:43
channel ORA_DISK_1: finished piece 2 at 2019:04:14 00:17:44
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kgtuu587_2_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_1: starting piece 3 at 2019:04:14 00:17:44
channel ORA_DISK_2: finished piece 5 at 2019:04:14 00:17:45
piece handle=/tmp/backuporacle/db_BOSTON_20190414_khtuu587_5_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:34
channel ORA_DISK_1: finished piece 3 at 2019:04:14 00:17:59
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kgtuu587_3_1 tag=TAG20190414T001711 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:48
Finished backup at 2019:04:14 00:17:59

备份完成之后的文件大小如下所示:

1
2
3
4
5
6
7
8
9
-rw-r-----. 1 oracle oinstall 5.1M 4月  14 00:17 db_BOSTON_20190414_kituu587_1_1
-rw-r-----. 1 oracle oinstall 49M 4月 14 00:17 db_BOSTON_20190414_khtuu587_1_1
-rw-r-----. 1 oracle oinstall 49M 4月 14 00:17 db_BOSTON_20190414_khtuu587_2_1
-rw-r-----. 1 oracle oinstall 99M 4月 14 00:17 db_BOSTON_20190414_kgtuu587_1_1
-rw-r-----. 1 oracle oinstall 49M 4月 14 00:17 db_BOSTON_20190414_khtuu587_3_1
-rw-r-----. 1 oracle oinstall 49M 4月 14 00:17 db_BOSTON_20190414_khtuu587_4_1
-rw-r-----. 1 oracle oinstall 99M 4月 14 00:17 db_BOSTON_20190414_kgtuu587_2_1
-rw-r-----. 1 oracle oinstall 4.4M 4月 14 00:17 db_BOSTON_20190414_khtuu587_5_1
-rw-r-----. 1 oracle oinstall 44M 4月 14 00:17 db_BOSTON_20190414_kgtuu587_3_1

通道1备份的数据块小于100M,通道2、通道3备份的数据块小于50M
也可以在run命令下,分配通道时手动指定参数,如下所示:

1
2
3
4
5
6
run {
allocate channel t1 type disk maxpiecesize = 50M;
allocate channel t2 type disk maxpiecesize = 80M;
allocate channel t3 type disk;
backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
}

3、完全备份数据时,单独排除某一个数据库不备份

CONFIGURE EXCLUDE FOR TABLESPACE users;
开始备份,tablespace users被自动过滤掉,没有备份:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
RMAN> backup as compressed backupset full database format '/tmp/backuporacle/db_%d_%T_%U';
Starting backup at 2019:04:14 00:32:50
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=397 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=585 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=12 device type=DISK
file 4 is excluded from whole database backup
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/data/u01/app/oracle/oradata/boston/sysaux01.dbf
input datafile file number=00003 name=/data/u01/app/oracle/oradata/boston/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2019:04:14 00:32:51
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/u01/app/oracle/oradata/boston/system01.dbf
input datafile file number=00005 name=/data/u01/app/oracle/oradata/boston/test001.dbf
channel ORA_DISK_2: starting piece 1 at 2019:04:14 00:32:51
channel ORA_DISK_2: finished piece 1 at 2019:04:14 00:32:58
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kltuu65j_1_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_2: starting piece 2 at 2019:04:14 00:32:58
channel ORA_DISK_2: finished piece 2 at 2019:04:14 00:33:05
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kltuu65j_2_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_2: starting piece 3 at 2019:04:14 00:33:05
channel ORA_DISK_1: finished piece 1 at 2019:04:14 00:33:06
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kktuu65j_1_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_1: starting piece 2 at 2019:04:14 00:33:06
channel ORA_DISK_2: finished piece 3 at 2019:04:14 00:33:13
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kltuu65j_3_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_2: starting piece 4 at 2019:04:14 00:33:13
channel ORA_DISK_2: finished piece 4 at 2019:04:14 00:33:20
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kltuu65j_4_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_2: starting piece 5 at 2019:04:14 00:33:20
channel ORA_DISK_1: finished piece 2 at 2019:04:14 00:33:21
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kktuu65j_2_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_1: starting piece 3 at 2019:04:14 00:33:21
channel ORA_DISK_2: finished piece 5 at 2019:04:14 00:33:22
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kltuu65j_5_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:31
channel ORA_DISK_1: finished piece 3 at 2019:04:14 00:33:36
piece handle=/tmp/backuporacle/db_BOSTON_20190414_kktuu65j_3_1 tag=TAG20190414T003251 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 2019:04:14 00:33:36

4、配置snapshot control file location

因为控制文件一直是在适时刷新的,不能确保数据文件和控制文件的一致性,因此rman在备份和同步recovery catalog时会用到snapshot control file,开始备份时会创建或者更新(如果snapshot controlfile 存在)snapshot controlfile,之后rman使用snapshot controlfile进行备份和同步。
snapshot controlfile这是在rman备份和同步的时候才会用到,oracle在创建表空间、切换日志、执行检查点并不会把信息写到snapshot controlfile下。

rman查看snapshot controlfile

1
2
3
RMAN> show snapshot controlfile name;
RMAN configuration parameters for database with db_unique_name BOSTON are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/snapcf_boston.f';

修改snapshot controlfile路径CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/root/snap_boston.ctl’;
设置的路径oralce用户必须有访问权限,如果没有访问权限,会报下面错误:

1
2
3
4
5
6
ORA-01580: error creating control backup file /root/snap_boston.ctl
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 13: Permission denied
Additional information: 6

RMAN-08132: WARNING: cannot update recovery area reclaimable file list

点击阅读

[Oracle] oracle 禁用fast recovery area


1、如果数据库开启了flashback database需要禁用

alter database flashback off;

2、修改log_archive_dest_n参数,将其值修改为非fast recovery area

未修改之前:
LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST'
(LOCATION=USE_DB_RECOVERY_FILE_DEST配置fast recovery area,该参数值为 DB_RECOVERY_FILE_DEST初始化参数指定的值)
修改为非FRA:
ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=/ORACLE/DBS/';

3、之后禁用fra初始化参数

ALTER SYSTEM SET DB_RECOVERY_FILE_DEST='';

点击阅读

[Linux] nexus 登录之后提示报错System Requirement: max file descriptors [4096] likely too low, increase to at least [65536]


1、nexus 登录之后提示报错System Requirement: max file descriptors [4096] likely too low, increase to at least [65536]

如下图所示:
1

2、修改方法

ulimit -n 65536

添加参数-XX:-MaxFDLimit(默认情况下没有添加这个参数)
more /data/soft/nexus/nexus-3.7.1-02/bin/nexus.vmoptions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-XX:-MaxFDLimit
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false

3、重新启动nexus

/data/soft/nexus/nexus-3.7.1-02/bin/nexus restart

点击阅读

[Oracle] sqlplus 连接方式


1、sqlplus 用户名/密码@连接字符串

sqlplus scott/tiger@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.168.177)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=chicago)))"
或者
sqlplus scott/tiger@"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.168.177)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=chicago)))"
eg:
sqlplus scott/tiger@192.168.168.177:1521/boston.us.oracle.cn

2、sqlplus 用户名/密码@ip:port/service_name

sqlplus corer111/core@192.168.168.65:1521/oibs1

3、sqlplus 用户名/密码@net_service_name

sqlplus scott/tiger@boston177

4、本地验证sys用户登录,监听是否开启和以及数据库是否启动都不影响登录

1
2
export ORACLE_SID=***
sqlplus / as sysdba

5、数据库用户登录,数据库要确保在启动状态,监听是否可用不影响

1
sqlplus scott/tiger

6、客户端使用external password store

6.1、客户端先创建wallet(D:\software\oracle\product\11.2.0\client_1\wallets为指定生成wallet的目录):

1
mkstore -wrl D:\software\oracle\product\11.2.0\client_1\wallets -create

6.2、在wallet里面创建数据库连接认证:

1
mkstore -wrl wallet_location -createCredential db_connect_string username

wallet_location:创建钱包的位置
db_connect_string :对应的tns中指定的网络服务名
username:连接数据库使用的用户名
eg:

1
mkstore -wrl D:\software\oracle\product\11.2.0\client_1\wallets -createCredential boston177 scott

13

6.3、修改sqlnet.ora配置文件,添加wallet相关参数:

1
2
3
4
5
6
7
8
9
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = D:\software\oracle\product\11.2.0\client_1\network\admin)
)
)

SQLNET.WALLET_OVERRIDE = TRUE

测试是否能够正常连接:

1
sqlplus /@boston177

14

6.4、如果后面用户名密码发生变更,直接修改外部钱包认证即可,应用端不需要做任何变更,修改数据库用户密码之后修改外部面认证:

查看有哪些外部密码认证:

1
mkstore -wrl D:\software\oracle\product\11.2.0\client_1\wallets -listCredential

11

修改外部密码认证:

1
mkstore -wrl D:\software\oracle\product\11.2.0\client_1\wallets  -modifyCredential boston177 scott

15

6.5、删除外部密码认证:

1
mkstore -wrl D:\software\oracle\product\11.2.0\client_1\wallets -deleteCredential boston177

12

点击阅读

[Linux] linux 下used显示使用的内存过大,但实际进程占用的内存很小


1、查看当前系统内存的使用情况:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@zabbix-zyl gopmonitor]# top|head -10
top - 10:25:34 up 90 days, 1:31, 4 users, load average: 0.65, 0.58, 0.37
Tasks: 1027 total, 1 running, 1025 sleeping, 0 stopped, 1 zombie
Cpu(s): 0.8%us, 0.5%sy, 0.0%ni, 97.6%id, 1.2%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 16318608k total, 15056496k used, 1262112k free, 202316k buffers
Swap: 10485756k total, 3422652k used, 7063104k free, 364088k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
116159 root 20 0 15700 1868 832 R 3.8 0.0 0:00.03 top
3901 zabbix 20 0 3699m 5800 3432 S 1.9 0.0 0:14.09 zabbix_server
1 root 20 0 19356 848 628 S 0.0 0.0 0:07.99 init
[root@zabbix-zyl gopmonitor]# free -m
total used free shared buffers cached
Mem: 15936 14704 1231 2 197 355
-/+ buffers/cache: 14151 1785
Swap: 10239 3342 6897

2、释放所有缓存再次查看,缓存释放掉了:

1
2
3
4
5
6
[root@zabbix-zyl gopmonitor]# echo 3 > /proc/sys/vm/drop_caches
[root@zabbix-zyl gopmonitor]# free -m
total used free shared buffers cached
Mem: 15936 4141 11794 2 8 47
-/+ buffers/cache: 4086 11849
Swap: 10239 3342 6897

3、关于/proc/sys/vm/drop_caches参数不同值对应的含义:

1
2
3
4
0:不释放(系统默认值)
1:释放页缓存
2:释放dentries和inodes
3:释放所有缓存( 不是破坏性操作,脏的对象(比如脏页)不会被释放,可以运行sync命令,使用sync命令强制缓冲区的所有数据写入磁盘。)

点击阅读

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog