2个rman自动恢复的脚本
### scripts 1
--the scirpt is used for restore db from vcs to a point to time recovery
--and the target datafile and logfile is different from source
###### config env
export start_date="10/31/2017 06:00:00"
export end_date="11/01/2017 00:00:00"
export restore_date="10/31/2017 23:00:00"
export CLIENT_NAME="bpo1.db.os"
export ORACLE_SID=bpo
export ORACLE_HOME=/db/bpo/app/product/11g
export ORACLE_BASE=/db/bpo/app/product
export OLD_ORACLE_HOME=/db/bpo/oracleapp/database/11.2.0/db_1/dbs
export old_log_path="/db/vats/oradata/vats/"
export new_log_path="/db/bpo/data/"
export old_data_path="+DATA_DG/bpo/datafile"
export new_data_path="/db/bpo/data"
##no need change config
export PATH=$PATH:$ORACLE_HOME/bin
--for linux
export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep -a "cntrl" |awk '{print $8}'| head -1`
--for aix
export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep "cntrl" |awk '{print $8}'| head -1`
export oracle_user=osbpo
###
cd $new_data_path
mkdir archivelog
cd $ORACLE_BASE
mkdir diag diag/rdbms diag/tnslsnr
##for target is already ok ,it meand target db is already started,revert datafile * to new location in target in /tmp/datafile_$ORACLE_SID.sql ,
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
spool /tmp/datafile_$ORACLE_SID.sql
set linesize 999 linesize 999 head off feedback off
select 'set newname for datafile '||FILE#||' to '||''''||name||''';' from v$datafile;
spool off
db
##########for target is not ok, it means target db is not started,revert datafile * to new location in source and copy to target
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
spool /tmp/datafile_$ORACLE_SID.sql
set linesize 999 linesize 999 head off feedback off
select 'set newname for datafile '||''||FILE#||''||' to '||chr(39)||replace(name,'$old_data_path','$new_data_path')||'''||'.dbf;' from v\$datafile;
spool off
db
##su $oracle_user -c "sqlplus / as sysdba "<<db1
##@/tmp/datafile_$ORACLE_SID.sql
##db1
###### begin to restore controlfile
su $oracle_user -c "sqlplus / as sysdba "<<eof0
shutdown immediate;
startup nomount;
eof0
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g" <<eof1
run {
allocate channel c1 type 'sbt_tape';
send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';
restore controlfile from '$controlfile';
release channel c1;
}
eof1
su oracle1 -c "sqlplus / as sysdba "<<eof2
select status from v\$instance;
alter database mount;
eof2
####produce restore and recover command
echo "run { " > /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c1 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c2 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c3 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c4 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
cat /tmp/datafile_$ORACLE_SID.sql >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "set until time \"to_date('$restore_date','mm/dd/yyyy yy hh24:mi:ss')\";">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "restore database;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "switch datafile all;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "recover database;">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c1;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c2;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c3;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c4;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "}" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
chmod 777 /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
su oracle1 -c "rman target / catalog rman11g/rman11g@cat11g cmdfile=/tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql"
##### ,for source log file is in filesytem ,mount db and change logfile to new location in target ,no need , 在rman 调用了switch datafile all, 后 open resetlogs 会自动 clear log and create logfile in new location.
##su oracle1 -c "sqlplus / as sysdba "<<eof5
#set linesize 999 linesize 999 head off feedback off
#spool /tmp/logfile_$ORACLE_SID.sql
#select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'$old_log_path1','$new_log_path')||''';' from v\$logfile;
#spool off
#eof5
#####for source log file is in asm, mount db and change logfile to new location in target -no need , 在rman 调用了switch datafile all, 后 open resetlogs 会自动 clear log and create logfile in new location.
##su oracle1 -c "sqlplus / as sysdba "<<eof5
##set linesize 999 linesize 999 head off feedback off
##spool /tmp/logfile_$ORACLE_SID.sql
#select 'alter database rename file '||''''||member||''''||' to '||chr(39)||'$new_log_patch'||substr(member,instr(member,'/',-1,1) +1) from v\$logfile;
#spool off
#eof5
su oracle1 -c "sqlplus / as sysdba "<<eof6
@/tmp/logfile_$ORACLE_SID.sql
eof6
####open resetlogs ,if meet ora-00392 ,it means it is for to-time reovery,need clear the log .
su oracle1 -c "sqlplus / as sysdba "<<eof7
alter database open resetlogs;
eof7
### scripts 2
export ORALCE_SID=vats
export ORACLE_HOME=/db/app/product/database/11g
export source_db_home=/oracle/product/database/11.2.0 s
export target_db_home=/db/app/product/database/11g s
export source_db_file_loc=/db/oradata/vats
export target_db_file_loc=/db/oradata/vats
export source_archive_log=/db/oradata/vats/archivelog
export target_archive_log=/db/oradata/vats/archivelog
export source_ip=25.10.0.197
export target_ip=10.241.96.37
export target_passwd="123456"
export oracle_user=oracle
export PORT=15025
### it will prompt passwd
##
scp root@$source_ip:$source_db_home/*$ORALCE_SID* $target_db_home
### it will prompt passwd
###scp root@$source_ip:$source_db_file_loc/*.* $target_db_file_loc
#### use expect to send the datafile use scp
#expect -c "
# spawn scp root@$source_ip:$source_db_file_loc/*.* $target_db_file_loc
# expect {
# \"*assword\" {set timeout 300; send \"$target_passwd\r\"; exp_continue;}
# \"yes/no\" {send \"yes\r\";}
# }
#expect eof"
###use expect to send the datafile use sftp becuase sftp 可以容忍更多的网络延时
#expect -c "
# spawn
sftp root@$source_ip:$source_db_file_loc/suntx02.dbf $target_db_file_loc
# expect {
# \"*assword\" {set timeout 300; send \"$target_passwd\r\"; exp_continue;}
# \"yes/no\" {send \"yes\r\";}
# }
#expect eof"
####如果 send \"quit\r\"; 加入最后,那么sftp 会在遇到网络中断,异常退出 ,expect is for linux
cd $target_db_file_loc
expect -c "
spawn sftp root@$source_ip:$source_db_file_loc
expect {
\"*assword\" {set timeout -1; send \"$target_passwd\r\"; exp_continue;}
\"sftp\" {send \"get *.dbf\r\
";}
}
expect eof"
exit
su $oracle_user -c "sqlplus / as sysdba "<<eof2
select status from v\$instance;
alter database mount;
alter database open read only;
shutdown immediate;
startup;
archive log list;
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$target_ip)(PORT=$PORT)))' scope=both;
shutdown immediate;
startup;
eof2
su $oracle_user -c "echo "SQLNET.EXPIRE_TIME=10" >> $ORACLE_HOME/network/admin/sqlnet.ora"
su $oracle_user -c "echo "$ORACLE_SID =" >> $ORACLE_HOME/network/admin/listener.ora"
su $oracle_user -c "echo "(DESCRIPTION_LIST =" >> $ORACLE_HOME/network/admin/listener.ora"
su $oracle_user -c "echo "(DESCRIPTION =">> $ORACLE_HOME/network/admin/listener.ora"
su $oracle_user -c "echo "(ADDRESS_LIST =">> $ORACLE_HOME/network/admin/listener.ora"
su $oracle_user -c "echo "(ADDRESS = (PROTOCOL = TCP)(HOST = $target_ip)(PORT = $PORT))" >> $ORACLE_HOME/network/admin/listener.ora "
su $oracle_user -c "echo ")" >> $ORACLE_H
EXPIRE_TIME=10" >> cd $ORACLE_HOME/network/admin/sqlnet.ora "
--
--scp root
#!/usr/bin/expect
#spawn scp root@$source_ip:$source_db_home/*$db_name* $target_db_home
#set timeout 20
#expect "$target_passwd"
#exec sleep 2
#send "password\r"
#interact
OME/network/admin/listener.ora "
su $oracle_user -c "echo ")" >> $ORACLE_HOME/network/admin/listener.ora "
su $oracle_user -c "echo ")" >> $ORACLE_HOME/network/admin/listener.ora "
su $oracle_user -c "lsnrctl start $ORACLE_SID"
su $oracle_user -c "lsnrctl status $ORACLE_SID"
su $oracle_user -c "sqlplus / as sysdba "<<eof3
select status from v\$instance;
alter system register;
eof3
su $oracle_user -c "lsnrctl status $ORACLE_SID"
###su $oracle_user -c "echo "SQLNET.
########for tempfile re-creation
1.观察alter日志,tempfile 是否会自动创建。
check log
cd /db/db1/app/db/diag/rdbms/db1/db11/trace
tail -f alert*.log
2,做10次switch logfile,检查logfile
alter system switch logfile;
3.temp file
理论上会tempfile 会自动创建在相同目录,11g会自动创建临时表空间,每个表空间200M,不会自动扩展,因此需要手工调整临时文件大小
4.undo 也是不会开启自动扩展的
###scripts to produce tempfile production:
select 'ALTER TABLESPACE '||t.name||' add tempfile '||''''||f.name||''''||f.bytes/1024/1024||'M REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;' from v
$tempfile f ,(select ts#,name from v$tablespace t where included_in_database_backup='NO') t
where f.ts#= t.ts#
#####################
ALTER TABLESPACE TEMP ADD TEMPFILE '/db/oracle/oradata/pisa/temp01.dbf'
SIZE 4929M REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
ALTER TABLESPACE PISA_TEMP ADD TEMPFILE '/db/oracle/oradata/pisa/PISA_TEMP.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 20971520 MAXSIZE 32767M;
ALTER TABLESPACE PISA_TEMP ADD TEMPFILE '/db/oracle/oradata/pisa/PISA_TEMP01.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 20971520 MAXSIZE 32767M;
ALTER TABLESPACE ETL_TEMP ADD TEMPFILE '/db/oracle/oradata/pisa/ETL_TEMP.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 10485760 MAXSIZE 5000M;
ALTER TABLESPACE TS_EAST_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/east_data_tmp01.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_EAST_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/east_data_tmp02.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_SAFE_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/safe_data_tmp01.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_SAFE_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/safe_data_tmp02.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_IGRSVISE_TMP drop TEMPFILE '/db/oracle/oradata/pisa/igrsvise_data_tmp01.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_IGRSVISE_TMP drop TEMPFILE '/db/oracle/oradata/pisa/igrsvise_data_tmp02.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_IGRSFIN_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/igrsfin_data_tmp01.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_IGRSFIN_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/igrsfin_data_tmp02.dbf'
SIZE 2000M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
---
ALTER TABLESPACE TS_IGRSVISE_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/igrsvise_data_tmp01.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
ALTER TABLESPACE TS_IGRSVISE_TMP ADD TEMPFILE '/db/oracle/oradata/pisa/igrsvise_data_tmp02.dbf'
SIZE 32767M REUSE AUTOEXTEND ON NEXT 104857600 MAXSIZE 32767M;
##select name from v$tempfile;
###alter database tempfile '/db/oracle/oradata/pisa/temp01.dbf' drop
-----step 2 drop old
select 'alter database tempfile '||''''||name||''' drop;' from v$tempfile;
###sample 0:
### scripts 1
##since oracle 11g is version equl cat1log 11g ,so we use man restore connect catalog db
##the scirpt is used for restore db from vcs to a point to time recovery
##and the target datafile and logfile is different from source,the script is running in root user
##below is running the linux nbu machine
##clearn old .dbf file in other direcotry /os/oradata
###if other db is 12c ,the key word CLIENT_NAME/new_log_path/new_data_path need change following the new db
##add pause to debug to /usr/bin for debug question
hostname=`df -h`
echo "cems total size is 100g, make sure /os/oradata/ have more space than 100g,if not clearn old .dbf file in /os/oradata/“
echo "Please input your biplist query start_date eg 03/17/2019 06:00:00 :"
read start_date
echo "Please input your biplist query end_time eg 03/19/2019 00:00:00 :"
read end_time
echo "Please input your rman restore_date until time eg 03/18/2019 23:00:00 ,and it is between start_time and end_time:"
read restore_date
echo "restore_date=$restore_date,continue to create ? (y/n):"
read continue
if [ "$continue" == "y" ]
then
###### section 1 config env
###config restore date, backup_start_date,end_start_date, nbu_client_name,ORACLE_SID,target ORACLE_HOME,target ORACLE_BASE,and PATH and oracle_user,time is "mm-dd-yyyy hh24:mi;ss"
##START_DATA is checking backup begin data, end_data is checking backup end time
##nbu client is client name, ORACLE_SID is db SID
#export start_date="03/16/2019 06:00:00"
#export end_date="03/19/2019 00:00:00"
#export restore_date="03/16/2019 23:00:00"
export CLIENT_NAME="cems.db.os"
export ORACLE_SID=cems
export ORACLE_HOME=/oracle/product/database/11.2.0
#export ORACLE_BASE= /oracle1/app/product/11.2.0/
export PATH=$PATH:$ORACLE_HOME/bin
export oracle_user=oracle
export new_log_path="/os/oradata/cems"
export new_data_path="/os/oradata/cems"
###export OLD_ORACLE_HOME=/db/bpo/oracleapp/database/11.2.0/db_1/dbs
###create direcotry for db
#mkdir -p /os/oradata/cems/archivelog
#mkdir -p /oracle/admin/cems/adump
#mkdir -p /oracle/diag/rdbms/cems/diag/rdbms
#mkdir -p /oracle/diag/rdbms/cems/diag/tnslsnr
#chmod -R 777 /oracle/admin/cems/adump
#chmod -R 777 /os/oradata/cems/archivelog
#chmod -R 777 /oracle/diag/rdbms/cems/diag
#chmod -R 777 /os/oradata/cems/
###config logfile and datafile change patch , 暂时不需要
##export old_log_path="/db/bcds/oradata/bcds/"
#export new_log_path="/datalv/bcds/"
##export old_data_path="/db/bcds/oradata/bcds"
##export new_data_path="/datalv/bcds"
## config os version is unix or linux
###for linux
export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep -a "cntrl" |awk '{print $8}'| head -1`
##for aix and hp
##export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep "cntrl" |awk '{print $8}'| head -1`
echo "##########section 1 is ok###############"
### mkdir
#cd $new_data_path
#mkdir archivelog
#cd $ORACLE_BASE
#mkdir diag diag/rdbms diag/tnslsnr
###### section 2 switch to oracle1 and keep root profile and begin to restore controlfile and mount db,如果碰到ORA-27101: shared memory realm does not exist,可以忽略
su $oracle_user -c "sqlplus / as sysdba "<<eof0
shutdown immediate;
startup nomount;
eof0
###set dbid= 89095998
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g" <<eof1
run {
allocate channel c1 type 'sbt_tape';
send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';
restore controlfile from '$controlfile';
release channel c1;
}
eof1
su $oracle_user -c "sqlplus / as sysdba "<<eof2
select status from v\$instance;
alter database mount;
eof2
echo echo "##########section 2 is ok###############"
### section 3 produce log file and data file change file
su $oracle_user -c "sqlplus / as sysdba "<<eof2
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/logpatch_$ORACLE_SID.sql
select replace(member,'/redo01.log','') from v\$logfile where GROUP# = 1;
spool off
eof2
export old_log_path=`grep os /tmp/logpatch_$ORACLE_SID.sql`
export old_data_path=`grep os /tmp/logpatch_$ORACLE_SID.sql`
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/datafile_$ORACLE_SID.sql
select 'set newname for datafile '||FILE#||' to '||''''||replace(name,'$old_data_path','$new_data_path')||''''||';' from v\$datafile;
spool off
db
sed '1d;$d' /tmp/datafile_$ORACLE_SID.sql > /tmp/datafile_path_$ORACLE_SID.sql
echo "##clean FRA AREA#####"
su $oracle_user -c "rman target / "<<eof2
crosscheck backup;
delete noprompt force backup;
delete noprompt force archivelog;
eof2
###add fix about RMAN-20207: INCARNATION
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/scn_$ORACLE_SID.sql
select max(INCARNATION#) from v\$database_incarnation where RESETLOGS_TIME < to_date('$restore_date','mm/dd/yyyy hh24:mi:ss');
spool off
db
sed '1d;$d' /tmp/scn_$ORACLE_SID.sql > /tmp/scn_start_$ORACLE_SID.sql
INCARNATION_NO=`cat /tmp/scn_start_$ORACLE_SID.sql`
####produce restore and recover command
echo "reset database to incarnation $INCARNATION_NO;" > /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "run { " >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c1 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c2 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c3 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c4 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
cat /tmp/datafile_path_$ORACLE_SID.sql >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "set until time \"to_date('$restore_date','mm/dd/yyyy hh24:mi:ss')\";">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "restore database;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "switch datafile all;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "recover database;">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c1;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c2;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c3;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c4;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "}" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
chmod 777 /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "##########section 3 is ok###############"
### section 4 begin to restore and recover
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g cmdfile=/tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql"
echo "##########section 4 is ok###############"
### section 5 begin to rename logfile and resetlogs open
su $oracle_user -c "sqlplus / as sysdba "<<eof5
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/logfile_$ORACLE_SID.sql
select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'$old_log_path','$new_log_path')||''';' from v\$logfile;
select 'alter database clear logfile group '|| GROUP#||';' from v\$logfile;
spool off
eof5
sed '/^SQL/d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
##sed '1d;$d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<eof6
select status from v\$instance;
@/tmp/logfile_path_$ORACLE_SID.sql
alter database open RESETLOGS;
eof6
echo echo "##########section 5 is ok finish ###############"
########for tempfile re-creation produce create new tempfile and drop old tempfile ,and execute it.
##export old_data_path=/tmp
su $oracle_user -c "sqlplus / as sysdba "<<db4
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
select 'ALTER TABLESPACE '||t.name||' add tempfile '||''''||replace(f.name,'$old_data_path','$new_data_path') ||''''||' size 10M REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;' from v\$tempfile f ,
(select ts#,name from v\$tablespace t where included_in_database_backup='NO') t where f.ts#= t.ts#;
spool off
db4
sed '1d;2d;$d' /tmp/tempfile_$ORACLE_SID.sql > /tmp/tempfile_add_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<db5
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
select 'alter tablespace '||t.name||' drop tempfile '||''''||f.name||''''||';' from v\$tempfile f ,(select ts#,name from v\$tablespace t where included_in_database_backup='NO') t
where f.ts#= t.ts#;
spool off
db5
sed '1d;2d;$d' /tmp/tempfile_$ORACLE_SID.sql > /tmp/tempfile_drop_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<db6
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
@/tmp/tempfile_add_$ORACLE_SID.sql
@/tmp/tempfile_drop_$ORACLE_SID.sql
spool off
db6
echo "##########section 6 is ok finish ###############"
###sample 1:
##准备阶段
#switch restore user profile to target database profile in nbu test machine
su - oracle1
cp profile_bcds .profile
####2 检查uid 和所有的gid 跟生产一致
usermod -u 1001 oracle1
groupmod -g 1001 dba
groupmod -g 1001 oinstall
### scripts 1
--the scirpt is used for restore db from vcs to a point to time recovery
--and the target datafile and logfile is different from source,the script is running in root user
###### section 1 config env
###config restore date, backup_start_date,end_start_date, nbu_client_name,ORACLE_SID,target ORACLE_HOME,target ORACLE_BASE,and PATH and oracle_user,time is "mm-dd-yyyy hh24:mi;ss"
export start_date="06/28/2018 06:00:00"
export end_date="06/29/2018 00:00:00"
export restore_date="06/28/2018 23:00:00"
export CLIENT_NAME="bcdp.db.os"
export ORACLE_SID=bcds
export ORACLE_HOME=/oracle1/app/product/11.2.0/dbhome_1
export ORACLE_BASE= /oracle1/app/product/11.2.0/
export PATH=$PATH:$ORACLE_HOME/bin
export oracle_user=oracle1
###export OLD_ORACLE_HOME=/db/bpo/oracleapp/database/11.2.0/db_1/dbs
###config logfile and datafile change patch
export old_log_path="/db/bcds/oradata/bcds/"
export new_log_path="/datalv/bcds/"
export old_data_path="/db/bcds/oradata/bcds"
export new_data_path="/datalv/bcds"
## config os version is unix or linux
###for linux
##export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep -a "cntrl" |awk '{print $8}'| head -1`
##for aix and hp
export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep "cntrl" |awk '{print $8}'| head -1`
echo "##########section 1 is ok###############"
### mkdir
#cd $new_data_path
#mkdir archivelog
#cd $ORACLE_BASE
#mkdir diag diag/rdbms diag/tnslsnr
###### section 2 switch to oracle1 and keep root profile and begin to restore controlfile and mount db
su $oracle_user -c "sqlplus / as sysdba "<<eof0
shutdown immediate;
startup nomount;
eof0
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g" <<eof1
set dbid= 89095998
run {
allocate channel c1 type 'sbt_tape';
send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';
restore controlfile from '$controlfile';
release channel c1;
}
eof1
su $oracle_user -c "sqlplus / as sysdba "<<eof2
select status from v\$instance;
alter database mount;
eof2
echo echo "##########section 2 is ok###############"
### section 3 produce log file and data file change file
##for target is already ok ,it meand target db is already started,revert datafile * to new location in target in /tmp/datafile_$ORACLE_SID.sql ,
### produce data file change file
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/datafile_$ORACLE_SID.sql
select 'set newname for datafile '||FILE#||' to '||''''||replace(name,'$old_data_path','$new_data_path')||''''||';' from v\$datafile;
spool off
db
sed '1d;$d' /tmp/datafile_$ORACLE_SID.sql > /tmp/datafile_path_$ORACLE_SID.sql
####produce restore and recover command
echo "run { " > /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c1 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c2 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c3 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c4 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
cat /tmp/datafile_path_$ORACLE_SID.sql >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "set until time \"to_date('$restore_date','mm/dd/yyyy hh24:mi:ss')\";">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "restore database;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "switch datafile all;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "recover database;">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c1;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c2;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c3;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c4;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "}" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
chmod 777 /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "##########section 3 is ok###############"
### section 4 begin to restore and recover
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g cmdfile=/tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql"
echo "##########section 4 is ok###############"
### section 5 begin to rename logfile and resetlogs open
su $oracle_user -c "sqlplus / as sysdba "<<eof5
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/logfile_$ORACLE_SID.sql
select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'$old_log_path','$new_log_path')||''';' from v\$logfile;
select 'alter database clear logfile group '|| GROUP#||';' from v\$logfile;
spool off
eof5
sed '/^SQL/d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
##sed '1d;$d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<eof6
select status from v\$instance;
@/tmp/logfile_path_$ORACLE_SID.sql
alter database open RESETLOGS;
eof6
echo echo "##########section 5 is ok finish ###############"
##准备阶段
#switch restore user profile to target database profile in nbu test machine
su - oracle1
cp profile_bcds .profile
####2 检查uid 和所有的gid 跟生产一致
usermod -u 1001 oracle1
groupmod -g 1001 dba
groupmod -g 1001 oinstall
### scripts 1
--the scirpt is used for restore db from vcs to a point to time recovery
--and the target datafile and logfile is different from source,the script is running in root user
###### section 1 config env
###config restore date, backup_start_date,end_start_date, nbu_client_name,ORACLE_SID,target ORACLE_HOME,target ORACLE_BASE,and PATH and oracle_user,time is "mm-dd-yyyy hh24:mi;ss"
export start_date="06/28/2018 06:00:00"
export end_date="06/29/2018 00:00:00"
export restore_date="06/28/2018 23:00:00"
export CLIENT_NAME="bcdp.db.os"
export ORACLE_SID=bcds
export ORACLE_HOME=/oracle1/app/product/11.2.0/dbhome_1
export ORACLE_BASE= /oracle1/app/product/11.2.0/
export PATH=$PATH:$ORACLE_HOME/bin
export oracle_user=oracle1
###export OLD_ORACLE_HOME=/db/bpo/oracleapp/database/11.2.0/db_1/dbs
###config logfile and datafile change patch
export old_log_path="/db/bcds/oradata/bcds/"
export new_log_path="/datalv/bcds/"
export old_data_path="/db/bcds/oradata/bcds"
export new_data_path="/datalv/bcds"
## config os version is unix or linux
###for linux
##export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep -a "cntrl" |awk '{print $8}'| head -1`
##for aix and hp
export controlfile=`/usr/openv/netbackup/bin/bplist -C $CLIENT_NAME -S pnbumaster -l -t 4 -s $start_date -e $end_date -R / | grep "cntrl" |awk '{print $8}'| head -1`
echo "##########section 1 is ok###############"
### mkdir
#cd $new_data_path
#mkdir archivelog
#cd $ORACLE_BASE
#mkdir diag diag/rdbms diag/tnslsnr
##########for target is not ok, it means target db is not started,revert datafile * to new location in source and copy to target
#su $oracle_user -c "sqlplus / as sysdba "<<db
#set escape on
#spool /tmp/datafile_$ORACLE_SID.sql
#set linesize 999 linesize 999 head off feedback off
#select 'set newname for datafile '||''||FILE#||''||' to '||chr(39)||replace(name,'$old_data_path','$new_data_path')||'''||'.dbf;' from v\$datafile;
#spool off
#db
##su $oracle_user -c "sqlplus / as sysdba "<<db1
##@/tmp/datafile_$ORACLE_SID.sql
##db1
###### section 2 switch to oracle1 and keep root profile and begin to restore controlfile and mount db
su $oracle_user -c "sqlplus / as sysdba "<<eof0
shutdown immediate;
startup nomount;
eof0
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g" <<eof1
set dbid= 89095998
run {
allocate channel c1 type 'sbt_tape';
send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';
restore controlfile from '$controlfile';
release channel c1;
}
eof1
su $oracle_user -c "sqlplus / as sysdba "<<eof2
select status from v\$instance;
alter database mount;
eof2
echo echo "##########section 2 is ok###############"
### section 3 produce log file and data file change file
##for target is already ok ,it meand target db is already started,revert datafile * to new location in target in /tmp/datafile_$ORACLE_SID.sql ,
### produce data file change file
su $oracle_user -c "sqlplus / as sysdba "<<db
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/datafile_$ORACLE_SID.sql
select 'set newname for datafile '||FILE#||' to '||''''||replace(name,'$old_data_path','$new_data_path')||''''||';' from v\$datafile;
spool off
db
sed '1d;$d' /tmp/datafile_$ORACLE_SID.sql > /tmp/datafile_path_$ORACLE_SID.sql
####produce restore and recover command
echo "run { " > /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c1 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c2 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c3 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "allocate channel c4 type 'sbt_tape';" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "send 'NB_ORA_SERV=pnbumaster,NB_ORA_CLIENT=$CLIENT_NAME';">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
cat /tmp/datafile_path_$ORACLE_SID.sql >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "set until time \"to_date('$restore_date','mm/dd/yyyy hh24:mi:ss')\";">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "restore database;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "switch datafile all;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "recover database;">> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c1;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c2;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c3;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "release channel c4;" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "}" >> /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
chmod 777 /tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql
echo "##########section 3 is ok###############"
### section 4 begin to restore and recover
su $oracle_user -c "rman target / catalog rman11g/rman11g@cat11g cmdfile=/tmp/restore_`date '+%y%m%d'`_$ORACLE_SID.sql"
echo "##########section 4 is ok###############"
### section 5 begin to rename logfile and resetlogs open
su $oracle_user -c "sqlplus / as sysdba "<<eof5
set escape on
set linesize 999 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/logfile_$ORACLE_SID.sql
select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'$old_log_path','$new_log_path')||''';' from v\$logfile;
select 'alter database clear logfile group '|| GROUP#||';' from v\$logfile;
spool off
eof5
sed '/^SQL/d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
##sed '1d;$d' /tmp/logfile_$ORACLE_SID.sql > /tmp/logfile_path_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<eof6
select status from v\$instance;
@/tmp/logfile_path_$ORACLE_SID.sql
alter database open RESETLOGS;
eof6
echo "##########section 5 is ok finish ###############"
### section 6 begin to rename logfile and resetlogs open
########for tempfile re-creation produce create new tempfile and drop old tempfile ,and execute it.
export old_data_path=/tmp
su $oracle_user -c "sqlplus / as sysdba "<<db4
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
select 'ALTER TABLESPACE '||t.name||' add tempfile '||''''||replace(f.name,'$old_data_path','$new_data_path') ||''''||' size '||f.bytes/1024/1024||'M REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;' from v\$tempfile f ,
(select ts#,name from v\$tablespace t where included_in_database_backup='NO') t where f.ts#= t.ts#;
spool off
db4
sed '1d;2d;$d' /tmp/tempfile_$ORACLE_SID.sql > /tmp/tempfile_add_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<db5
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
select 'alter tablespace '||t.name||' drop tempfile '||''''||f.name||''''||';' from v\$tempfile f ,(select ts#,name from v\$tablespace t where included_in_database_backup='NO') t
where f.ts#= t.ts#;
spool off
db5
sed '1d;2d;$d' /tmp/tempfile_$ORACLE_SID.sql > /tmp/tempfile_drop_$ORACLE_SID.sql
su $oracle_user -c "sqlplus / as sysdba "<<db6
set linesize 32760 pagesize 0 head off feedback off echo off verify off trimspool on
spool /tmp/tempfile_$ORACLE_SID.sql
@/tmp/tempfile_add_$ORACLE_SID.sql
@/tmp/tempfile_drop_$ORACLE_SID.sql
spool off
db6
echo "##########section 6 is ok finish ###############"
###new for debug tool pasue
1. 打开文本编辑器,在 /home/cheng/bin 目录中创建一名为pause的文本文件。
2.在pause文件中写入以下内容:
#!/bin/bash
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty raw
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
if [ -z "$1" ]; then
echo '请按任意键继续...'
else
echo -e "$1"
fi
get_char
保存并退出文本编辑器。
3.打开终端,执行以下命令:
chmod 0755 /home/cheng/bin/pause
---------------------
作者:Colin91
来源:CSDN
原文:https://blog.csdn.net/colin91/article/details/9119031
版权声明:本文为博主原创文章,转载请附上博文链接!
#############issue 1 https://blog.csdn.net/lldustc_blog/article/details/78348140
RMAN中通过时间点不完全恢复报ORA-01841的解决办法
环境
- 操作系统 oracle linux 6.5
- 数据库 oracle 11.2.0.4
执行脚本
run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
restore database;
recover database;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
错误及分析
执行脚本后报错
RMAN-03002: failure of recover command at ……..
RMAN-11003: failure during parse/execution of SQL …….
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
此处为貌似是我们的语句写错了,其实是oracle的bug
貌似有两个问题
需设置NLS_LANG环境变量
在执行rman命令前先执行export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
此处不能将restore database和recover database放在一个run块里,需在单独的run块中完成
run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
restore database;
}
- 1
- 2
- 3
- 4
- 5
- 6
run {
allocate channel c1 type disk;
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss";
set until time='2017-10-8 00:00:00';
recover database;
}
2个rman自动恢复的脚本的更多相关文章
- 【RMAN】TSPITR--RMAN表空间基于时间点的自动恢复
[RMAN]TSPITR--RMAN表空间基于时间点的自动恢复 一.1 BLOG文档结构图 一.2 前言部分 一.2.1 导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其 ...
- OCP读书笔记(7) - 使用RMAN执行恢复
7.Using RMAN to Perform Recovery 使用RMAN进行完全恢复system表空间文件丢失的恢复 模拟损坏: SQL> conn /as sysdba; SQL> ...
- rman备份/恢复
全备脚本 cat rman_full.sh #!/bin/bash export ORACLE_BASE=/opt/oracle export ORACLE_HOME=$ORACLE_BASE/pro ...
- RMAN的恢复篇
Oracle 数据库的恢复实际上包含了两个概念:数据库修复(RESTORE)与数据库恢复(RECOVER): 数据库修复:是指利用备份的数据库文件来替换已经损坏的数据库文件或者将其恢复到一个新的位置. ...
- Oracle RMAN备份恢复指导书
目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...
- 应用maven自动部署的脚本
@(编程) 最近写了一个自动部署的脚本,可以一键部署到测试服务器或者生产服务器上,包括一个函数脚本和一个调用脚本,比较简单,记录如下. 特点如下: 部署前自动备份 可以部署tomcat项目和java项 ...
- Oracle 11g RAC to RAC ADG搭建(一)采用rman备份恢复方式
(一)基础环境 主库 备库 操作系统 RedHat6.7 RedHat6.7 服务器名称 primarydb1primarydb2 standbydb1standbydb2 IP地址规划 192. ...
- 配置tmux在机器重启后自动恢复tmux工作现场,告别重启恐惧症
1. 问题出现的背景 通过ssh远程登录服务器在上面工作,有时候很有可能由于网络断开而导致ssh链接断开,或者下班后想继续在家登录到服务器继续工作.这些情况都需要服务器保持我们的工作环境,比如,vim ...
- Atlas 读写分离 & Atlas + MHA 故障自动恢复
目录 Atals 介绍 Atlas 主要功能 Atlas 相对于官方 MySQL-Proxy 的优势 Atlas 使用 Atlas 安装 Atlas 目录 Atlas 配置 Atlas 启动 Atla ...
随机推荐
- HDU4848 Wow! Such Conquering! —— dfs + 剪枝
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4848 题解: 一开始读错题目.以为每个点只能访问一遍.其实只要每个点都有被访问就可以了. 首先是用弗洛 ...
- Redis缓存服务搭建及实现数据读写 - Eric.Chen
发现博客园中好多大牛在介绍自己的开源项目是很少用到缓存,比如Memcached.Redis.mongodb等,今天得空抽时间把Redis缓存研究了一下,写下来总结一下,跟大家一起分享 一下.由于小弟水 ...
- 通过dom4j写.xml文件
步骤: 1.左键选中src,点击红圈2: 2.新建类: 3.开始写代码: package com.bjsxt.xml; import java.io.File; import java.io.File ...
- hdu 1280 前m大的数(排序)
题意:排序 思路:排序 #include<iostream> #include<stdio.h> #include<algorithm> using namespa ...
- 书写优雅的shell脚本(七)- ${COLUMN:-}
${COLUMN:-} 如果COLUMN是空变量,或者变量不存在,返回-后面的内容,如果变量有值返回这个值.
- mysql 数据库修改用户名和密码
因为经常修改数据库密码,也找到了几种修改数据库密码的方式,在这里给大家介绍下供大家参考通过navicat 管理数据库客户端来修改数据库密码: 选择数据库 --- 点击导航条的用户 --- 编辑用户 ...
- CodeForces - 840D:(主席树求出现区间出现次数大于某值的最小数)
Once, Leha found in the left pocket an array consisting of n integers, and in the right pocket q que ...
- C#视频取帧图
由于项目里页面有许多视频资料需要展示给用户查看,因此需要做一个视频列表,原设计是列表显示视频第一帧图,但实际上很多视频第一帧是纯黑底色. 于是想到用js利用canvas截图,最后发现由于浏览器跨域限制 ...
- char的定义在iOS和Android下是不同的
char is different in iOS and Android!跨平台开发时很容易忽略的非常坑爹的一个区别. 我的需求是实现一个算法,这个算法在iOS和Android下需要保持一致的结果,很 ...
- POJ - 3414 Pots BFS(著名倒水问题升级版)
Pots You are given two pots, having the volume of A and B liters respectively. The following operati ...