SPFILE cannot be specified for a pluggable database - database

I wanted to create a SPFILE from an existant PFILE but i keep getting the error on SQL-Plus Linux :
SPFILE cannot be specified for a pluggable database
Am just a beginner i followed these instructions before trying to create the SPFILE :
Log on as SYS.
Disconnect from database (using shutdown)
Create SPFILE from PFILE
This is the command i used to create SPFILE :
CREATE SPFILE = '/u01/app/oracle/product/version/db_1/dbs/spfileorclcdb.ora' FROM PFILE = '/u01/app/oracle/product/version/db_1/dbs/init.ora';
These are the files present in the directory dbs :
Am just a learning, i don't know if i should delete the default SPFILE and then try to create another ?

Related

how to import a dmp file with profiles from a CDB db to a PDB DB instance using impdp in Oracle 12c?

I have a dmp file from a CDB(don't know exactly) in another server from where, I was given a dmp file which was exported using expdp(possibly). I want to import it into a PDB instance on an Oracle 12c server which I have.
I extracted the sql file for the dmp file and there is profile by the name of 'C##APPPROF'. This dmp is of 2 schemas and the import fails where it tries to run 'CREATE USER' because the profile name doesn't exist.
According to Oracle 12c docs, I cannot create a profile for a PDB instance in Oracle 12c starting with 'C##' since that is the convention for creating profiles in a CDB instance.
In a non-CDB, a profile name cannot begin with C## or c##.
This is the command which is currently used.
impdp "sys/Oradoc_db1#ORCLPDB1 as sysdba" directory=MY_DATA_PUMP_DIRECTORY dumpfile=corp.dmp logfile=MY_DATA_PUMP_DIRECTORY:logfile.log exclude=GRANT
Is there a way, I can overcome this ?
With the help of the comment made by pmdba, I created the users in my db before importing the dmp file and then the impdp command as follows
impdp \"sys/Oradoc_db1#ORCLPDB1 as sysdba\" directory=MY_DATA_PUMP_DIRECTORY dumpfile=corp.dmp logfile=MY_DATA_PUMP_DIRECTORY:log.log exclude=GRANT schemas=user1,user2 transform=OID:n transform=segment_attributes:n
The system will still try to create the users and will show error that user cannot be created, but the dmp file will work just fine.
Also, every time I have to reimport a new dmp file or do an import again,
I do the following commands:
DROP USER USER1 CASCADE;
DROP USER USER2 CASCADE;
CREATE USER "USER2" IDENTIFIED BY "PASSWORD123"
DEFAULT TABLESPACE "CORPORATE"
TEMPORARY TABLESPACE "TEMP";
CREATE USER "USER1" IDENTIFIED BY "PASSWORD1234"
DEFAULT TABLESPACE "TB1"
TEMPORARY TABLESPACE "TEMP";

Error while create PDB database from another existing PDB in Oracle

I am struggling with an error when using create pluggable database from command. My config is:
HOST_A - source CDB with couple of PDBs with ASM
HOST_B - destination CDB with couple of existing PDBs with ASM
I would like to create a new pluggable database on HOST_B using dblink to HOST_A and "create pluggable database X from dbLink" statement, however I'm getting this error:
ORA-65169 Error encountered while attempting to copy file -- path to .DBF file on HOST_A
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""
I have checked above path to .dbf file and owner on HOST_A - it exists and has correct owner. Also, HOST_B has enough space to create new snapshot. What makes that even more weird, is that I have very similar HOST_C with same init parameters and it works without any problem.
I noticed on HOST_B oracle has copied these files and placed them under valid ASM mount point with correct name etc, however create pluggable database still fails.
Any ideas?

Oracle DB : What is difference between spfile and init.ora file?

I have tried to understand through oracle docs but could not get it properly Any body please explain.
What is difference between spfile and init.ora file?
Thanks.
init.ora
init.ora or the pfile(parameter file) is a simple text file which can be updated by a standard editor like vi
which contains the various initialization parameters used while starting a database instance.
Here is a sample init.ora file:
db_cache_size = 176000M
db_2k_cache_size = 2048M
db_16k_cache_size = 99000M
db_keep_cache_size = 600000M
db_recycle_cache_size = 64000M
shared_pool_size = 14000M
We need to restart the database after editing the init.ora using a text editor so that the changes can come into effect.
If we want to start a remote db we need a local pfile.
RMAN(Recovery manager) which helps in data backup recovery process does not keep the backup of pfile or init.ora file.
spfile
The Oracle spfile is a binary representation of the text based init.ora file or pfile( parameter file) which contains the various initialization
parameters used while starting a database instance.Came into existence in and after Oracle 9i.
We do not edit this file using an editor as it is a binary file and may get corrupted and which may lead to your database instance not starting rather
it is altered by using the alter system query.
An example of editing a spfile :
ALTER SYSTEM SET open_cursors=300 SCOPE=SPFILE;
The changes come into effect after running the Alter system query and we do not need to restart the database.
We do not need a local copy in case of spfile if we need to start a remote database.
As this file is maintained by the server the parameters are validated before they are accepted.
RMAN keeps the backup of spfile.
By default our database uses pfile to start we can change that and create a spfile from a pfile or init.ora file by using the following query and we don't even need to restart the db.
sqlplus / as sydba;
CREATE SPFILE FROM PFILE='/u01/oracle/dbs/init.ora;
The difference between init.ora and spfile.
init.ora and spfile both contains Database parameters info. With
spfile you can set Oracle database settings with the ALTER SYSTEM
command that is used in sqlplus to add/Modify/delete settings.
However for init.ora you edit it as a text file because init.ora
saved in the format of ASCII.
init.ora info is read by oracle engine at the time of database
instance . in spfile modifications can applicable without restarting
oracle database.
When an Oracle database is started, the process will always use
spfile.ora, if it exists. If the spfile.ora is not found, the
init.ora would be used on startup.

How to change Oracle default data pump directory to import dumpfile?

I'm using impdp to import a backup. But I want change default directory dumpfile.
$ impdp system/password#$ORACLE_SID schemas=USER_SCHEMA dumpfile=mydumpfile.dmp logfile=impdpmydumpfile.log
Import: Release 11.2.0.3.0 - Production on Mon Mar 16 09:32:05 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-31640: unable to open dump file "/u01/app/oracle/admin/mydatabase/dpdump/mydumpfile.dmp" for read
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
With the directory parameter:
impdp system/password#$ORACLE_SID schemas=USER_SCHEMA directory=MY_DIR \
dumpfile=mydumpfile.dmp logfile=impdpmydumpfile.log
The default directory is DATA_PUMP_DIR, which is presumably set to /u01/app/oracle/admin/mydatabase/dpdump on your system.
To use a different directory you (or your DBA) will have to create a new directory object in the database, which points to the Oracle-visible operating system directory you put the file into, and assign privileges to the user doing the import.
I want change default directory dumpfile.
You could create a new directory and give it required privileges, for example:
SQL> CREATE DIRECTORY dmpdir AS '/opt/oracle';
Directory created.
SQL> GRANT read, write ON DIRECTORY dmpdir TO scott;
Grant succeeded.
To use the newly created directory, you could just add it as a parameter:
DIRECTORY=dmpdir
Oracle introduced a default directory from 10g R2, called DATA_PUMP_DIR, that can be used. To check the location, you could look into dba_directories:
SQL> select DIRECTORY_NAME, DIRECTORY_PATH from dba_directories where DIRECTORY_NAME = 'DATA_PUMP_DIR';
DIRECTORY_NAME DIRECTORY_PATH
-------------------- --------------------------------------------------
DATA_PUMP_DIR C:\app\Lalit/admin/orcl/dpdump/
SQL>
use DIRECTORY option.
Documentation here:
http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_import.htm#SUTIL907
DIRECTORY
Default: DATA_PUMP_DIR
Purpose
Specifies the default location in which the import job can find the dump file set and where it should create log and SQL files.
Syntax and Description
DIRECTORY=directory_object
The directory_object is the name of a database directory object (not the file path of an actual directory). Upon installation, privileged users have access to a default directory object named DATA_PUMP_DIR. Users with access to the default DATA_PUMP_DIR directory object do not need to use the DIRECTORY parameter at all.
A directory object specified on the DUMPFILE, LOGFILE, or SQLFILE parameter overrides any directory object that you specify for the DIRECTORY parameter. You must have Read access to the directory used for the dump file set and Write access to the directory used to create the log and SQL files.
Example
The following is an example of using the DIRECTORY parameter. You can create the expfull.dmp dump file used in this example by running the example provided for the Export FULL parameter. See "FULL".
> impdp hr DIRECTORY=dpump_dir1 DUMPFILE=expfull.dmp
LOGFILE=dpump_dir2:expfull.log
This command results in the import job looking for the expfull.dmp dump file in the directory pointed to by the dpump_dir1 directory object. The dpump_dir2 directory object specified on the LOGFILE parameter overrides the DIRECTORY parameter so that the log file is written to dpump_dir2.
You can use the following command to update the DATA PUMP DIRECTORY path,
create or replace directory DATA_PUMP_DIR as '/u01/app/oracle/admin/MYDB/dpdump/';
For me data path correction was required as I have restored the my database from production to test environment.
Same command can be used to create a new DATA PUMP DIRECTORY name and path.

How to move data files (oradata) from corrupted Oracle's11g new Oracle 11g?

I am using Oracle version 11g and Oracle Linux 6.5 . But Oracle 11g damaged.
How to move data files (oradata) from old corrupted Oracle's11g in new Oracle 11g and startup database ?????
1) Create Pfile from spfile ( This step is not needed if DB is already running on pfile)
sqlplus "/as sysdba"
create pfile from spfile;
2) Shutdown database
sqlplus "/as sysdba"
shu immediate;
3) Move pfile and password file from old $ORACLE_HOME/dbs to new $ORACLE_HOME/database (this is Windows specific, if you are using unix/linux folder is dbs instead of database)
4) Edit pfile and replace controlfile parameter with new location.
5) set New oracle_home parameter and path location
6) Login to sqlplus and create spfile from pfile.
sqlplus "/as sysdba"
create spfile from pfile;
7) Follow below link to change file location in control file.
http://docs.oracle.com/cd/B28359_01/server.111/b28310/dfiles005.htm#ADMIN11431
8) Open database.
alter database open.

Resources