I am running a script with SQLPlus in an Oracle DB which creates extra tablespaces. Here is the code of the script:
CREATE TABLESPACE FAR_YELLOW_FISH
DATAFILE
'$ORADATA/node03/faryellowfish01.dbf' SIZE 200M,
'$ORADATA/node03/faryellowfish02.dbf' SIZE 200M;
CREATE TABLESPACE WET_BROWN_SOUP
DATAFILE
'$ORADATA/node01/wetbrownsoup01.dbf' SIZE 100M,
'$ORADATA/node03/wetbrownsoup02.dbf' SIZE 100M;
CREATE TABLESPACE EASY_ORANGE_DISK
DATAFILE
'$ORADATA/node03/easyorangedisk01.dbf' SIZE 100M,
'$ORADATA/node03/easyorangedisk02.dbf' SIZE 100M,
'$ORADATA/node02/easyorangedisk03.dbf' SIZE 100M,
'$ORADATA/node02/easyorangedisk04.dbf' SIZE 100M;
CREATE TABLESPACE WET_YELLOW_OVEN
DATAFILE
'$ORADATA/node01/wetyellowoven01.dbf' SIZE 100M;
Before this I run the following:
sqlplus /nolog
connect / as sysdba
create SPFILE from PFILE;
startup nomount
and a script which creates main tablespaces - it works properly.
When running the script, that I mentioned first, I get the following error: ORA-01109: database not open. It appears for each CREATE TABLESPACE expression.
As a solution I tried to run ALTER DATABASE OPEN; but the answer was ORA-01507: database not mounted.
I guess, there is something wrong with the script, but not sure about that.
How can I solve it?
Your startup script isn't starting the database.
To start the database, do this:
sqlplus /nolog
connect / as sysdba
startup
Also, do not use environment variables (i.e. $ORADATA) in your SQL script. sqlplus won't know what they mean. Include the full path.
Related
we are starting to work with oracle multitenant architecture, and modify our custom shell commands accordingly. so in the aspect of running an SQLPlus query against the CDB, nothing has really much changed, we are still declaring the Oracle_HOME and Oracle_SID environment variables, and concatenating the actual query and the user and password credentials, like this:
export ORACLE_SID=contdev;export ORACLE_HOME=/oracle/app/oracle/product/19.3;printf "SHOW CON_NAME;"| $ORACLE_HOME/bin/sqlplus -s 'c##devuser/devpassword'
but we are struggling to achieve the same for the PDB, as we don't use tnsnames, we still required to connect with user name and password, with a one liner shell command, not a script. due to our security team policy.
searching on web, we have found that another environment variable is available for the PDB, named: ORACLE_PDB_SID. but when we trying to ran the following command:
export ORACLE_SID=contdev;ORACLE_PDB_SID=contDev1;export ORACLE_HOME=/oracle/app/oracle/product/19.3;printf "SHOW CON_NAME;"| $ORACLE_HOME/bin/sqlplus -s 'c##devuser/devpassword'
We are still getting the output from the root container, and not the PDB:
CON_NAME
------------------------------
CDB$ROOT
Another search on the web, we found that we need use ALTER SESSION SET CONTAINER=contDev1; but it's not clear how to use this, in the above command.
After connecting to the Oracle database, just type show pdbs:
SQL> show pdbs
SQL> alter session set container=<DB_NAME>_PDB;
SQL> show pdbs
I am following these instructions.
I have created a docker container like this:
docker run --name oracle \
-p 1521:1521 \
-e ORACLE_SID=ORASID \
-e ORACLE_PDB=ORAPDB \
-e ORACLE_PWD=F1f#f23_ \
-v /mnt_point/oradata:/home/oracle/oradata \
oracle/database:12.2.0.1-ee
The output is:
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Completed: alter pluggable database ORAPDB open
2017-08-07T19:16:31.190780+00:00
ORAPDB(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORASID/ORAPDB/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORAPDB(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORASID/ORAPDB/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORAPDB(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORAPDB(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2017-08-07T19:16:32.867558+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORASID/control01.ctl' SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORAPDB SAVE STATE
Completed: ALTER PLUGGABLE DATABASE ORAPDB SAVE STATE
I kill it via ctrl+c. I then run:
docker start oracle
docker logs -f oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
ORAPDB(3):Undo initialization finished serial:0 start:508498668 end:508498772 diff:104 ms (0.1 seconds)
ORAPDB(3):Database Characterset for ORAPDB is AL32UTF8
ORAPDB(3):Opatch validation is skipped for PDB ORAPDB (con_id=0)
2017-08-07T19:25:39.799508+00:00
ORAPDB(3):Opening pdb with no Resource Manager plan active
Pluggable database ORAPDB opened read write
Starting background process CJQ0
Completed: ALTER DATABASE OPEN
2017-08-07T19:25:40.536753+00:00
CJQ0 started with pid=38, OS id=239
2017-08-07T19:25:42.538433+00:00
Shared IO Pool defaulting to 64MB. Trying to get it from Buffer Cache for process 77.
===========================================================
Dumping current patch information
===========================================================
No patches have been applied
===========================================================
I then attempt to connect like this:
docker exec -ti oracle sqlplus pdbadmin#ORAPDB
The result is:
ORA-12154: TNS:could not resolve the connect identifier specified
It then asks me for a username. Regardless of which user SYS, SYSTEM or PDBADMIN, I cannot connect. I have retyped the password (F1f#f23_) a multitude of times to make sure it was not a typo. Any thoughts on this would be appreciated.
I've encountered this with those images, too. You will first have to open the pluggable database before you can connect to it.
I do that with something like this:
docker exec -ti oracle sqlplus / as sysdba
alter pluggable database pdb1 open;
Yes, I got the same error after setting up Oracle database in docker too.
So first check the instance is running (and look for the ORACLE_SID):
The Oracle SID is ORCLCDB.
If you don't have the environment set for ORACLE_SID, you get:
Connection failed.
But after you set your ORACLE_SID:
And now you no longer get the connection failure error, but a different SYSDBA instead.
Just add "/ as sysdba" to your entire sqlplus command and you are good to go.
Once the container has been started and the database created you can connect to it just like to any other database by one of the following methods:
1) sqlplus sys/<your password>#//localhost:1521/<your SID> as sysdba
2) sqlplus system/<your password>#//localhost:1521/<your SID>
3) sqlplus pdbadmin/<your password>#//localhost:1521/<Your PDB name>
Running SQL*Plus in a Docker container
You may use the same Docker image you used to start the database, to run sqlplus to connect to it, for example:
docker run --rm -ti oracle/database:12.2.0.1-ee sqlplus pdbadmin/<yourpassword>#//<db-container-ip>:1521/ORCLPDB1
Another option is to use docker exec and run sqlplus from within the same container already running the database:
docker exec -ti <container name> sqlplus pdbadmin#ORCLPDB1
To run your Oracle Database Docker image use the docker run command as follows:
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:12.2.0.1-ee
Parameters:
--name: The name of the container (default: auto generated)
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
-e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be owned by the Unix user "oracle" or set appropriately.
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
useful: https://github.com/oracle/docker-images/tree/master/OracleDatabase
In my case, the definition of environment variable TNS_ADMIN was causing the issue with ORA-12154.
I could successfully connect to the instance inside of the XE container: sqlplus test/test#//localhost:1521/XEPDB1, but not from outside.
After removing TNS_ADMIN it worked. I think, sqlplus takes TNS_ADMIN setting, and if it exists, it takes the tnsnames.ora data to resolve the connection. But of course, the Oracle XE instance from inside docker is not listed there.
As an alternative, you could use this syntax, which works although there is a tnsnames.ora defined: sqlplus test/test#'(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XEPDB1)))'
This instruction worked for me:
Starting SQL*Plus and Connecting to the Database
https://docs.oracle.com/database/121/ADMQS/GUID-DE8A79BD-FAE4-4364-98FF-D2BD992A06E7.htm#ADMQS0361
Basically get into the oracle container, then enter sqlplus. type SYS AS SYSDBA at the user name prompt, and then password. After that, I create the user and tables.
I think you are looking for this.
datasource:
url: jdbc:oracle:thin:#//localhost:1521/ORCLPDB1.localdomain
username: SYS as SYSDBA
password: Oradoc_db1
I wrote the following commands:
create directory orcl_full as '/oradata3/datapump/full_export';
create user user1 identified by admin12;
grant read,write on directory orcl_full to user1;
grant exp_full_database to user1;
But when I tried exporting data using expdp command, it did not work:
expdp user1#ri/admin12#ORCL directory=orcl_full dumpfile=orclfull.dmp logfile=full_export.log FULL=YES;
Here is the error I get:
ORA-31626: job does not exist
ORA-31633: unable to create master table "user1.SYS_EXPORT_FULL_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1048
ORA-01950: no privileges on tablespace 'USERS'
I am stuck here, can someone kindly help me. In the tutorials, this command was working.
ORA-31626: job does not exist
ORA-31633: unable to create master table
Datapump uses a master table to manage the export job. Like any other table it needs storage which means it needs to write to a tablespace.
ORA-01950: no privileges on tablespace 'USERS'
When you created user1 account you did not grant it any tablespace privileges. So it cannot create any tables and that's why the job fails. The solution is quite simple: grant quota on the USERS tablespace (the default tablespace if no other is specified for the user account).
alter user user1 quota unlimited on users;
"got the following error :SP2-0734: unknown command beginning "expdp use..." - rest of line ignored. "
expdp is an OS executable. Your error is a SQL*plus error, which is a SQL client. Either fire up a terminal window and run the OS command there, or shell out from SQL*Plus using the host command.
This command worked :
expdp user1#ri15/$d_pass directory=orcl_full dumpfile=orclfull.dmp logfile=full_export.log FULL=YES;`
I am trying to create database using Oracle 11g R2 on windows 2008 server, when I run script to create database instance I will get the following error message
ERROR at line 1:
ORA-01109: database not open
grant select on ALL_MVIEW_DETAIL_PARTITION to public with grant option
*
ERROR at line 1:
ORA-01109: database not open
logged on as administrator.`
Thanks,
usermma
Login to Oracle with root
su - oracle
sqlplus / as sysdba
create user username identified by password;
Exception : ORA-01109 Database not open
To resolve this i trie below steps and succesfully created the schema.
Please verify the ORA_HOMEPATH/dbs/sgadef.dbf
Make ensure that after shutting down the Oracle server,if you find any services running on machine by entering below command
ps -ef | grep ora_ | grep DBName(sid)
Kill the processes if you find any by using kill command
kill -9 PID
Please check below file exists in mentioned path; if not please create.
ORACLE_HOMEPATH/dbs/lk<sid>
start mount; If the server is started use close immediate
SQL> alter database close;
Database altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down
SQL> startup mount
ORACLE instance started.
Total System Global Area 126951228 bytes
Fixed Size 454460 bytes
Variable Size 109051904 bytes
Database Buffers 16777216 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> select open_mode from v$database;
OPEN_MODE
----------
MOUNTED
SQL> alter database open;
Database altered.
Now you can create your own schema as the database is open
SQL> create user schemaname identified by password;
SQL> grant resource,connect to schema name;
grant permission succeded.
I have done above steps to create a schema when database is not open.
Execute below Commands Sequentially....
> sqlplus
username/password = sys/*******
SQL> shutdown immediate;
SQL> startup mount;
SQL> recover database;
SQL> alter database open;
How did you create the script(s)? What does it do? Is there some reason you're not using the Database Configuration Assistant to do this? It may be simply a matter of not having the service for the instance created via oradim.
I want to connect user sys in sqlplus of oracle but after I connect, I type like this:
sqlplus sys as sysdba
password:123456
Error:
ORA-01030:insufficient privilege
warning:You are no longer to connect oracle.
Does anyone help me to solve my problem?
Your example looks a little garbled; to connect to sqlplus via the command line, with a user sys and password 123456:
sqlplus sys/123456 as sysdba
or
sqlplus "sys/123456 as sysdba"
prior to Oracle 10. If you are already inside sqlplus (as I assume from the fact that your example starts with a SQL>), you use the connect command:
SQL> connect sys/123456 as sysdba
In all cases, if you haven't set the environment variable ORACLE_SID, you need to specify that after the password, like this:
sqlplus sys/123456#<mydbname> as sysdba
where <mydbname> is either of the form <hostname>/<sid>, if you're using Oracle 10 or later, or a valid entry from your tnsnames.ora file (located in $ORACLE_HOME/network/admin) for all versions.
Is your operating system user account that you are logged in as a member of the ORA_DBA group (windows) or the DBA group (*nix)?
If the answer is yes, then the next thing to check is for the existence of the ORACLE_HOME\database\orapwORCL.ora file, which contains the passwords for all of the users defined as sysdba users. If it does not exist, you need to shutdown the database and execute the orapwd utility:
cd ORACLE_HOME\database
orapwd file=orapwORCL.ora password=123456 entries=10
This defines the sys password as 123456. You should then be able to start up the database and connect sys/123456 as sysdba
The password file must exist for password=based authentication on sysdba logins. The reason for this is the fact that sysdba connections must be allowed when the database is not up and the database cannot authenticate you.