Configuring Oracle XStream - oracle

I'm trying to configure Oracle XStream out by official documentation
So, shortly, I'm connecting as sysdba
sqlplus / as sysdba
Then executing commands create create CDB user and give him privileges
> CREATE TABLESPACE xstream_tbs DATAFILE '$ORACLE/cdb/orcl/xstream_tbs.dbf' SIZE 25M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
> CREATE USER c##xstrmadmin IDENTIFIED BY password DEFAULT TABLESPACE xstream_tbs QUOTA UNLIMITED ON xstream_tbs container=all;
> GRANT CREATE SESSION, SET CONTAINER TO c##xstrmadmin CONTAINER=ALL;
After this step I should give permissions to user to use XStream
> BEGIN
DBMS_XSTREAM_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'c##xstrmadmin',
privilege_type => 'CAPTURE',
grant_select_privileges => TRUE,
container => 'ALL');
END;
/
On this stage, I'm getting this error:
ERROR at line 1:
ORA-44001: invalid schema
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH_IVK", line 3383
ORA-06512: at line 1
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH_IVK", line 3500
ORA-06512: at "SYS.DBMS_XSTREAM_AUTH", line 34
ORA-06512: at line 2
Current container is cdb$root
Googling gives actually nothing and I have no idea whats wrong as I'm following DBA documentation.

I guess I found workaround.
If you connect to oracle with
> sqlplus /nolog
And then connect as sysdba
> conn / as sysdba
Then all works fine!
If this is only one way to resolve problem with creating permissions then problem is in sqlplus or oracle itself. Sad!

Related

Oracle OLS LBACSYS Errors

I'm learning the OLS (Oracle Label Security) feature of Oracle, and here is my problem.
I executed those procedures to enabled the OLS feature. My current user was sys who have the sysdba privilege.
EXEC LBACSYS.CONFIGURE_OLS;
EXEC LBACSYS.OLS_ENFORCEMENT.ENABLE_OLS;
Then I logged in by LBACSYS account to create the OLS Policy, but it not worked.
CONN LBACSYS/LBACSYS;
BEGIN
SA_SYSDBA.CREATE_POLICY (
policy_name => 'emp_ols_pol',
column_name => 'ols_col',
default_options => 'read_control, update_control');
END;
/
Error messages
Error report -
ORA-65109: operation not allowed in CDB$ROOT
ORA-06512: at "LBACSYS.LBAC_LGSTNDBY_UTIL", line 100
ORA-06512: at "LBACSYS.LBAC_SYSDBA", line 80
ORA-06512: at "LBACSYS.LBAC_SYSDBA", line 138
ORA-06512: at "LBACSYS.LBAC_LGSTNDBY_UTIL", line 76
ORA-06512: at "LBACSYS.SA_SYSDBA", line 16
ORA-06512: at line 2
65109. 00000 - "operation not allowed in CDB$ROOT"
*Cause: An operation was attempted that is not supported in the Container
Database root.
*Action: Switch to a pluggable database to perform the operation.
Help me please, and thank you guys a lot!

Accessing a function against another owner in oracle?

I am having a function called fn_export and its owner is bhist. I am calling this function from ohist user using bhist.fn_export. While calling like this I am facing the below issue.
ORA-00942: table or view does not exist
ORA-06512: at "bhist.fn_export", line 442
ORA-06512: at line 20
I tried to verify all the tables in that function and I am able to access all those tables from ohist. I have execute grant on bhist.fn_export to ohist. Still I am having this issue. Can any one of you please help in resolving this issue?
Thanks,
Venkat
You need to grant EXECUTE privilege on this function to ohist user.
A syntax is:
GRANT EXECUTE ON function_name TO username;
You can connect as bhist user and grant the privilege using:
GRANT EXECUTE ON fn_export TO ohist;
You can also connect as SYS or SYSTEM, and use this command:
GRANT EXECUTE ON bhist.fn_export TO ohist;
See a below simple example (one user is named TEST and the other is named DEV):
SQL> connect test
Enter password:
Connected.
SQL> CREATE FUNCTION fn_export RETURN number AS
2 BEGIN
3 RETURN 20;
4 END;
5 /
Function created.
SQL> connect dev
Enter password:
Connected.
SQL> SELECT test.fn_export FROM dual;
SELECT test.fn_export FROM dual
*
ERROR at line 1:
ORA-00904: "TEST"."FN_EXPORT": invalid identifier
SQL> connect test
Enter password:
Connected.
SQL> grant execute on fn_export to dev;
Grant succeeded.
SQL> connect dev
Enter password:
Connected.
SQL> SELECT test.fn_export FROM dual;
FN_EXPORT
----------
20
SQL>

