반응형
 1. 원격으로 DB(schema) 접속하여, 백업파일 생성하기
  1. AWS 같이, MySQL이 타 서버에 위치해있을 경우
    • mysqldump --host={백업할 schema ip주소} --port={백업할 schema port} --routines --triggers --bind-address=0.0.0.0 --user={백업할 schema user} --password={백업할 schema password} --databases {백업할 schema 명} > backup.sql


  2. MySQL 가 위치한 서버에 접속할 수 있을 경우
    • mysqldump --host={백업할 schema ip주소} --port={백업할 schema port} --routines --triggers --user={백업할 schema user} --password={백업할 schema password} --databases {백업할 schema 명} > backup.sql


  3. Docker container 내부에 MySQL이 위치해있을 경우
    • mysql container 에 접속하기
      ex) docker exec -it {mysql conatiner 명} bash
    • mysqldump --host={백업할 schema ip주소} --port={백업할 schema port} --routines --triggers --user={백업할 schema user} --password={백업할 schema password} --databases {백업할 schema 명} > backup.sql

 

 2.  DB(schema) 및 계정 생성하기
  • mysql -u root -p  # 새로운 mysql 접속하기
  • create database {데이터베이스명};  # 새로운 DB 생성
  • create user '{user 명}'@'%' identified by '{passwd}'; # 새로운 user 계정 생성
  • grant all privileges on *.* to '{user 명}'@'%' with grant option; # 새로 생성한 user 에 권한 부여하기
  • flush privileges;  # 부여한 권한 적용하기

 3. 백업한 파일로, DB(schema) 복구하기
  • mysql -u {user명} -p --database={데이터베이스명} < backup.sql

 


※ 백업시 발생하는 오류 해결방법

  1. ERROR 2003 (HY000): Can't connect to MySQL server on
  2. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)
    • (원인) function 을 생성할 수 있는 권한이 없어서 발생한 오류이다. 
    • (해결방법) log_bin_trust_function_creators 옵션을 활성화하여, 권한을 부여한다.
      권한 부여하는 방법은 아래 코드 참고한다.
SET GLOBAL log_bin_trust_function_creators = 1;
SET @@SQL_MODE='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’;

 

 

반응형
반응형
오류메세지
  • ORA-01653: unable to extend table SYS.AUD$ by 8192 in tablespace SYSTEM
  • ORA-02002: error while writing to audit trail
  • ORA-00604: error occurred at recursive SQL level 1
  • ORA-01653: unable to extend table SYS.AUD$ by 8192 in tablespace SYSTEM

 

오류원인
  • SYS.AUD$ 은 간단하게 DB 에서 작업하는 Log 가 저장되는 테이블임. 
  • SYS.AUD$ 의 용량이 꽉 차 자동으로 늘릴려고 했지만, 확장되지 않아 발생한 오류

 

해결방법
  1. DB가 위치한 os 위치로 이동
  2. su - oracle
  3. sqlplus ‘/as sysdba’
  4. ALTER SESSION SET CURRENT_SCHEMA ={schema 명};
  5. truncate table sys.aud$;

※ 보통 SYS.AUD$ 에 쌓인 Log 정보를 백업한뒤 truncate 명령어로 전체삭제하는게 좋음. 하지만 여기서는 따로 백업은 진행하지 않고 바로 삭제하였음

SYS.AUD$ 는 DB 에서 작업한 이력들을 저장하는 테이블이기 때문에, truncate 로 삭제하더라도 다른 테이블의 데이터가 삭제되지 않음

반응형
반응형
오류메세지
  • ORA-39002: invalid operation
  • ORA-39070: Unable to open the log file.
  • ORA-29283: invalid file operation
  • ORA-06512: at "SYS.UTL_FILE", line 488
  • ORA-29283: invalid file operation

 

상황설명
  • 디렉토리 권한 부여했는데도, ORA-39002: invalid operation 오류메세지가 발생함

해결방법
  • os 위치로 가서 ls -l 명령어 입력
  • 폴더 및 파일의 소유권인 oracle:dba 로 되어있는지 확인
  • 만약 root 와 같이 다른 소유자로 설정되어있을 경우 아래 명령어로 소유자 변경
  • Chown oracle:db {폴더경로}
  • Chown oracle:db {파일경로}
