select empno,ename,rowid,row_number() over(partition by empno,ename order by empno) as number1 from empbak; EMPNO ENAME ROWID NUMBER1 ---------- ---------- ------------------ ---------- 7369 SMITH AAAVuKAAEAAAADdAAA 1 7369 SMITH AAAVuKAAEAAAADbAAA 2 7369 test AAAVuKAAEAAAADdAAL 1 7369 test AAAVuKAAEAAAADdAAO 2 7499 ALLEN AAAVuKAAEAAAADdAAP 1 7499 ALLEN AAAVuKAAEAAAADdAAM 2 7521 WARD AAAVuKAAEAAAADbAAC 1 7521 WARD AAAVuKAAEAAAADdAAB 2 7566 JONES AAAVuKAAEAAAADdAAN 1 7566 JONES AAAVuKAAEAAAADdAAR 2 7654 MARTIN AAAVuKAAEAAAADdAAC 1 7654 MARTIN AAAVuKAAEAAAADbAAE 2 7698 BLAKE AAAVuKAAEAAAADbAAF 1 7698 BLAKE AAAVuKAAEAAAADdAAD 2 7782 CLARK AAAVuKAAEAAAADdAAE 1 7782 CLARK AAAVuKAAEAAAADbAAG 2 7788 SCOTT AAAVuKAAEAAAADbAAH 1 7788 SCOTT AAAVuKAAEAAAADdAAF 2 7839 KING AAAVuKAAEAAAADdAAG 1 7839 KING AAAVuKAAEAAAADbAAI 2 7844 TURNER AAAVuKAAEAAAADdAAH 1 7844 TURNER AAAVuKAAEAAAADbAAJ 2 7876 ADAMS AAAVuKAAEAAAADdAAI 1 7876 ADAMS AAAVuKAAEAAAADbAAK 2 7900 JAMES AAAVuKAAEAAAADdAAJ 1 7900 JAMES AAAVuKAAEAAAADbAAL 2 7902 FORD AAAVuKAAEAAAADbAAM 1 7902 FORD AAAVuKAAEAAAADdAAK 2 7934 MILLER AAAVuKAAEAAAADdAAb 1 7934 MILLER AAAVuKAAEAAAADdAAc 2
然后根据获取到的row_number()的值,将大于1的其他重复值删除
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
04:27:50 SCOTT@ boston> select empno,ename,rowid from (select empno,ename,rowid,row_number() over(partition by empno,ename order by empno) as number1 from empbak) where number1 > 1; EMPNO ENAME ROWID ---------- ---------- ------------------ 7369 SMITH AAAVuKAAEAAAADbAAA 7369 test AAAVuKAAEAAAADdAAO 7499 ALLEN AAAVuKAAEAAAADdAAM 7521 WARD AAAVuKAAEAAAADdAAB 7566 JONES AAAVuKAAEAAAADdAAR 7654 MARTIN AAAVuKAAEAAAADbAAE 7698 BLAKE AAAVuKAAEAAAADdAAD 7782 CLARK AAAVuKAAEAAAADbAAG 7788 SCOTT AAAVuKAAEAAAADdAAF 7839 KING AAAVuKAAEAAAADbAAI 7844 TURNER AAAVuKAAEAAAADbAAJ 7876 ADAMS AAAVuKAAEAAAADbAAK 7900 JAMES AAAVuKAAEAAAADbAAL 7902 FORD AAAVuKAAEAAAADdAAK 7934 MILLER AAAVuKAAEAAAADdAAc 15 rows selected.
根据获取到的rowid删除重复值
1
delete from empbak where rowid in (select rowid from (select empno,ename,rowid,row_number() over(partition by empno,ename order by empno) as number1 from empbak) where number1 > 1);
Trace file /data/u01/app/oracle/diag/rdbms/orcl/chicago/trace/chicago_ora_14486.trc Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options ORACLE_HOME = /data/u01/app/oracle/product/11.2.0.4/dbhome_1 System name: Linux Node name: dax-mysql-slave Release: 3.10.0-327.el7.x86_64 Version: #1 SMP Thu Nov 19 22:10:57 UTC 2015 Machine: x86_64 Instance name: chicago Redo thread mounted by this instance: 1 Oracle process number: 26 Unix process pid: 14486, image: oracle@dax-mysql-slave (TNS V1-V3)
*** 2019-03-16 20:17:45.310 *** SESSION ID:(131.5) 2019-03-16 20:17:45.310 *** CLIENT ID:() 2019-03-16 20:17:45.310 *** SERVICE NAME:(SYS$USERS) 2019-03-16 20:17:45.310 *** MODULE NAME:(sqlplus@dax-mysql-slave (TNS V1-V3)) 2019-03-16 20:17:45.310 *** ACTION NAME:() 2019-03-16 20:17:45.310 -- The following are current System-scope REDO Log Archival related -- parameters and can be included in the database initialization file. -- -- LOG_ARCHIVE_DEST='' -- LOG_ARCHIVE_DUPLEX_DEST='' -- -- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf -- -- DB_UNIQUE_NAME="orcl" -- -- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG' -- LOG_ARCHIVE_MAX_PROCESSES=4 -- STANDBY_FILE_MANAGEMENT=MANUAL -- STANDBY_ARCHIVE_DEST=?/dbs/arch -- FAL_CLIENT='' -- FAL_SERVER='' -- -- LOG_ARCHIVE_DEST_1='LOCATION=/data/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/arch' -- LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY' -- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM EXPEDITE NOVERIFY SYNC' -- LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY' -- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME' -- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)' -- LOG_ARCHIVE_DEST_STATE_1=ENABLE -- -- The following commands will create a new control file and use it -- to open the database. -- Data used by Recovery Manager will be lost. -- The contents of online logs will be lost and all backups will -- be invalidated. Use this only if online logs are damaged. -- After mounting the created controlfile, the following SQL -- statement will place the database in the appropriate -- protection mode: -- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/data/u01/app/oracle/oradata/orcl/redo01.log' SIZE 50M BLOCKSIZE 512, GROUP 2 '/data/u01/app/oracle/oradata/orcl/redo02.log' SIZE 50M BLOCKSIZE 512, GROUP 3 '/data/u01/app/oracle/oradata/orcl/redo03.log' SIZE 50M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE '/data/u01/app/oracle/oradata/orcl/system01.dbf', '/data/u01/app/oracle/oradata/orcl/sysaux01.dbf', '/data/u01/app/oracle/oradata/orcl/undotbs01.dbf', '/data/u01/app/oracle/oradata/orcl/users01.dbf' CHARACTER SET ZHS16GBK ; -- Commands to re-create incarnation table -- Below log names MUST be changed to existing filenames on -- disk. Any one log file from each branch can be used to -- re-create incarnation records. -- ALTER DATABASE REGISTER LOGFILE '/data/u01/app/oracle/product/11.2.0.4/dbhome_1 /dbs/arch1_1_1002593622.dbf'; -- ALTER DATABASE REGISTER LOGFILE '/data/u01/app/oracle/product/11.2.0.4/dbhome_1 /dbs/arch1_1_1003088967.dbf'; -- Recovery is required if any of the datafiles are restored backups, -- or if the last shutdown was not normal or immediate. RECOVER DATABASE USING BACKUP CONTROLFILE -- Database can now be opened zeroing the online logs. ALTER DATABASE OPEN RESETLOGS; -- Commands to add tempfiles to temporary tablespaces. -- Online tempfiles have complete space information. -- Other tempfiles may require adjustment. ALTER TABLESPACE TEMP ADD TEMPFILE '/data/u01/app/oracle/oradata/orcl/temp01.dbf' SIZE 30408704 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M; -- End of tempfile additions. --
*** 2019-03-16 20:17:54.765 Stopping background process SMCO
*** 2019-03-16 20:17:55.918 Stopping background process QMNC
*** 2019-03-16 20:17:56.918 Stopping background process MMNL
*** 2019-03-16 20:17:57.918 Stopping background process MMON
*** 2019-03-16 20:17:58.939 ksukia: Starting kill, flags = 1 ksukia: killed 0 out of 0 processes.
*** 2019-03-16 20:18:00.031 *** 2019-03-16 20:18:00.031 4329 krsh.c ARCH: Archival disabled due to shutdown: 1089
*** 2019-03-16 20:18:01.032 *** 2019-03-16 20:18:01.032 4329 krsh.c ARCH: Archival disabled due to shutdown: 1089
修改操作过程:
1 2 3 4 5 6 7
STARTUP NOMOUNT该行上面的内容全部删除 以--开头的内容全部删除;(vim 方法 :%s/^--.*//g) ***下的记录进程动态的内容全部删除 CREATE CONTROLFILE REUSE DATABASE替换为CREATE CONTROLFILE SET DATABASE RECOVER DATABASE USING BACKUP CONTROLFILE加上注释--RECOVER DATABASE USING BACKUP CONTROLFILE(也可删除) ORCL替换为CHICAGO (vim 方法 :%s/ORCL/CHICAGO/g) orcl替换为chicago (vim 方法 :%s/orcl/chicago/g)
[oracle@rac1 ~]$ expdp \"/ as sysdba\" directory=exp_data_dir full=y dumpfile=oibs_full.dmp cluster=n parallel=4 logfile=expdp.log exclude=STATISTICS Export: Release 11.2.0.4.0 - Production on Wed Mar 13 16:14:01 2019 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options ORA-39006: internal error ORA-39213: Metadata processing is not available
2、查看报错信息
1 2 3 4 5 6
[oracle@rac1 ~]$ oerr ora 39213 39213, 00000, "Metadata processing is not available" // *Cause: The Data Pump could not use the Metadata API. Typically, // this is caused by the XSL stylesheets not being set up properly. // *Action: Connect AS SYSDBA and execute dbms_metadata_util.load_stylesheets // to reload the stylesheets.
3、根据提示执行dbms_metadata_util.load_stylesheets命令
1 2 3 4 5 6 7 8 9 10 11 12
[oracle@rac1 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Mar 13 16:15:27 2019 Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options
wget https://tar.goaccess.io/goaccess-1.3.tar.gz tar -xzvf goaccess-1.3.tar.gz cd goaccess-1.3/ ./configure --enable-utf8 --enable-geoip=legacy make make install
cd /data/soft wget http://fallabs.com/tokyocabinet/tokyocabinet-1.4.48.tar.gz tar -zxvf tokyocabinet-1.4.48.tar.gz cd tokyocabinet-1.4.48 ./configure --prefix=/usr/local --enable-off64 --enable-fastest make make install
SYS@ boston> alter system set global_names=true; SYS@ boston> create database link oibs1 connect to test identified by oracle using 'oibs1'; Database link created. SYS@ boston> select * from t1@oibs1; ID ---------- 1 2 SYS@ boston> create database link oibs connect to test identified by oracle using 'oibs1'; Database link created. Elapsed: 00:00:00.03 SYS@ boston> select * from t1@oibs; select * from t1@oibs * ERROR at line 1: ORA-02085: database link OIBS connects to OIBS1
18:50:14 SYS@ boston> show parameter service_names NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string boston
修改service_names
1 2 3
19:56:42 SYS@ boston> alter system set service_names='chicago.us.oracle'; System altered. Elapsed: 00:00:00.23
查看service_names已修改
1 2 3 4
19:56:56 SYS@ boston> show parameter service_names NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago.us.oracle
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dax-mysql-slave)(PORT=1521))) Services Summary... Service "boston" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
再次修改service_names
1 2 3
19:56:59 SYS@ boston> alter system set service_names='chicago.us.oracle.com'; System altered. Elapsed: 00:00:00.12
查看监听
1 2 3 4 5 6 7 8 9 10 11
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dax-mysql-slave)(PORT=1521))) Services Summary... Service "boston" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle.com" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
chicago.us.oracle的服务名被替代为chicago.us.oracle.com
5.2、在db_domain存在的情况下(如果没有,可以自己修改,修改该值需要重启库)
先修改db_domain值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
22:18:05 SYS@ boston> alter system set db_domain='us.oracle.cn' scope=spfile; System altered. 22:18:22 SYS@ boston> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. 22:18:38 SYS@ boston> startup ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2253664 bytes Variable Size 503319712 bytes Database Buffers 1090519040 bytes Redo Buffers 7319552 bytes Database mounted. Database opened. 22:19:36 SYS@ boston> show parameter db_domain NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_domain string us.oracle.cn
修改service_names,在不指定后缀的情况下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
22:45:57 SYS@ boston> alter system set service_names='chicago'; System altered. Elapsed: 00:00:00.11 22:46:45 SYS@ boston> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago
[oracle@dax-mysql-slave admin]$ lsnrctl status ...... Services Summary... Service "boston.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully
22:46:49 SYS@ boston> alter system set service_names='chicago.cn.oracle.com'; System altered. Elapsed: 00:00:00.15 22:48:40 SYS@ boston> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ service_names string chicago.cn.oracle.com [oracle@dax-mysql-slave admin]$ lsnrctl status ..... Services Summary... Service "boston.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "bostonXDB.us.oracle.cn" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... Service "chicago.cn.oracle.com" has 1 instance(s). Instance "boston", status READY, has 1 handler(s) for this service... The command completed successfully