[1,2교시 - 데이터베이스 보안]
/ 데이터 무결성 제약조건의 종류
1. 개체 무결성(Entity integrity)
- 하나의 테이블에 중복된 행이 존재하지 않도록 규정
- 기본키 제약이라고도 한다.
- Primary Key(PK) : 열에 유일한 값만 입력이 되어야 하고, NULL값을 허용하지 않는 것
- UNIQUE : 값의 중복을 허용하지 않는 제약, NULL도 중복되면 안된다.
2. 참조 무결성(Referential integrity)
- 행을 입력, 수정, 삭제할 때 연관되는 다른 테이블과의 데이터가 정확하게 유지되도록 규정
- FOREIGN KEY(외래키) : 다른 테이블의 데이터를 참조할 때 없는 값을 참조할 수 없도록 제약
3. 도메인 무결성(Domain integrity)
- 속성이 정의되어 있는 영역을 벗어나지 않도록 규정
- NOT NULL : 데이터를 입력받을때 NULL을 허용하지 않는것
- DEFAULT : 입력 값을 지정하지 않았을때 기본값으로 입력되도록 하는 것
- CHECK : 값의 범위를 정해 놓는 제약
4. Null 무결성(Null integrity)
- NOT NULL : 데이터를 입력받을때 NULL을 허용하지 않는것
5. 고유 무결성(Unique integrity)
- UNIQUE : 값의 중복을 허용하지 않는 제약
6. 키 무결성(Key integrity)
7. 관계 무결성(Relationship integrity)
/ 무결성 제약조건 실습
- pk, check 실습
create table lan (
ano int primary key,
addr varchar(20) check(addr in('Seoul', 'Jeju','Busan','Suwon'))
);
insert into lan(ano, addr) VALUES (1, 'Seoul'); -- 삽입됨
insert into lan(ano, addr) VALUES (2, 'bla bla'); --삽입안됨
insert into lan(ano, addr) VALUES (1, 'Busan'); --삽입안됨
- 외래키(Foreign key)
CREATE TABLE par(
id number not null PRIMARY key,
par_name varchar(20)
);
CREATE TABLE child(
id number not null PRIMARY key,
par_id number,
child_name varchar(20),
CONSTRAINT fk_pid foreign key(par_id) REFERENCES par(id)
);
insert into child (id, par_id, child_name) values (1,1,'자식1'); -- 생성안됨 : 부모 데이터가 없음
insert into par(id, par_name) values (1, '부모1'); -- 부모 데이터 생성
insert into child (id, par_id, child_name) values (1,1,'자식1'); -- 생성됨
insert into child (id, par_id, child_name) values (2,1,'자식2'); -- 생성됨
insert into child (id, par_id, child_name) values (3,2,'자식3'); -- 생성안됨 : 부모 데이터가 없음
/ 데이터베이스 보안 요구사항 정의 - 분석 프로세스 숙지
- 분석 과정 및 단계별 역활/산출물 숙지가 필요함
- 단계별로 진행함
- 이전 단계로 피드백 하는 과정을 가짐
- 사용자 요구 사항 분석의 정확성/명확성을 확보함
1. 요구사항 도출
- 데이터베이스의 대상 파악, 프로젝트 목표 숙지, 프로젝트의 범위를 기준으로 조사 범위를 결정
- 도출을 위해 업무관계자 인터뷰 및 외부자료 수집 및 분석등을 한다.
2. 요구사항 분석
- 도출된 요구사항의 명확성을 파악, 완전성 및 모호성 검증
- 불완전한 부분이 존재하면 요구사항 도출단계를 재수행
- 요구사항을 분류하여 통합 또는 분리하는 작업수행
3. 요구사항 기록
- 요구사항 목록 정리 및 관리자의 승인을 받아 확정
- 정리된 요구사항을 형식에 맞춰 문서화
- 프로젝트 종료 때까지 반영여부를 지속적으로 관리
[3,4,5교시 - 시스템 보안]
/ raid5 구성해보기
- 하드디스크를 1GB, 싱글로 3개 만든다.
- 부팅 시 새로 sdh, sdi, sdj가 확인된다.
- 부팅 후 'll /dev/sd*', 'fdisk -l | grep /dev/sd' 등으로 확인해본다.
ll /dev/sd*
fdisk -l | grep /dev/sd
- 각각의 'sdh, sdi, sdj'를 fdisk작업을 해준다.
[root@kyj ~]# fdisk /dev/sdh
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xd78be71d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@kyj ~]# fdisk /dev/sdi
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x3f42118a.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'
Command (m for help): p
Disk /dev/sdi: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x3f42118a
Device Boot Start End Blocks Id System
/dev/sdi1 2048 2097151 1047552 fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@kyj ~]# fdisk /dev/sdj
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xa18e714f.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'
Command (m for help): p
Disk /dev/sdj: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xa18e714f
Device Boot Start End Blocks Id System
/dev/sdj1 2048 2097151 1047552 fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
- mdadm을 한다.
# mdadm -C /dev/md5 -l 5 -n 3 /dev/{sdh1,sdi1,sdj1}
- 확인1
- 확인2
- /dev/md5를 ext4로 포맷한다.
# mkfs -t ext4 /dev/md5
- 루트에 'raid5'폴더를 만들고 그 폴더에 마운트 시킨다.
# mkdir /raid5
# mount /dev/md5 /raid5
- 마운트되었는지 확인한다.
# df -h
- 리부팅 시 자동으로 마운트되도록 /etc/fstab에 데이터를 등록해준다.
# vi /etc/fstab
- /dev/md5 /raid5 ext4 defaults,nofail 0 0 ->내용 추가
- 리부팅
# reboot
/ raid 구성 전체적인 과정 정리
1. 하드디스크 추가
1-1. 'll /dev/sd*'로 추가된 디스크 확인
2. 'fdisk /dev/sd블라블라'로 각각 파티셔닝(타입 코드는 fd로 입력)
3. mdadm -C /생성할/폴더 -l 레이드단계 -n 하드갯수 /dev/{하드, 목록, 들} : 레이드 구성
3-1. mdadm -D /생성한/폴더 : 레이드 구성 확인
4. mkfs.ext4 /생성한/폴더 : ext4로 포멧
5. mkdir /마운트/폴더 : 마운트할 폴더 생성
6. mount /생성한/폴더 /마운트/폴더 : 레이드 구성한것을 새로만든 폴더에 마운트
7. vi /etc/fstab : 리부팅 시 자동 마운트 설정
/ 실습과제
1. RAID 구성
- 수행1 : LinearRaid, Raid0,를 구성하여라
> 제출1 : 디스크 추가 및 fdisk 작업완료 후 ls -l /dev/sd*
> 제출2 : 마운트 작업 완료 후 df -h
> 제출3 : 마운트 작업 완료 후 vi /etc/fstab
- 수행2 : Raid1, Raid5를 구성하여라
> 제출1 : 디스크 추가하고 리부팅 후, ls -l /dev/sd*
> 제출2 : mdadm으로 md1, md5 구성 후, ls -l /dev/md*
> 제출3 : md1, md5에 대해 마운트 작업 후, df -h
> 제출4 : mdadm --detail /md1
> 제출5 : mdadm --detail /md5
> 제출6 : cat /proc/mdstat
> 제출7 : vi /etc/fstab
2. CentOS에 http 및 ssh 설치
- 수행1 : VMware를 사용하여 CentOS서버를 준비하고 root로 로그인한후에, Linux Server에 웹서버(httpd)를 설치하고, 서버상에서 적절한 명령어를 사용하여 Linux Server의 웹서비스 TCP 80포트, sshd서비스 tcp 22포트가 리스닝 가능상태임을 확인/캡쳐하여 제출하시오.
- 수행2 : Linux Server에 웹서버 인덱스페이지(index.html)을 구성하고, 호스트PC에서 Linux Server로 웹서버 페이지접근/오픈하시오.
필요한 경우 해당 서비스를 방화벽에서 오픈하고 접근/오픈된 웹서버페이지를 확인/캡쳐하여 제출하시오.(index.html 내용은 ‘This is Linux Server' 로 한다)
- 수행3 : 호스트PC에서 해당 Linux Server 에 ssh로 접속하되, putty등의 클라이언트 프로그램을 사용하고, 접속시 root계정 또는 centos계정을 사용하도록 한다.
호스트PC에서 ssh접속 완료후, 서버에서 # w, # who 명령어 구문 결과를 각각 확인/캡쳐하여 제출하시오.
- 수행4 : 클라이언트(호스트PC)에서 서버를 향해 putty 등의 프로그램을 사용하여 ssh로 클라이언트가 접속성공한 내역(ESTABLISHED)을 확인하기 위해서
# netstat -ant | grep LIST* 또는
# netstat -ant | grep ESTA* 또는
# netstat -ant | grep 22 명령어 사용하여 확인/캡쳐하여 제출하시오.
'정보보안학원 > 과정평가형 일지' 카테고리의 다른 글
21일차 - 데이터베이스 보안, 시스템 보안 (0) | 2022.05.16 |
---|---|
18일차 - 데이터베이스 보안, 시스템 보안 (0) | 2022.05.11 |
16일차 - 데이터베이스 보안, 시스템 보안 (0) | 2022.05.09 |
15일차 - 데이터베이스 보안, 시스템 보안 (0) | 2022.05.04 |
14일차 - 데이터베이스 보안, 시스템 보안 (0) | 2022.05.03 |