반응형
반응형
 1. 오라클 접속
  • 현재 오라클 설치되어있는 서버의 CMD 창에서 아래 명령어 입력
  • su - oracle
  • sqlplus '/as sysdba'

 

 2. 오라클 계정 권한 확인
  1. export 한 파일 저장할 디렉토리 read, write 권한 부여
    • select * from dba_directories; 쿼리문 실행으로 조회되는 디렉토리명 및 os 위치 확인
    • grant read, write on directory {위의 query 문으로 나온 제일 상단의 directory 명} to {schema 명};
  2. connect, resource, dba 권한 부여
    • grant connect, resource, dba to {schema 명};
  3. export, import 권한 부여
    • GRANT EXP_FULL_DATABASE TO {schema 명};
    • GRANT IMP_FULL_DATABASE TO {schema 명};

 

3. schema 확인 (선택)
  • SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') AS "CURRENT_SCHEMA" FROM DUAL;
  • 위 쿼리의 출력값이 {schema 명} 맞는지 확인

 

4. Export 수행 (아래 2가지 방법 중 택1)
  1. (방법1) schema export
    • expdp {schema명}/{passwd}@{ip 주소} schemas={3에서 확인한 schema 입력} directory={2-1 에서 확인한 directory  입력} dumpfile=test_schema.dmp logfile=test_schema.log
  2. (방법2) tablespace 로 export 
    • expdp {schema명}/{passwd}@{ip 주소} tablespaces='USERS' directory={2-1 쿼리에서 확인한 directory 명 입력} dumpfile=test_tablespace.dmp logfile=test_tablespace.log
    • 2-1 에서 확인한 os 위치에 test_schema.dmp, test_schema.log , test_tablespace.dmp, test_tablespace.log 생겼는지 확인

 

5. Import 수행 (아래 2가지 방법 중 택1)
  1. (방법1) schema import
    • impdp {schema명}/{passwd}@{ip 주소} schemas={3에서 확인한 schema 입력} directory={2-1 에서 확인한 directory 명 입력} dumpfile=test_schema.dmp logfile=test_schema.log
  2. (방법2) tablespace 로 import
    • impdp {schema명}/{passwd}@{ip 주소} tablespaces='USERS' directory={2-1 쿼리에서 확인한 directory 명 입력} dumpfile=test_tablespace.dmp logfile=test_tablespace.log

 

반응형
반응형

1. tmux 는 언제 사용하는가?

 

터미널 창에서 jupyter notebook 를 실행시킨뒤 만약 mysql 을 실행시키려고 하면 jupyter notebook 종료해야지만 다른 mysql 을 사용할 수 있다. 이때, tmux 를 활용하면 2가지 작업을 동시에 실행할 수 있다.

 

2. tmux 적용해보기

 

1) 세션 생성하기

AWS 서버에 'dss' 라는 이름으로 세션을 새로 생성한다. 세션과 함께 1번째 윈도우가 만들어진다.

tmux new -s dss

 


2) 윈도우 추가로 생성하기

dss 라는 세션 안에 2번째 윈도우가 새로 생성됬다.

( 앞으로 1번째로 생성된 윈도우는 w0 , 2번째로 생성된 윈도우는 w1 로 명칭을 통일하겠습니다. )

# ctrl 과 b 를 동시 누른다
ctrl + b
# 이후 c를 누른다
c

 

 


3) jupyter notebook 실행하기

새로 만든 w1(두번째 생성한 윈도우) 에서 jupyter notebook 을 실행시켜보기

jupyter notebook

 

터미널 창


4) 다른 작업 수행하기

jupyter notebook 작업 이외에 다른 작업을 하고 싶다면, 다른 윈도우창으로 들어가 ( 명령어 ctrl + b 누른뒨 원하는 윈도우창 번호 입력) 작업을 수행하면된다.

# 윈도우 창 변경하는 방법
ctrl + b 누른 후 [윈도우 번호] 누르기
# 예를들어 현재 내가 윈도우0 번째에 들어와있는데 윈도우3 으로 이동하고 싶다면?
ctrl + b 동시에 누른 후, 3 누르기.

※그 외 유용한 단추기 모음 사이트

https://edykim.com/ko/post/tmux-introductory-series-summary/

반응형

+ Recent posts