Skip to main content

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=/home/oracle/utlfile
export BACKUP_DIR=/home/oracle/backup
cat << EOT >> /home/oracle/create-user.sql
create user $NEWUSER
  identified by $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 $NEWUSER;
grant resource, ctxapp to $NEWUSER;
grant imp_full_database to $NEWUSER;

-- Grant/Revoke system privileges 
grant create procedure to $NEWUSER;
grant create sequence to $NEWUSER;
grant create synonym to $NEWUSER;
grant create table to $NEWUSER;
grant create trigger to $NEWUSER;
grant create type to $NEWUSER;
grant create view to $NEWUSER;
grant alter system to $NEWUSER;
grant alter session to $NEWUSER;
grant debug any procedure to $NEWUSER;
grant debug connect session to $NEWUSER;

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

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

-- Job Privileges
grant all on sys.dbms_job to $NEWUSER;
grant all on sys.dba_jobs to $NEWUSER;
grant all on sys.dba_jobs_running to $NEWUSER;
grant execute on sys.dbms_lock to $NEWUSER;
grant all on sys.DBMS_CRYPTO to $NEWUSER;

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

-- Для BACKUP
create or replace directory backup as '$BACKUP_DIR';
grant all on directory backup to $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 ${DUMP_FILENAME}.gz 
impdp system/syspassw0rd@CarabiDB \
 remap_schema=csptest:csptest \
 directory=BACKUP \
 dumpfile=${DUMP_FILENAME} \
 logfile=${DUMP_FILENAME}.log \
 TABLE_EXISTS_ACTION=REPLACE