ORA-20000: Schema "HR" does not exist or insufficient privileges

I use Oracle 11g express. I try to install sample database HR. From cmd
sqlplus
system
123456
Error:
Comment created.
Commit complete.
BEGIN dbms_stats.gather_schema_stats( 'HR' , granularity => 'ALL' , cascade => TRUE , block_sample => TRUE ); END;
*
ERROR at line 1:
ORA-20000: Schema "HR" does not exist or insufficient privileges
ORA-06512: at "SYS.DBMS_STATS", line 3701
ORA-06512: at "SYS.DBMS_STATS", line 24470
ORA-06512: at "SYS.DBMS_STATS", line 24435
ORA-06512: at line 1
How I install sample database HR correctly?
Apparently the statement to create the user hr was not executed correctly, and despite that the execution of the hr_main.sql script is not stopped.
This worked for me:
Once as sysdba:
SQL> alter session set "_ORACLE_SCRIPT"=true;
Session altered.
SQL> create user hr identified by hr;
User created.
SQL> drop user hr cascade;
User droped.
SQL> #?/demo/schema/human_resources/hr_main.sql
...
User created.
...
Navigate to the PDB container as SYS user before executing the script
[oracle#af18354c958e /]$ sqlplus sys as sysdba
Enter password: password
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container = ORCLPDB1
SQL> #hr_main.sql
specify password for HR as parameter 1:
Enter value for 1: hr
specify default tablespeace for HR as parameter 2:
Enter value for 2: users
specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp
specify log path as parameter 4:
Enter value for 4: $ORACLE_HOME/demo/schema/log/
The problem is the line
create user hr identified by 123456a#
Because user is not created, you are getting other errors.
To resolve it do either of below
Remove special character from password. Or use underscores _ in password.
create user hr identified by 123456a
OR
Try enclosing password in double quotes. (I am not able to test it now. But if it doesn't work, try first option. I referred this link)
create user hr identified by "123456a#"

Oracle 11g. Unable to import dump files, even though schema is created

I have created a user in Oracle 11gR2, using the following script
create user cata
identified by cata
default tablespace tbs
temporary tablespace temp;
grant DBA to cata;
After trying to import a dump file using the command
impdp system/password#ORCL11 schemas=cata dumpfile=cata.dmp logfile=log.txt
i'm getting the following error
ORA-39002: invalid operation
ORA-39165: Schema ATGDB_CATA was not found.
Surprisingly, when i try to export a dump from the same schema, i'm able to do that. So, if the schema was not created properly then i should not be able to export the dump file as well, right ?
I have also checked in dba_users & the schema is created. Is there anything else that i can do which could resolve this problem
Out of the error message I guess that the original schema name was "atgdb_cata".
As you are now trying to import into a schema named "cata" you need to specify the parameter remap_schema
So for your case:
impdp system/password#ORCL11 schemas=atgdb_cata dumpfile=cata.dmp logfile=log.txt remap_schema=atgdb_cata:cata
Grant the roles of read and write on the Directory in which you created to the New User: EX:
GRANT READ, WRITE ON DIRECTORY dir_name TO NEW_USER:
Also grant the following role to the new user:
GRANT IMP_FULL_DATABASE TO NEW_USER;
Thanks!
NC
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 536
ORA-29283: invalid file operation
SOLUTION:
create or replace directory test_ dir as 'FOLDER_NAME' ;
that 'FOLDER_NAME' must has that dump file
step : 1
create folder SAMPLE under orcle_installed_path/sql/SAMPLE
put that dump file into that SAMPLE folder.
go to bin and execute ./sqlplus
and login
SQL>create or replace directory test_ dir as 'SAMPLE' ;
SQL> SQL> GRANT READ, WRITE on directory test_dir to 'USER';
SQL> GRANT IMP_FULL_DATABASE to 'USER';
exit
then impdb to import that dump

Oracle privilege missing for DBMS_SCHEDULER, ORA-27486 after GRANT CREATE JOB, CREATE EXTERNAL JOB

What additional privilege am I missing?
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
SQL> create user myUser identified by password default tablespace theData temporary tablespace temp;
User created.
SQL> grant connect, resource to myUser;
Grant succeeded.
SQL> GRANT READ,WRITE ON DIRECTORY tmp TO myUser;
Grant succeeded.
SQL> GRANT CREATE JOB TO myUser;
Grant succeeded.
SQL> GRANT CREATE EXTERNAL JOB TO myUser;
Grant succeeded.
SQL> connect myUser/password
Connected.
SQL>
SQL>
1 CREATE PROCEDURE shellScript
2 AS
3 /*-----------------------*/
4 v_sql UTL_FILE.FILE_TYPE;
5 v_shell UTL_FILE.FILE_TYPE;
6 /*=======================*/
7 BEGIN
8 /*=======================*/
9 -- write the sql script to /tmp/myUser-tmp-script.sql
10 v_sql:= UTL_FILE.FOPEN('TMP','myUser-tmp-script.sql','w');
11 UTL_FILE.PUT_LINE(v_sql,'select to_char(sysdate,''YYYYMMDDHR24MISS'') from dual'||';', FALSE);
12 UTL_FILE.FFLUSH(v_sql);
13 UTL_FILE.FCLOSE(v_sql);
14 -- write the shell script to /tmp/myUser-tmp-script.sh
15 v_shell:= UTL_FILE.FOPEN('TMP','myUser-tmp-script.sh','w');
16 UTL_FILE.PUT_LINE(v_shell,'#!/bin/bash', FALSE);
17 UTL_FILE.PUT_LINE(v_shell,'sqlplus myUser/password#sbox #/tmp/myUser-tmp-script.sql > /tmp/myUser-tmp-script.err', FALSE);
18 UTL_FILE.FFLUSH(v_shell);
19 UTL_FILE.FCLOSE(v_shell);
20 -- execute the shell script which executes the sql script
21 DBMS_SCHEDULER.PURGE_LOG(JOB_NAME=>'myJob');
22 DBMS_SCHEDULER.CREATE_JOB(JOB_NAME=>'myJob', JOB_TYPE=>'EXECUTABLE', JOB_ACTION=>'/bin/bash', NUMBER_OF_ARGUMENTS=>1, START_DATE=>SYSTIMESTAMP, ENABLED=>FALSE);
23 DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE('myJob', 1, '/tmp/myUser-tmp-script.sh');
24 DBMS_SCHEDULER.ENABLE('myJob');
25 USER_LOCK.SLEEP(500); -- give it 5 seconds to complete
26 -- clean up
27 UTL_FILE.FREMOVE('TMP', 'myUser-tmp-script.sh');
28 UTL_FILE.FREMOVE('TMP', 'myUser-tmp-script.sql');
29 /*=======================*/
30 END shellScript;
/
Procedure created.
SQL> SHOW ERRORS PROCEDURE shellScript
No errors.
SQL>
SQL>
SQL> execute shellScript;
BEGIN shellScript; END;
*
ERROR at line 1:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 411
ORA-06512: at "SYS.DBMS_ISCHED", line 452
ORA-06512: at "SYS.DBMS_SCHEDULER", line 1082
ORA-06512: at "MYUSER.SHELLSCRIPT", line 21
ORA-06512: at line 1
SQL>
According to TFM, PURGE_LOG requires the MANAGE SCHEDULER privilege:
GRANT MANAGE SCHEDULER TO xxx;
Wow, I found the problem... "myJob" was an existing package object in the database. I'm guessing my "insufficient privileges" were to replace the package object with a job object.
if you get the manage scheduler privilege, the next thing where this will fail is the none existing execute bits on the shell script. If the execute bits are in place, it will fail because it lacks the environment settings like PATH and ORACLE_HOME, needed to run SQL*Plus.
Besides that, why stick to 10g?
Oracle 11g has much better options to run external jobs, security implemented by credentials instead of some file in $ORACLE_HOME that defines the user to run the job.
There is some very nice reading available on this subject, see my profile.
I hope this helps,
Ronald.

Resources