Skip to main content

4 этап - инициализация базы CarabiDB

Шаг 1. Поменять поле [USER],[PASSWORD],[UTL_FLIE_DIR],[BACKUP_DIR]

mkdir /home/oracle/utlfile
mkdir /home/oracle/backup
  • USER - уникальный
  • PASSWORD=carabi2002
  • UTL_FLIE_DIR=/home/oracle/utlfile
  • BACKUP_DIR=/home/oracle/backup
create user [USER]
  identified by [PASSWORD]
  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];
grant resource, ctxapp to [USER];
grant imp_full_database to [USER];
-- Grant/Revoke system privileges 
grant create procedure to [USER];
grant create sequence to [USER];
grant create synonym to [USER];
grant create table to [USER];
grant create trigger to [USER];
grant create type to [USER];
grant create view to [USER];
grant alter system to [USER];
grant alter session to [USER];
grant debug any procedure to [USER];
grant debug connect session to [USER];

-- Grant/Revoke objects
grant select on sys.v_$lock to [USER];
grant execute on SYS.DBMS_LOGMNR to [USER];
grant execute on SYS.DBMS_PROFILER to [USER];
grant select on SYS.V_$LOGMNR_CONTENTS to [USER];
grant select on SYS.V_$MYSTAT to [USER];
grant select on SYS.V_$LOGFILE to [USER];
grant select on SYS.V_$OPEN_CURSOR to [USER];
grant select on SYS.V_$SESSION to [USER];
grant select on SYS.V_$PROCESS to [USER];
grant select on SYS.DBMS_LOCK_ALLOCATED to [USER];

-- Grant/Revoke Java privileges
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'write' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '' );
call dbms_java.grant_permission( UPPER('[USER]'), 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '' );
call dbms_java.grant_permission(UPPER('[USER]'), 'SYS:java.net.SocketPermission', '*', 'accept,connect,listen,resolve');

grant execute on SYS.DBMS_BACKUP_RESTORE to [USER];

-- Job Privileges
grant all on sys.dbms_job to [USER];
grant all on sys.dba_jobs to [USER];
grant all on sys.dba_jobs_running to [USER];
grant execute on sys.dbms_lock to [USER];
grant all on sys.DBMS_CRYPTO to [USER];

--- Создание директории для XML импортов. Заменить [UTL_FLIE_DIR]
create or replace directory UTL_FILE_DIR as '[UTL_FLIE_DIR]';
grant all on directory UTL_FILE_DIR to [USER];

-- Для BACKUP
create or replace directory backup as '[BACKUP_DIR]';
grant all on directory backup to [USER];

echo exit | sqlplus SYS/syspassw0rd@CarabiDB as SYSDBA @create-user.sql

шаг 2. Импортировать схему carabi (в директории [BACKUP_DIR] должен лежать архив carabi7.dmp.gz )

[PASSWORD],[OLD_USER],[USER],[FILENAME.dmp]

gzip -d [FILENAME.dmp].gz 
impdp system/[PASSWORD]@orcl \
 remap_schema=[OLD_USER]:[USER] \
 directory=BACKUP \
 dumpfile=[FILENAME.dmp] \
 logfile=[USER].log \
 TABLE_EXISTS_ACTION=REPLACE
echo exit | sqlplus SYS/syspassw0rd@CarabiDB as SYSDBA @create-user.sql