4 этап - инициализация базы CarabiDB
Шаг 1. Поменять поле [USER],[PASSWORD],[UTL_FLIE_DIR],[BACKUP_DIR]
mkdir /home/oracle/utlfile
mkdir /home/oracle/backup
export NEWUSER=csptest
export NEWPASSWORD=carabi2002
export UTL_FLIE_DIR=carabi2002
export BACKUP_DIR=carabi2002
cat USER<< -EOT уникальный >> PASSWORD=carabi2002
UTL_FLIE_DIR=/home/oracle/utlfile create-user.sql
BACKUP_DIR=/home/oracle/backup
create user [USER]$NEWUSER
identified by [PASSWORD]$NEWPASSWORD
default tablespace USERS
temporary tablespace TEMP
quota unlimited on sysaux
quota unlimited on system
quota unlimited on users
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to [USER];$NEWUSER;
grant resource, ctxapp to [USER];$NEWUSER;
grant imp_full_database to [USER];$NEWUSER;
-- Grant/Revoke system privileges
grant create procedure to [USER];$NEWUSER;
grant create sequence to [USER];$NEWUSER;
grant create synonym to [USER];$NEWUSER;
grant create table to [USER];$NEWUSER;
grant create trigger to [USER];$NEWUSER;
grant create type to [USER];$NEWUSER;
grant create view to [USER];$NEWUSER;
grant alter system to [USER];$NEWUSER;
grant alter session to [USER];$NEWUSER;
grant debug any procedure to [USER];$NEWUSER;
grant debug connect session to [USER];$NEWUSER;
-- Grant/Revoke objects
grant select on sys.v_$lock to [USER];$NEWUSER;
grant execute on SYS.DBMS_LOGMNR to [USER];$NEWUSER;
grant execute on SYS.DBMS_PROFILER to [USER];$NEWUSER;
grant select on SYS.V_$LOGMNR_CONTENTS to [USER];$NEWUSER;
grant select on SYS.V_$MYSTAT to [USER];$NEWUSER;
grant select on SYS.V_$LOGFILE to [USER];$NEWUSER;
grant select on SYS.V_$OPEN_CURSOR to [USER];$NEWUSER;
grant select on SYS.V_$SESSION to [USER];$NEWUSER;
grant select on SYS.V_$PROCESS to [USER];$NEWUSER;
grant select on SYS.DBMS_LOCK_ALLOCATED to [USER];$NEWUSER;
-- Grant/Revoke Java privileges
call dbms_java.grant_permission( UPPER('[USER]'$NEWUSER'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
call dbms_java.grant_permission( UPPER('[USER]'$NEWUSER'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'write' );
call dbms_java.grant_permission( UPPER('[USER]'$NEWUSER'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read' );
call dbms_java.grant_permission( UPPER('[USER]'$NEWUSER'), 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '' );
call dbms_java.grant_permission( UPPER('[USER]'$NEWUSER'), 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '' );
call dbms_java.grant_permission(UPPER('[USER]'$NEWUSER'), 'SYS:java.net.SocketPermission', '*', 'accept,connect,listen,resolve');
grant execute on SYS.DBMS_BACKUP_RESTORE to [USER];$NEWUSER;
-- Job Privileges
grant all on sys.dbms_job to [USER];$NEWUSER;
grant all on sys.dba_jobs to [USER];$NEWUSER;
grant all on sys.dba_jobs_running to [USER];$NEWUSER;
grant execute on sys.dbms_lock to [USER];$NEWUSER;
grant all on sys.DBMS_CRYPTO to [USER];$NEWUSER;
--- Создание директории для XML импортов.
Заменить [UTL_FLIE_DIR]
create or replace directory UTL_FILE_DIR as '[UTL_FLIE_DIR]'$UTL_FLIE_DIR';
grant all on directory UTL_FILE_DIR to [USER];$NEWUSER;
-- Для BACKUP
create or replace directory backup as '[BACKUP_DIR]'$BACKUP_DIR';
grant all on directory backup to [USER];$NEWUSER;
EOT
echo exit | sqlplus SYS/syspassw0rd@CarabiDB as SYSDBA @create-user.sql
шаг 2. Импортировать схему carabi (в директории [BACKUP_DIR] должен лежать архив carabi7.dmp.gz )
[PASSWORD],[OLD_USER],[USER],[FILENAME.dmp]
export DUMP_FILENAME=FILENAME.dmp
gzip -d [FILENAME.dmp]${DUMP_FILENAME}.gz
impdp system/[PASSWORD]@orclsyspassw0rd@CarabiDB \
remap_schema=[OLD_USER]:[USER]csptest:csptest \
directory=BACKUP \
dumpfile=[FILENAME.dmp]${DUMP_FILENAME} \
logfile=[USER]${DUMP_FILENAME}.log \
TABLE_EXISTS_ACTION=REPLACE
impdp system/syspassw0rd@CarabiDB \
remap_schema=petrobalt:petrobalt \
directory=BACKUP \
dumpfile=petrobalt-start.dmp \
logfile=petrobalt-start.log \
TABLE_EXISTS_ACTION=REPLACE