블로그 이미지
오정oI

카테고리

분류 전체보기 (119)
회사 - pj # 나라원 (1)
회사 - pj # 나라원 (2)
이직준비 2 (0)
이직준비 (10)
국비-클라우드 (1)
학점은행제 (0)
취미 (0)
주식 (0)
외국어 (0)
자격증 (14)
BigData_On (1)
BigData_Off1 (74)
클라우드 (0)
언어_Framework (1)
언어-Server (2)
언어_Client (0)
업무 (1)
IT참고서적 (1)
IT 최신 트랜드 (0)
제테크 (1)
Study Plan (2)
동영상 및 자료 (5)
여행 (1)
git (0)
Total
Today
Yesterday
반응형
SMALL

[DC]

Active Directory Domain Service  구성

1. DNS  설정

2. Active Directory Domain Service 설치

 - 2008R2  이하 버전은 실행창 : dcpromo

 - 2012R1  이상 서버관리도구

 

[SRV]

Active Directory Domain Service  가입

0. 통신 확인

1. DNS 설정 ←  DNS, DC IP 주소

2. sysdm.cpl,  시스템 속성

3. 도메인 가입 : itbank.com, ID, PW

4. 부가적 기능 설치

 

# 강사 DC 가입

DC IP  주소 : 172.16.0.200

도메인 이름 : care.com

도메인 관리자 계정명 : administrator

도메인 관리자 비번 : P@ssw0rd

서버 관리자 도구 - ADDS 도구 설치 (Active Directory Domain Service 설치)

=> SRV 에서..,

=> 재시작, 로긴시

administrator@care.com

P@ssw0rd

 

* window+r 명령어

관리도구
서비스명 + mgmt.msc

dnsmgmt.msc
dhcpmgmt.msc
compmgmt.msc
rrasmgmt.msc

// DNS  설정
window+r : ncpa.cpl


//  관리 도구
window+r : dsa.msc

// dns 관리도구
window+r : dnsmgmt.msc

// 관리 도구 박스
window+r : mmc

 

[DC]

=> 끝난 후 suspand~!

=> snapshot 처음 시점으로 돌리기!

 

// 1. DNS  설정

window+r : ncpa.cpl>

설정 후 확인

window+r : cmd

 

// 2. Active Directory Domain Service 설치

sol 1>

window+r : dcpromo >

해당 사이트 가서 설치 하는 듯..,

sol 2> 서버 관리자에서 해당 서비스 설치

 

 

포리스트 : 도메인이 여러 개인 애

포리스트 기능 수준: 프로그램 호환성

 

읽기 전용 : 벡업 DC 역할

복원  pwd, 계정 pwd  아님!

NetBIOS 도메인 이름: itbank.com

DNS → WINS

DN       NetBIOS

 

DC → NTDS

Domain → NTDS

Local → SAM

 

// 설치 후 재부팅 시

 

// 관리 도구

window+r : dsa.msc

 

조직구조, 조직구성단위(OU)

사용자 계정, 그룹 등 생성

관리자 권한 위임(제어 위임)

 

//dns 관리도구

window+r : dnsmgmt.msc

 

////////////////////////////////////////

[SRV]

// 0. 통신 확인

 

// 1. DNS 설정 ←  DNS, DC IP 주소

DC, DNS or DNS가 설치된 곳의 IP 주소

 

 

// 2. sysdm.cpl,  시스템 속성

 

 

 

// 3. 도메인 가입 : itbank.com, ID, PW

[에러]

ping(x), dns address (x)

 

도메인에 가입할 계정. SRV (x)

DC id, pwd 기입

 

// 4. 부가적 기능 설치

=> 원격도구 설치

 

 

======================================

Lesson 3.  관리자 툴 설치 및 사용법

 

 

// 관리 도구 박스: window+r : mmc

 

// window  명령어 있는 곳

C:\Windows\System32

 

======================================

Lesson 4.  조직단위(Organizational Unit)?

정의

ou 안에는.., 계정, 그룹,  ou를 넣을 수 있음.

용도

- 권한 위임

- 논리적 구조 (폴더처럼 사용 가능)

- 그룹 정책 시행

 

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 목차

 

* SRV 기본 정보 및 오늘 수업 진도

admin : administrator

password : P@ssw0rd

 

1. VMware Tool 설치

2. 컴퓨터 이름 변경 : SRV1xx, SRV101, SRV102, SRV103

3. IP 주소 설정

4. 방화벽 : 운영체제 보안(네트워크 기반)

5. SnapShot

 

! 도메인 로그인 방법

1. administrator@care.com

: 계정명@도메인명

2. care.com\administrator

: 도메인명\

3. care\administrator

: 도메인명\계정명

 

! 로컬 로그인 방법

1. SRV100\administrator

: 컴퓨터이름\계정명

 

administrator

 

! 재 로긴 시 :

Ctrl + Alt + Insert

(Ctrl + Alt + Delete 를 해버리면 현재 작업중인 pc도 잠길 수 있으므로..,)

 

! 윈도우즈 명령어 : .cpl .msc

 

내일..,

DC : Domain Controller

SRV : 회원 가입 시킬거

 

 

=========================================

 

 

* 패스워드 변경

vmware 윈도우창 클릭> window+R: cmd

 

 

* VWware Tool  설치

sol 1>

VM 탭 클릭> Install VMware Tools...

sol 2>

vmware 윈도우창 클릭> window+E

해당 드라이브 더.클> 다음, 다음,.. > 다시시작 : 아니오

 

* 컴퓨터 이름 변경

이 외에 도메인 변경, 원격 설정시 올거임.

window+R : sysdm.cpl

 

윈도우즈 재시작>

 

* ip 변경

window+R : ncpa.cpl

 

 

서브넷 마스크 : 어디까지가 대역대인가 알려주는 값

기본 게이트 웨이 : 외부 통신 하는 경우 필요

기본 설정 DNS 서버 : 외부 통신 하는 경우 필요

 

cf.  Active ~ <- DNS 필요!

 

* 방화벽

기본적으로 외부 접근 차단함.

이렇게 되면 서버가 클라이언트에게 서비스 해줄 수 없음.

FW : 방화벽(FireWall)

WAF : 웹 방화벽(Web Application Firewall)
IPS : 침입 방지 시스템(Instrusion Prevention System)
IDS : 침입 탐지 시스템(Instrusion Detection System)

cf. 방화벽  IPS와 IDS

http://jihoon6078.tistory.com/27

 

window  방화벽 사용법

- Window + R : wf.msc

 

인바운드 규칙 : 데이타 받는거 (대부분 차단)

아웃바운드 규칙 : 데이타 나가는 거 (대부분 허용)

 

인바운드 규칙 클릭(default:차단)>

내용물 중 회색 : 차단

 

아웃바운드 규칙 클릭(default:허용)>

내용물 중 회색 : 허용

 

cf.  리눅스 : forward

지나가는 데이타들 검색

데이타가 외부서 들올 때 들어온 데이타 검색 하고 받아들일때,

or 데이타가 안에서 외부로 나갈 때 검토

 

<실습> pc 통신 가능하게 만들기!

 

1) 내 pc ip 셋팅 후

cmd : ipconfig

내 ip 제대로 설정 됬는지 확인

 

cf. cmd : ipconfig

169.254.x.x 뜨면 설정 제대로 안된거임!

2) 다른 pc ping 테스트

[cmd 창] ping 172.16.0.101        // 다른 pc ip 주소 치고 확인

 

3) 방화벽 열어주기

인바운드 규칙 클릭> 파일 및 프린터 공유(에코요청 -ICMPv4-In) 오.버 규칙 사용함

(외부에서 들어옴 IN)

 

cf) 아웃바운드는 default로 허용이므로 손댈 필요 없음!

 

4) 네트워크 설정

네트워크 설정 : vmware 하단 Network Adapter 더.클> host-only → Bridge로 변경

 

* SnapShot

 

 

* 컴퓨터 추가 설치

 

admin : administrator

password : P@ssw0rd

 

1. VMware Tool 설치

VM 탭 클릭> Install VMware Tools...>

내 PC > DVD  드라이브 더.클

 

2. 컴퓨터 이름 변경 : SRV1xx, SRV101, SRV102, SRV103

- 이름 : DC2xx

window+R : sysdm.cpl

이 외에 도메인 변경, 원격 설정시 올거임.

 

3. IP 주소 설정

- 172.16.0.2xx/24(255.255.255.0)

window+R : ncpa.cpl

cmd : ipconfig

C:\Users\Administrator>ipconfig

Windows IP 구성


이더넷 어댑터 Ethernet0:

   연결별 DNS 접미사. . . . :
   링크-로컬 IPv6 주소 . . . . : fe80::9cf6:320a:d821:d867%12
   IPv4 주소 . . . . . . . . . : 172.16.0.203
   서브넷 마스크 . . . . . . . : 255.255.255.0
   기본 게이트웨이 . . . . . . :

 

 

4. 방화벽 설정 및 통신 확인

cmd : ping 172.16.0.101

Window + R : wf.msc

 

5. SnapShot(백업)

 

* 이론 -  로그온과 인증

- 로그온과 인증도메인 로그온과 로컬 로그온 방법

- 도메인 로그온(NTDS)과 로컬 로그온(SAM) 방법 : 네트웍 통한 인증

- 엑세스 토큰 : 접근 위해 필요한 것?

1) 도메인 로그인 : NTDS

 

 

2) 로컬 로그인 : SAM

 

 

 

 

 

 

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

※ 1. OT

 

* pickpick  설치 사이트 : http://ngwin.com/kr/download

* 보안 자격증 : CISSP, CISA

 

* Module Overview

Lesson 1: Windows Server 2008 환경

Lesson 2: 액티브 디렉터리

Lesson 3: 관리자 툴

Lesson 4:

 

* 용어 정리

Server : 서비스를 제공하는 자

client :  //          제공받는 자

Service : Program

 

network :  데이타 송.수신, 웹 서비스 제공

A_PC ↔ B_PC 정보 이용

- IP(논리) 주소 : 컴퓨터의 대표적 주소. 다른 위치에 PC 찾아감    ex> 1.1.1.1

- MAC(물리) 주소 :  NIC 카드 주소. PC 식별 고유 번호

- Port 주소(번호) : 프로그램 주소.

컴퓨터가 pg 여러개 실행 시  각 프로그램 구분 위한 번호

ex> 구글 크롬, 곰플레이어?.., 네이버 웹 서버(80) 접속시 데이터 요구

Switch : LAN 구간 연결 장비. 컴퓨터들간 통신 연결. MAC 주소 이용

없으면? LAN선 PC들 다 연결 해야..,

ex> 위치 a - 1.1.1.1 ↔ 위치 b - 1.1.1.1

=>   MAC 주소로 구분 (주민번호)

Switch가 MAC 주소 식별.

 

Lesson1. Service ?

 

* Service

DSN, DHCP => 서버 2에서..,

1) Active Directory Domain Services

2) File Services :

- FTP 서비스 : 어디서든 사용 가능.

- 공유폴더(SMBv2) : (Server Message Block) 정해진 위치에서만 사용 가능. 보안 더 좋음

 

3) DNS Server : DNS(Domain Name System) : 문자 → IP 로 변환 (정방향 조회)

- Domain : 물리적 그룹

- IP ↔ URL, URI, DN, FQDN

192.168.0.4 www.google.com

정보 조회 or 질의

- 문자 → IP : 정방향 조회 | IP → 문자 : 역방향 조회

ex> Active Directory Domain Service

한대의 컴퓨터로 다수의 컴퓨터를 제어할 수 있다. (중앙관리)

1대의 pc가 제어를 하면 다수의 pc에 같은 pg을 설치 및 제거 가능?

삼성, 지사 많은 곳(공공기관) - 삼성전자 계열사 하나, 도시가스 공사

4) Print Services : 요샌 복합기. 드라이버 pg만 설치하면 됨. 요샌 서버가 제어 안함.

5) Web Server IIS : => Web Service(http service: hyper text transfer protocol)

(Service - DB -  언어)                   (30%)

- IIS - MS-SQL - ASP.NET            : MS 계열. 공짜 아님. (Internet Information Service) ex> 대기업, AS 좋음!

- Apache -Mysql - MariaDB - PHP : 리눅스, 유닉스 계열(HP, IBM, Sun(solaris))    ex> 중.소기업

                                   (50%)

웹 페이지에서 받은 정보를 IIS나 Apache가 Client에게 전달

APM을 구성한다(Application Performance Management)??

cf) 기타 언어 : JSP(Java), Python(보안, swap, 빅 데이타,...), HTML, CSS, Jqury

6) Terminal Services

        (CLI 환경)

- Telnet : 지금은 안 쓰임. 암호화 전혀 안됨(평문 데이타 전송).

- SSH v1, v2: (Secure Shell)

v1 : 암호화 해독 가능 << v2 를 쓰는게 나음..,

------------------------------------------------

- Remote Desktop Protocol(원격 데스크탑) : 보안 좋음. 암호화 잘 되있음.

ex) 네이트온 원격 제어, Team viewer

  (GUI 환경)

cf) Terminal :  끝점. 종단(End device)

ex) 네이버 클라우드

7) DHCP (서버) : Client 에게 IP 주소 동적 설정

Message 종류

네트워크 주소 설정

- Discover : C → S IP 요청. 네트워크 주소 설정 안되있음. MAC 주소만 갖고 있음. broadcast~!

- Offer     : C의 MAC 주소 전달받음. C → S 에게 broadcast~! (DHCP PC2개면 더 빨리 보내는 애 선택)

- Request : C

- Ack      : S

확인 정보

- Information

설정 확인

- Ack

DHCP의 client 구별법 : 각 client의 MAC 주소를 보고 판별

이 점이 단점임.(취약) (∵ client  구별법이 MAC주소 하나밖에 없어서.., )

제한 거리는 LAN 구간 => WAN(Relay Agent  쓰면 가능해짐..,)

 

[그림] DNS 초창기

- 위치 : C:\Windows\System32\drivers\etc > hosts 파일

- 방법 : 사용자가  IP, DN 직접 쓰는 방식.

 

=> 3) DNS Service  관련

[그림] DNS

 

[그림] Domain Controller

[그림] DC 인증방식 : kerberos

 

* Windows Server 2012 제품군

제품군 : WindowsServer 2012 standard data-entor

용어

- 4-way-SMP :  cpu 4개까지, 동시 병렬처리 가능

- 부하분산 클러스터링(NetworkLoad Balancing Clustering)

부하분산 : 한 pc가 클러스터링 된 pc들에게 트래픽 양을 분산시켜서 줌

(빨리 끝나는 S에겐 빨리주고 느린애들은 천천히 주고..,)

ex) 성능이 낮은 피씨 4개 묶어서 한가지 일을 함 == 성능 좋은 pc

- 장애 조치 클러스터링

- 가상화 : 여러 운영체제를 사용가능하게 구분 해 놓음.

ex> Hyper V, Docker 키워드 검색 및 책 추천

 

 

[그림] 부하분산 : 트래픽 양 분산

[그림] 클러스터링 : 성능이 낮은 피씨 4개 묶어서 한 가지 일을 함 == 성능 좋은 pc

[그림] 장애 조치 클러스터링

============================================

Lesson2. Active Directory

 

* (액티브 디렉터리)Active Directory  서버의 역할

액티브 디렉터리 도메인 서비스(AD DS) 가 모든 애들을 관리 해줌.

경량(Lightweight) 디렉터리 서비스(AD LDS), 디렉터리 인증서 서비스(AD CS), 권한 관리 서비스(AD RMS),

연합 서비스(AD ???)

 

* AD

0) 개념

- AD(Domain Controller)가 하위 컴퓨터들을 다 관리함.

 

1) 특징

- 네트워크 정보의 중앙 저장소

- 자원 확인 및 검색

 

2) 장점

- 보안 관리의 간소화

- 추가적인 보안 정보 저장소

- 그룹 정책 :  AD(Domain Controller)가 하위 컴퓨터들을 다 관리함.

- 확장성    ex> A피씨 :  직원 10000명 도메인 설정 / B피씨 :  직원 10000명 도메인 설정

- 관리의 위임 : 일반 사용자에게 임시로 관리자 권한 위임

 

* 조직구조(Organization Unit)

개념 및 특징

- OU : MS는 컨테이너라고 부르는데, 실제로는 폴더임.

- 파일 묶는데, 사용자 계정, 그룹 묶음

ex> 서울 지사, 강원 지사, 경기 지사..,

   ↙↓↘

    영업,관리,인사...

 

* 포리스트(Forest)

개념

- 상호 신뢰관계를 맺고 있는 도메인들의 집합.

특징

- 도메인들끼리 정보가 공유 있어야 함. (신뢰관계를 맺고 있음)

ex> 글로벌 기업 : 아시아, 유럽, 아메리카??

 

* 도메인 컨트롤러(Domain Controller)

 

특징

- 액티브 디렉터리 정보의 복사본을 가지고 있는 컴퓨터

- 액티브 디렉터리 정보 요청에 대한 응답

- 네트워크를 통한 사용자 인증(로긴)

- DNS 통합

- 도메인과 포리스트 전체의 멀티마스터 복제(Multi-master replication)에 참여

: 포리스트 안에 도메인들은 데이타를 서로 공유하고 있음.

=> Global Catalog이용

- Domain은 최대 5개? DC는 한 Domain당 2개씩 올수 있음(Standby, Active)

DC는 가급적이면 거리가 있는 곳에 서로 한개씩 배치해야..,

(둘이 같은 공간에 있으면 의미 없음.., 뚫리면 동시에 뚫려서..,)

 

cf) Global Catalog : 도메인 정보에 대한 위치값 담겨 있음. 인덱스 가능.

    각 도메인들은 각자 영역(섹터)의 정보를 담고 있고,

    각 도메인의 인덱스값을(요약본) Global Catalog 에게 준다.

 

 

 

* VM ware 사용법 및 OS 설치

1) 네트워크 설정

종류

외부 통신시,

- Bridged : 내 랜카드에 연결되있음? 강의장에 있는 DHCP에게 IP 주소를 받음.

- NAT : VM ware 공간 안에 가상장비 있음. Network  address(IP)를 변환해줌.

- Host-only : VM ware 안에 있는 장비들 끼리만 통신함(VM ware안에 있는 운영체제들 끼리만) 외부로는 나갈 수 없음!

ex> 기업 중요 정보 있는 곳. 인터넷 안됨. 내부망

 

cf) 사설 , 공인 IP

사설 IP    ==> Bridged

192.168.                //192.168.0.4

10.

172.16~172.31

----------------

공인 IP (ISP 업체서 부여 잘 안해줌..,) ==> NAT

 

2) VMware 설치

 

1. Custom> Next

2. default> Next // 같은 버전이어야만 호환 가능.

3. I will install~> Next  // ① 진짜 cd ② iso 파일(인증값 같은걸 받아야.., 정품인증)

4. Windows Server 2012 > Next      // 윈도우 안 : host os / vmware 안 : guest os

5. SRV, D:\2월 평일반 윈도우1 서정아\pg > Next

6. default, > Next         // BIOS : 부팅설정 잡음. EFI : BIOS 최신버전

7. default, > Next         

8. default,  > Next         // 2048MB

9. Use host-only > Next  // 설치 후 나중에는 Bridged 로 바꿀거!

10. default, > Next         // LSI Logic SAS,

     // I/O controller types : 서버가 많이 씀. 데이타 양이 많아지면 손실남.

    데이타 사이에 칩셋을 껴서 얘가 데이타에 대한 입.출력을 컨트롤함.

윈도우 운영체제 안에서(윈도우 7입장)에서 vmware guest는 어차피 파일

그래서 얘는 의미 없음!

11. default, > Next           // (데이터 송.수신) IDE : 과거 회색 선 > SATA > Scaci?(SATA+Controller)

12. default, > Next           // 2번째 : 새로 만든거 복.붙해서 다른 pc에 옮기는 경우 3번째 : 진짜 hdd

13. 40(GB), default > Next  // Allocate all disk ~. : 모든 공간을 40으로 미리 설정 해버림..,

        // multiple ~ : 속도 좀 빨라짐..,

14. hdd 이름 확인 > Next

15. 현재 설정 정보 보임.

 

3) 윈도우 서버 2012 설치

1. CD/DVD (SATA) 클릭> [Virtual Machine Settings] > Use ISO image file: 클릭>

ko_windows_server_2012_r2_vl_x64_dvd_3316969.iso 넣기

2. default, > 다음

3. 지금 설치 클릭

4. Datacenter(GUI 포함) > 다음

cf. Server Core : CLI

5. 동의> 다음

6. 사용자 지정:Windows만 설치

7.  hdd 공간 할당 (x) > 다음

8. 설치 후 비번 설정 : P@ssw0rd    // 0 -> 숫자

로긴시 <Ctrl + Alt + Del> => <Ctrl + Alt + Insert> 로 할것~!

 

프로그램 끌 때, Power> Suspend

다시 시작시,    Power> Resume

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 강의 정리 내용 :

2월7일_20평일리2.txt

phpmyadmin_설치.txt

 

* phpmyadmin 프로그램

1> 개념

- 웹 환경에서 MySQL 프로그램의 기능을 거의 지원하는 MySQL 웹 관리 매니저 프로그램
- 웹 환경에서 MySQL의 데이터베이스, 테이블, 필드, 레코드 등을 쉽게 관리할 수 있음

2> 준비물

// 리눅스 웹 브라우저에서..,

http://www.phpmyadmin.net -> phpmyadmin 프로그램을 다운로드 받을 사이트!

버전 : 4.0.10.20~ tar.gz

# ls

# cd 다운로드

# ls

#

# tar xvzf php* -C /web/server/apache/

# cd /web/server/apache/

# ls

 

 

 

# mv php* phpmyadmin

 

# ls

# systemctl restart httpd.service

 

// 웹 브라우저 검색창에 다음과 같이 치기

192.168.46.90/phpmyadmin

 

// index.php라는걸 알려줘야..,

// apache 환경 설정 파일

/etc/httpd/conf/httpd.conf

 

168줄 :DirectoryIndex 항목은 기본적으로 index.html 만 지정

phpmyadmin 프로그램을 설치하는 과정에서 index.php가 필요하므로 위 항목에다가 추가를 해야함.

왼쪽부터 우선순위 임

# vi /etc/httpd/conf/httpd.conf

    169     DirectoryIndex index.html index.php        ; index.html이 없으면, index.php가 우선순위가 됨!

 

:wq

# systemctl restart httpd.service

F5                        // 코딩 소스가 뜨는데, 아직은 뭔가가 부족..,

 

// php 패키지 추가

# yum -y install --skip-broken php-*

# systemctl restart httpd.service

 

bank / itbank

실행

 

 

* Database

 

 

1> 개념

ㆍDatabase : 여러가지 공동의 업무에 필요한 데이터를 유기적으로 결합하여 저장한 집합체

 

ㆍDBMS(DataBase Management System)

- 데이타베이스 관리자라고도 불림

- 다수의 컴퓨터 사용자들의 데이터베이스 안에 데이터들을 기록하거나 접근할 수 있게 해주는 프로그램

- 목적은 데이터베이스 내의 정보 검색, 저장, 효율적인 환경을 제공함

- RDBMS(Relation(관계형) DBMS)는 표준화되어 사용자 및 프로그램 인터페이스를 제공함

 

ㆍSQL(Structured Query Language : 구조화 질의 언어)

- 종류로는 Oracle, MySQL, MariaDB 등이 있음

 

ㆍMySQL(CentOS 6.x 까지)

- SQL문을 사용하는 오픈 소스의 RDBMS

- 매우 빠르고 유연하고 사용하기 쉬운 장점

- 다중 사용자, 다중 스레드를 지원하고 C, C++, Java, PHP 스크립트 언어를 위한 응용 프로그램 인터페이스를

제공함

- 유닉스, 윈도우즈 서버, 리눅스에서도 사용함

 

MariaDB

- SQL문을 사용하는 오픈 소스의 RDBMS

- MySQL과 동일한 소스 코드를 기반으로 GPL v2 라이선스를 따름

- Oracle 소유의 현재 불확실한 MySQL의 라이선스 상태에서 반발하여 만들어짐

- MySQL 5.5 까지는 소스 코드가 거의 동일함

 

2> 실습

 

패키지명은 mariadb로 시작함

mariadb.service를 재시작

 

mariadb 접속방법

# mysql -u root -p mysql

 

mysql은 명령어

-u은 접속할 사용가 계정명

root는 관리자

-p는 접속할 사용자 계정의 비밀번호

mysql은 사용할 데이터베이스명

 

비밀번호는 처음이기 때문에 null 값이다.

 

mariadb 버전과 현재 날짜

select version(), current_date;

 

참고로 명령어 뒤에는 반드시 ; (세미콜론)을 입력!

 

① 첫번째 명령어

> show

 

show는 데이터베이스 목록을 출력

show는 테이블 목록을 출력

 

show는 데이터베이스와 테이블에서 사용 가능한 명령어

 

사용형식

> show databases;

> show tables;

 

table (> show tables;)

table은 관계형 데이터베이스에서 세로줄과 가로줄의 모델을 이용하여

정렬된 데이터 집합(값)의 모임

 

db table은 데이터베이스와 사용자를 연동(연결)시켜주는 테이블

user table은 사용자 생성 테이블 사용자는 user table에서만 생성할 수 있음

 

 ② 두번째 명령어

use

 

use는  데이터베이스를 변경

 

use는 데이터베이스에서 사용

 

사용형식

> use 데이터베이스;

 

③ 세번째 명령어

describe

 

describe는 접속한 데이터베이스의 테이블에 대한 스키마 정보를 확인

 

describe는 테이블에서 사용

 

사용형식

> describe 테이블;

> desc 테이블;

> explain 테이블;

 

스키마(schema)

- 데이터베이스를 구성하는 레코드의 크기, 키(key)의 정의, 레코드의 관계, 검색 방법 등을 정의

- 데이터베이스의 구조와 제약 조건에 전반적인 명세를 기술

 

④ 네번째 명령어

create

 

create는 데이터베이스를 생성

create는 테이블을 생성

 

create는 데이터베이스와 테이블에서 사용

 

사용형식(데이터베이스 생성)

> create database 데이터베이스명;

 

사용형식(테이블 생성)

> create table 테이블 (필드 필드타입 (길이));

→ 하나의 필드를 생성하면서 테이블 생성

 

> create table 테이블 (필드1 필드타입 (길이) 필드2 필드타입(길이), ...);

→ 여러개의 필드를 생성하면서 테이블 생성

 

field는 항목.

- 파일을 구성하는 기억 영역의 최소 단위로 특정한 종류의 데이터를 포함한 것

(ex. 재고파일의 품명번호, 색 코드)

⑤ 다섯번째 명령어

drop     // 개념적으로 큼

 

drop은 데이터베이스를 삭제

drop은 테이블을 삭제

 

drop은 데이터베이스와 테이블에서 사용

 

사용형식(데이터베이스 삭제)

> drop database 데이터베이스명;

 

사용형식(테이블 삭제)

> drop table 테이블;

 

⑥ 여섯번째 명령어

select

 

select는 접속한 데이터베이스에 테이블의 필드 안에 레코드를 조회(확인)

 

select는 테이블에서 상숑

 

레코드(record)는 데이터(값)로써 최소한의 단위

 

사용형식

> select *(모든필드) from 테이블;

→ 테이블의 모든 필드의 레코드를 조회

 

> select 필드1, 필드2, 필드3, ... from 테이블;

→ 테이블에 지정한 필드의 레코드를 조회

 

⑦ 일곱번쨰 명령어

update

 

update는 접속한 데이터베이스에 테이블의 필드 안에 레코드 수정

 

update는 테이블에서 사용

 

사용형식

> update 테이블 set 필드='값';

→ 테이블의 수정할 필드 안에 값을 전부 수정

 

> update 테이블 set 필드='값' where(조건) 필드='값';

→ 테이블의 수정할 필드 안에 값을 조건은 건 필드 쪽에만 수정

 

(참고로 password 필드 작업시 password()를 사용해야 암호화로 할 수 있음)

ex) password=password('값')

 

⑧ 여덟번째 명령어

delete // << drop보다 작은 개념

 

delete는 접속한 데이터베이스에 테이블의 필드 안에 레코드를 삭제

 

delete는 테이블에서 사용

 

사용형식

> delete from 테이블;

→ 테이블의 필드 안에 모든 레코드를 삭제 (지금 user 테이블에서 쓰면 망..,)

 

> delete from 테이블 where(조건) 필드='값';

→ 테이블에 조건을 건 필드 안에 레코드만 삭제

 

⑨ 아홉번째 명령어

insert

 

insert는 접속한 데이터베이스에 테이블의 필드 안에 레코드를 삽입

insert는 테이블에서 사용

 

사용형식

> insert into 테이블 (필드) value ('값');

→ 테이블의 필드 안에 레코드 하나 삽입

 

> insert into 테이블 (필드1, 필드2, 필드3, ... ) values ('값1', '값2', '값3',... );

→ 테이블의 여러 필드 안에 여러 레코드 삽입

 

⑩ 열번째 명령어

alter

 

alter는 접속한 데이터베이스에 테이블의 필드를 수정, 추가, 삭제 등

alter는 테이블에서 사용

 

사용형식(필드타입 수정)

> alter table 테이블 modify 필드 필드타입(길이);

 

사용형식(필드명 변경)

> alter table 테이블 change 기존필드  변경필드 필드타입(길이);

 

사용형식(필드 추가 : 맨 마지막에)

> alter table 테이블 add 필드 필드타입(길이); 

 

사용형식(필드 추가 : a필드와 b필드 사이에)

> alter table 테이블 add 필드 필드타입(길이) after a필드;

 

사용형식(필드 추가 : 맨 앞에)

> alter table 테이블 add 필드 필드타입(길이) first;

 

사용형식(필드 삭제)

> alter table 테이블 drop 필드;

 

 

 

cf) 기타 명령어

> help

리눅스 colsole의 clear == Ctrl + L

> 중간에 입력 잘못 했을 시, \c

 

 

 

 

[실습] db ↔ 사용자 연결

 

현재 kgitbank db가 있고, 사용자 bank 추가

 

사용자 생성

> insert into user (host, user, password) values ('localhost', '사용자', password('값'));

 

사용자와 데이터베이스 연동(연결)

> insert into db values ('localhost', '데이터베이스', '사용자', 'y'*19);

 

mariadb에서 작업한 설정을 적용하기 위해서 아래와 같은 방법을 사용

 

1) mariadb 프로그램에서 자체 적용 방법

flush privileges;

 

2) mariadb 프로그램 종료 후 적용방법

systemctl restart mariadb.service

 

 

 

 

 

 

// mariadb 실습

[root@junga ~]# yum -y install mariadb*
...

Complete!
[root@junga ~]# systemctl restart mariadb.service
[root@junga ~]#
[root@junga ~]# mysql -u root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> select version(), current_date;
+----------------+--------------+
| version()      | current_date |
+----------------+--------------+
| 5.5.56-MariaDB | 2018-02-06   |
+----------------+--------------+
1 row in set (0.00 sec)

MariaDB [mysql]>

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

> exit

// 2018.02.07

[root@junga ~]# systemctl restart mariadb.service
[root@junga ~]#
[root@junga ~]# mysql -u root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]>
MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> use test;
Database changed
MariaDB [test]>
MariaDB [test]> show tables;
Empty set (0.00 sec)

MariaDB [test]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> exit
Bye
[root@junga ~]# use mysql;
bash: use: 명령을 찾을 수 없습니다...
[root@junga ~]#
[root@junga ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]>
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

MariaDB [mysql]> describe db;
+-----------------------+---------------+------+-----+---------+-------+
| Field                 | Type          | Null | Key | Default | Extra |
+-----------------------+---------------+------+-----+---------+-------+
| Host                  | char(60)      | NO   | PRI |         |       |
| Db                    | char(64)      | NO   | PRI |         |       |
| User                  | char(16)      | NO   | PRI |         |       |
| Select_priv           | enum('N','Y') | NO   |     | N       |       |
| Insert_priv           | enum('N','Y') | NO   |     | N       |       |
| Update_priv           | enum('N','Y') | NO   |     | N       |       |
| Delete_priv           | enum('N','Y') | NO   |     | N       |       |
| Create_priv           | enum('N','Y') | NO   |     | N       |       |
| Drop_priv             | enum('N','Y') | NO   |     | N       |       |
| Grant_priv            | enum('N','Y') | NO   |     | N       |       |
| References_priv       | enum('N','Y') | NO   |     | N       |       |
| Index_priv            | enum('N','Y') | NO   |     | N       |       |
| Alter_priv            | enum('N','Y') | NO   |     | N       |       |
| Create_tmp_table_priv | enum('N','Y') | NO   |     | N       |       |
| Lock_tables_priv      | enum('N','Y') | NO   |     | N       |       |
| Create_view_priv      | enum('N','Y') | NO   |     | N       |       |
| Show_view_priv        | enum('N','Y') | NO   |     | N       |       |
| Create_routine_priv   | enum('N','Y') | NO   |     | N       |       |
| Alter_routine_priv    | enum('N','Y') | NO   |     | N       |       |
| Execute_priv          | enum('N','Y') | NO   |     | N       |       |
| Event_priv            | enum('N','Y') | NO   |     | N       |       |
| Trigger_priv          | enum('N','Y') | NO   |     | N       |       |
+-----------------------+---------------+------+-----+---------+-------+
22 rows in set (0.10 sec)

MariaDB [mysql]>

MariaDB [mysql]> desc user
    -> ;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field                  | Type                              | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host                   | char(60)                          | NO   | PRI |         |       |
| User                   | char(16)                          | NO   | PRI |         |       |
| Password               | char(41)                        | NO   |      |         |       |
| Select_priv            | enum('N','Y')                    | NO   |      | N      |       |
| Insert_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Update_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Delete_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Create_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Drop_priv              | enum('N','Y')                     | NO   |     | N       |       |
| Reload_priv            | enum('N','Y')                     | NO   |     | N       |       |
| Shutdown_priv          | enum('N','Y')                     | NO   |     | N       |       |
| Process_priv           | enum('N','Y')                     | NO   |     | N       |       |
| File_priv              | enum('N','Y')                     | NO   |     | N       |       |
| Grant_priv             | enum('N','Y')                     | NO   |     | N       |       |
| References_priv        | enum('N','Y')                     | NO   |     | N       |       |
| Index_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Alter_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Show_db_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Super_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Create_tmp_table_priv  | enum('N','Y')                     | NO   |     | N       |       |
| Lock_tables_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Execute_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Repl_slave_priv        | enum('N','Y')                     | NO   |     | N       |       |
| Repl_client_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Create_view_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Show_view_priv         | enum('N','Y')                     | NO   |     | N       |       |
| Create_routine_priv    | enum('N','Y')                     | NO   |     | N       |       |
| Alter_routine_priv     | enum('N','Y')                     | NO   |     | N       |       |
| Create_user_priv       | enum('N','Y')                     | NO   |     | N       |       |
| Event_priv             | enum('N','Y')                     | NO   |     | N       |       |
| Trigger_priv           | enum('N','Y')                     | NO   |     | N       |       |
| Create_tablespace_priv | enum('N','Y')                     | NO   |     | N       |       |
| ssl_type               | enum('','ANY','X509','SPECIFIED') | NO   |     |         |       |
| ssl_cipher             | blob                              | NO   |     | NULL    |       |
| x509_issuer            | blob                              | NO   |     | NULL    |       |
| x509_subject           | blob                              | NO   |     | NULL    |       |
| max_questions          | int(11) unsigned                  | NO   |     | 0       |       |
| max_updates            | int(11) unsigned                  | NO   |     | 0       |       |
| max_connections        | int(11) unsigned                  | NO   |     | 0       |       |
| max_user_connections   | int(11)                           | NO   |     | 0       |       |
| plugin                 | char(64)                          | NO   |     |         |       |
| authentication_string  | text                              | NO   |     | NULL    |       |
+------------------------+-----------------------------------+------+-----+---------+-------+
42 rows in set (0.00 sec)

MariaDB [mysql]> show database
    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database' at line 1
MariaDB [mysql]>
MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> create database testdatabase;
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> create database kgitbank;
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kgitbank           |
| mysql              |
| performance_schema |
| test               |
| testdatabase       |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [mysql]>
// 현재 작업공간은 mysql임!

MariaDB [mysql]>
MariaDB [mysql]> create table testtable;
ERROR 1113 (42000): A table must have at least 1 column
MariaDB [mysql]>

 

MariaDB [mysql]> help

General information about MariaDB can be found at
http://mariadb.org

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

MariaDB [mysql]>
MariaDB [mysql]> create table testtable;
ERROR 1113 (42000): A table must have at least 1 column
MariaDB [mysql]>
MariaDB [mysql]> create table testtable (number int(2),
    -> name char(20));
Query OK, 0 rows affected (0.11 sec)

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| testtable                 |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
25 rows in set (0.00 sec)

MariaDB [mysql]> desc testtable;
+--------+----------+------+-----+---------+-------+
| Field  | Type     | Null | Key | Default | Extra |
+--------+----------+------+-----+---------+-------+
| number | int(2)   | YES  |     | NULL    |       |
| name   | char(20) | YES  |     | NULL    |       |
+--------+----------+------+-----+---------+-------+
2 rows in set (0.00 sec)

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kgitbank           |
| mysql              |
| performance_schema |
| test               |
| testdatabase       |
+--------------------+
6 rows in set (0.00 sec)

MariaDB [mysql]> drop database testdatabase;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kgitbank           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [mysql]>
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| testtable                 |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
25 rows in set (0.00 sec)

MariaDB [mysql]>
MariaDB [mysql]> drop table testtable;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

MariaDB [mysql]>

MariaDB [mysql]> select * from user;
+----------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+
| Host           | User | Password | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string |
+----------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+
| localhost      | root |          | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
| junga.kgitbank | root |          | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
| 127.0.0.1      | root |          | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
| ::1            | root |          | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
| localhost      |      |          | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
| junga.kgitbank |      |          | N           | N           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            | N                      |          |            |             |              |             0 |           0 |               0 |                    0 |        |                       |
+----------------+------+----------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+--------+-----------------------+
6 rows in set (0.03 sec)

MariaDB [mysql]> select host, user, password from user;
+----------------+------+----------+
| host           | user | password |
+----------------+------+----------+
| localhost      | root |          |
| junga.kgitbank | root |          |
| 127.0.0.1      | root |          |
| ::1            | root |          |
| localhost      |      |          |
| junga.kgitbank |      |          |
+----------------+------+----------+
6 rows in set (0.17 sec)

 

MariaDB [mysql]> select * from db;
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
| Host | Db      | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Create_tmp_table_priv | Lock_tables_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Execute_priv | Event_priv | Trigger_priv |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
| %    | test    |      | Y           | Y           | Y           | Y           | Y           | Y         | N          | Y               | Y          | Y          | Y                     | Y                | Y                | Y              | Y                   | N                  | N            | Y          | Y            |
| %    | test\_% |      | Y           | Y           | Y           | Y           | Y           | Y         | N          | Y               | Y          | Y          | Y                     | Y                | Y                | Y              | Y                   | N                  | N            | Y          | Y            |
+------+---------+------+-------------+-------------+-------------+-------------+-------------+-----------+------------+-----------------+------------+------------+-----------------------+------------------+------------------+----------------+---------------------+--------------------+--------------+------------+--------------+
2 rows in set (0.05 sec)

MariaDB [mysql]> select host, db, user from db;
+------+---------+------+
| host | db      | user |
+------+---------+------+
| %    | test    |      |
| %    | test\_% |      |
+------+---------+------+
2 rows in set (0.00 sec)

MariaDB [mysql]>

MariaDB [mysql]> update user set password='itbank';
Query OK, 6 rows affected (0.07 sec)
Rows matched: 6  Changed: 6  Warnings: 0

MariaDB [mysql]> select host, user, password from user;
+----------------+------+----------+
| host           | user | password |
+----------------+------+----------+
| localhost      | root | itbank   |
| junga.kgitbank | root | itbank   |
| 127.0.0.1      | root | itbank   |
| ::1            | root | itbank   |
| localhost      |      | itbank   |
| junga.kgitbank |      | itbank   |
+----------------+------+----------+
6 rows in set (0.00 sec)

MariaDB [mysql]> update user set password=password('itbank') where user='root';
Query OK, 4 rows affected (0.03 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host           | user | password                                  |
+----------------+------+-------------------------------------------+
| localhost      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| junga.kgitbank | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| 127.0.0.1      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| ::1            | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| localhost      |      | itbank                                    |
| junga.kgitbank |      | itbank                                    |
+----------------+------+-------------------------------------------+
6 rows in set (0.00 sec)

MariaDB [mysql]> delete from user where user='' \c
MariaDB [mysql]>
MariaDB [mysql]> delete from user where password='itbank';
Query OK, 2 rows affected (0.00 sec)

MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host           | user | password                                  |
+----------------+------+-------------------------------------------+
| localhost      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| junga.kgitbank | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| 127.0.0.1      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| ::1            | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
+----------------+------+-------------------------------------------+
4 rows in set (0.00 sec)

 

MariaDB [mysql]> select host, db, user from db;
+------+---------+------+
| host | db      | user |
+------+---------+------+
| %    | test    |      |
| %    | test\_% |      |
+------+---------+------+
2 rows in set (0.00 sec)

MariaDB [mysql]>
MariaDB [mysql]> delete from db where user='' \c        //  or
MariaDB [mysql]>
MariaDB [mysql]> delete from db \c                           // or
MariaDB [mysql]>
MariaDB [mysql]> delete from db where host='%' \c      // or
MariaDB [mysql]>
MariaDB [mysql]> delete from db where db='test' or db='test\_%';
Query OK, 2 row affected (0.00 sec)

MariaDB [mysql]>
MariaDB [mysql]> select host, db, user from db;
Empty set (0.00 sec)

MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host           | user | password                                  |
+----------------+------+-------------------------------------------+
| localhost      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| junga.kgitbank | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| 127.0.0.1      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| ::1            | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
+----------------+------+-------------------------------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> insert into user (host, user, password) values
    -> ('localhost', 'bank', password('itbank'));
Query OK, 1 row affected, 4 warnings (0.00 sec)

MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host           | user | password                                  |
+----------------+------+-------------------------------------------+
| localhost      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| junga.kgitbank | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| 127.0.0.1      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| ::1            | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| localhost      | bank | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
+----------------+------+-------------------------------------------+
5 rows in set (0.01 sec)

 

// db ↔ 사용자 연결

MariaDB [mysql]> insert into db values('localhost', 'kgitbank',
    -> 'bank','y','y','y','y','y','y','y','y','y','y',
    -> 'y','y','y','y','y','y','y','y','y');
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> select host, db, user from db;
+-----------+----------+------+
| host      | db       | user |
+-----------+----------+------+
| localhost | kgitbank | bank |
+-----------+----------+------+
1 row in set (0.00 sec)

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kgitbank           |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [mysql]> select host, user, password from user;
+----------------+------+-------------------------------------------+
| host           | user | password                                  |
+----------------+------+-------------------------------------------+
| localhost      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| junga.kgitbank | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| 127.0.0.1      | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| ::1            | root | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
| localhost      | bank | *E1B74369B47EB3AD8EF858144E1A0364E3259329 |
+----------------+------+-------------------------------------------+
5 rows in set (0.00 sec)

MariaDB [mysql]> select host, db, user from db;
+-----------+----------+------+
| host      | db       | user |
+-----------+----------+------+
| localhost | kgitbank | bank |
+-----------+----------+------+
1 row in set (0.00 sec)

MariaDB [mysql]>
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.03 sec)

MariaDB [mysql]> quit
Bye
[root@junga ~]#
[root@junga ~]# mysql -u bank -p kgitbank
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [kgitbank]>
MariaDB [kgitbank]> show databases;        // 일반 사용자는 자신이 만든 table 밖에 못 봄
+--------------------+
| Database           |
+--------------------+
| information_schema |
| kgitbank           |
+--------------------+
2 rows in set (0.00 sec)

MariaDB [kgitbank]> create table kangsabu (number int(2),
    -> subject char(15), name char(20));
Query OK, 0 rows affected (0.04 sec)

MariaDB [kgitbank]> describe kangsabu;
+---------+----------+------+-----+---------+-------+
| Field   | Type     | Null | Key | Default | Extra |
+---------+----------+------+-----+---------+-------+
| number  | int(2)   | YES  |     | NULL    |       |
| subject | char(15) | YES  |     | NULL    |       |
| name    | char(20) | YES  |     | NULL    |       |
+---------+----------+------+-----+---------+-------+
3 rows in set (0.00 sec)

MariaDB [kgitbank]> select * from kangsabu;
Empty set (0.00 sec)

MariaDB [kgitbank]> insert into kangsabu(number, subject, name)
    -> values ('1','c_lang','kokildong');
Query OK, 1 row affected (0.00 sec)

MariaDB [kgitbank]> select number, subject, name from kangsabu;
+--------+---------+-----------+
| number | subject | name      |
+--------+---------+-----------+
|      1 | c_lang  | kokildong |
+--------+---------+-----------+
1 row in set (0.00 sec)

// 필드타입 수정

MariaDB [kgitbank]> alter table kangsabu modify subject varchar(15);
Query OK, 1 row affected (0.03 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]> desc kangsabu;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| number  | int(2)      | YES  |     | NULL    |       |
| subject | varchar(15) | YES  |     | NULL    |       |
| name    | char(20)    | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

// 필드명 변경

MariaDB [kgitbank]> alter table kangsabu change number num int(2);
Query OK, 1 row affected (0.01 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]> desc kangsabu;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| num     | int(2)      | YES  |     | NULL    |       |
| subject | varchar(15) | YES  |     | NULL    |       |
| name    | char(20)    | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

// 필드 추가 (맨 마지막에)

MariaDB [kgitbank]> alter table kangsabu add age int(2);
Query OK, 1 row affected (0.04 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]> desc kangsabu;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| num     | int(2)      | YES  |     | NULL    |       |
| subject | varchar(15) | YES  |     | NULL    |       |
| name    | char(20)    | YES  |     | NULL    |       |
| age     | int(2)      | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

 

// 필드 추가 (중간에)

MariaDB [kgitbank]> alter table kangsabu add bloodtype char(3) after subject;
Query OK, 1 row affected (0.00 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]> desc kangsabu;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| num       | int(2)      | YES  |     | NULL    |       |
| subject   | varchar(15) | YES  |     | NULL    |       |
| bloodtype | char(3)     | YES  |     | NULL    |       |
| name      | char(20)    | YES  |     | NULL    |       |
| age       | int(2)      | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

// 필드 추가 (맨 앞에)

MariaDB [kgitbank]> alter table kangsabu add address char(20) first;
Query OK, 1 row affected (0.00 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]>
MariaDB [kgitbank]> desc kangsabu;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| address   | char(20)    | YES  |     | NULL    |       |
| num       | int(2)      | YES  |     | NULL    |       |
| subject   | varchar(15) | YES  |     | NULL    |       |
| bloodtype | char(3)     | YES  |     | NULL    |       |
| name      | char(20)    | YES  |     | NULL    |       |
| age       | int(2)      | YES  |     | NULL    |       |
+-----------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

// 필드 삭제

MariaDB [kgitbank]> alter table kangsabu drop bloodtype;
Query OK, 1 row affected (0.05 sec)               
Records: 1  Duplicates: 0  Warnings: 0

MariaDB [kgitbank]> desc kangsabu;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| address | char(20)    | YES  |     | NULL    |       |
| num     | int(2)      | YES  |     | NULL    |       |
| subject | varchar(15) | YES  |     | NULL    |       |
| name    | char(20)    | YES  |     | NULL    |       |
| age     | int(2)      | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 강사님 강의 노트 :

2월6일_19평일리2.txt

* Database

1> 개념

ㆍDatabase : 여러가지 공동의 업무에 필요한 데이터를 유기적으로 결합하여 저장한 집합체

 

ㆍDBMS(DataBase Management System)

- 데이타베이스 관리자라고도 불림

- 다수의 컴퓨터 사용자들의 데이터베이스 안에 데이터들을 기록하거나 접근할 수 있게 해주는 프로그램

- 목적은 데이터베이스 내의 정보 검색, 저장, 효율적인 환경을 제공함

- RDBMS(Relation(관계형) DBMS)는 표준화되어 사용자 및 프로그램 인터페이스를 제공함

 

ㆍSQL(Structured Query Language : 구조화 질의 언어)

- 종류로는 Oracle, MySQL, MariaDB 등이 있음

 

ㆍMySQL(CentOS 6.x 까지)

- SQL문을 사용하는 오픈 소스의 RDBMS

- 매우 빠르고 유연하고 사용하기 쉬운 장점

- 다중 사용자, 다중 스레드를 지원하고 C, C++, Java, PHP 스크립트 언어를 위한 응용 프로그램 인터페이스를

제공함

- 유닉스, 윈도우즈 서버, 리눅스에서도 사용함

 

MariaDB

- SQL문을 사용하는 오픈 소스의 RDBMS

- MySQL과 동일한 소스 코드를 기반으로 GPL v2 라이선스를 따름

- Oracle 소유의 현재 불확실한 MySQL의 라이선스 상태에서 반발하여 만들어짐

- MySQL 5.5 까지는 소스 코드가 거의 동일함

 

2> 실습

 

패키지명은 mariadb로 시작함

mariadb.service를 재시작

 

mariadb 접속방법

# mysql -u root -p mysql

 

mysql은 명령어

-u은 접속할 사용가 계정명

root는 관리자

-p는 접속할 사용자 계정의 비밀번호

mysql은 사용할 데이터베이스명

 

비밀번호는 처음이기 때문에 null 값이다.

 

mariadb 버전과 현재 날짜

select version(), current_date;

 

참고로 명령어 뒤에는 반드시 ; (세미콜론)을 입력!

 

① 첫번째 명령어

> show

 

show는 데이터베이스 목록을 출력

show는 테이블 목록을 출력

 

show는 데이터베이스와 테이블에서 사용 가능한 명령어

 

사용형식

> show databases;

> show tables;

 

cf) table (> show tables;)

table은 관계형 데이터베이스에서 세로줄과 가로줄의 모델을 이용하여

정렬된 데이터 집합(값)의 모임

 

db table은 데이터베이스와 사용자를 연동(연결)시켜주는 테이블

user table은 사용자 생성 테이블 사용자는 user table에서만 생성할 수 있음

 

 

 

 

 

 

// mariadb 실습

[root@junga ~]# yum -y install mariadb*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.daumkakao.com
 * extras: ftp.daumkakao.com
 * updates: ftp.daumkakao.com
Package 1:mariadb-libs-5.5.56-2.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be installed
---> Package mariadb-bench.x86_64 1:5.5.56-2.el7 will be installed
--> Processing Dependency: perl(GD) for package: 1:mariadb-bench-5.5.56-2.el7.x86_64
---> Package mariadb-devel.x86_64 1:5.5.56-2.el7 will be installed
--> Processing Dependency: openssl-devel(x86-64) for package: 1:mariadb-devel-5.5.56-2.el7.x86_64
---> Package mariadb-embedded.x86_64 1:5.5.56-2.el7 will be installed
---> Package mariadb-embedded-devel.x86_64 1:5.5.56-2.el7 will be installed
---> Package mariadb-server.x86_64 1:5.5.56-2.el7 will be installed
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.56-2.el7.x86_64
---> Package mariadb-test.x86_64 1:5.5.56-2.el7 will be installed
--> Processing Dependency: perl(Test::More) for package: 1:mariadb-test-5.5.56-2.el7.x86_64
--> Processing Dependency: perl(Env) for package: 1:mariadb-test-5.5.56-2.el7.x86_64
--> Running transaction check
---> Package openssl-devel.x86_64 1:1.0.2k-8.el7 will be installed
--> Processing Dependency: zlib-devel(x86-64) for package: 1:openssl-devel-1.0.2k-8.el7.x86_64
--> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-8.el7.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
---> Package perl-Env.noarch 0:1.04-2.el7 will be installed
---> Package perl-GD.x86_64 0:2.49-3.el7 will be installed
---> Package perl-Test-Simple.noarch 0:0.98-243.el7 will be installed
--> Running transaction check
---> Package krb5-devel.x86_64 0:1.15.1-8.el7 will be installed
--> Processing Dependency: libkadm5(x86-64) = 1.15.1-8.el7 for package: krb5-devel-1.15.1-8.el7.x86_64
--> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-8.el7.x86_64
--> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-8.el7.x86_64
--> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-8.el7.x86_64
--> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-8.el7.x86_64
---> Package zlib-devel.x86_64 0:1.2.7-17.el7 will be installed
--> Running transaction check
---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed
---> Package libcom_err-devel.x86_64 0:1.42.9-10.el7 will be installed
---> Package libkadm5.x86_64 0:1.15.1-8.el7 will be installed
---> Package libselinux-devel.x86_64 0:2.5-11.el7 will be installed
--> Processing Dependency: libsepol-devel(x86-64) >= 2.5-6 for package: libselinux-devel-2.5-11.el7.x86_64
--> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-11.el7.x86_64
--> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-11.el7.x86_64
---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed
--> Running transaction check
---> Package libsepol-devel.x86_64 0:2.5-6.el7 will be installed
---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================
 Package                        Arch           Version                  Repository    Size
===========================================================================================
Installing:
 mariadb                        x86_64         1:5.5.56-2.el7           base         8.7 M
 mariadb-bench                  x86_64         1:5.5.56-2.el7           base         388 k
 mariadb-devel                  x86_64         1:5.5.56-2.el7           base         752 k
 mariadb-embedded               x86_64         1:5.5.56-2.el7           base         3.6 M
 mariadb-embedded-devel         x86_64         1:5.5.56-2.el7           base         7.4 M
 mariadb-server                 x86_64         1:5.5.56-2.el7           base          11 M
 mariadb-test                   x86_64         1:5.5.56-2.el7           base         8.1 M
Installing for dependencies:
 keyutils-libs-devel            x86_64         1.5.8-3.el7              base          37 k
 krb5-devel                     x86_64         1.15.1-8.el7             base         266 k
 libcom_err-devel               x86_64         1.42.9-10.el7            base          31 k
 libkadm5                       x86_64         1.15.1-8.el7             base         174 k
 libselinux-devel               x86_64         2.5-11.el7               base         186 k
 libsepol-devel                 x86_64         2.5-6.el7                base          74 k
 libverto-devel                 x86_64         0.2.5-4.el7              base          12 k
 openssl-devel                  x86_64         1:1.0.2k-8.el7           base         1.5 M
 pcre-devel                     x86_64         8.32-17.el7              base         480 k
 perl-DBD-MySQL                 x86_64         4.023-5.el7              base         140 k
 perl-Env                       noarch         1.04-2.el7               base          16 k
 perl-GD                        x86_64         2.49-3.el7               base         173 k
 perl-Test-Simple               noarch         0.98-243.el7             base         170 k
 zlib-devel                     x86_64         1.2.7-17.el7             base          50 k

Transaction Summary
===========================================================================================
Install  7 Packages (+14 Dependent packages)

Total download size: 43 M
Installed size: 285 M
Downloading packages:
(1/21): libcom_err-devel-1.42.9-10.el7.x86_64.rpm                   |  31 kB  00:00:00    
(2/21): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm                  |  37 kB  00:00:02    
(3/21): krb5-devel-1.15.1-8.el7.x86_64.rpm                          | 266 kB  00:00:02    
(4/21): libsepol-devel-2.5-6.el7.x86_64.rpm                         |  74 kB  00:00:00    
(5/21): libkadm5-1.15.1-8.el7.x86_64.rpm                            | 174 kB  00:00:00    
(6/21): libverto-devel-0.2.5-4.el7.x86_64.rpm                       |  12 kB  00:00:00    
(7/21): mariadb-bench-5.5.56-2.el7.x86_64.rpm                       | 388 kB  00:00:00    
(8/21): mariadb-devel-5.5.56-2.el7.x86_64.rpm                       | 752 kB  00:00:00    
(9/21): libselinux-devel-2.5-11.el7.x86_64.rpm                      | 186 kB  00:00:02    
(10/21): mariadb-embedded-5.5.56-2.el7.x86_64.rpm                   | 3.6 MB  00:00:10    
(11/21): mariadb-5.5.56-2.el7.x86_64.rpm                            | 8.7 MB  00:00:30    
(12/21): mariadb-embedded-devel-5.5.56-2.el7.x86_64.rpm             | 7.4 MB  00:01:24    
mariadb-test-5.5.56-2.el7.x86_ FAILED                                         
http://ftp.daumkakao.com/centos/7.4.1708/os/x86_64/Packages/mariadb-test-5.5.56-2.el7.x86_64.rpm: [Errno 14] curl#18 - "transfer closed with 7331664 bytes remaining to read"
Trying other mirror.
(13/21): pcre-devel-8.32-17.el7.x86_64.rpm                          | 480 kB  00:00:00    
(14/21): openssl-devel-1.0.2k-8.el7.x86_64.rpm                      | 1.5 MB  00:00:00    
(15/21): mariadb-server-5.5.56-2.el7.x86_64.rpm                     |  11 MB  00:01:26    
(16/21): perl-GD-2.49-3.el7.x86_64.rpm                              | 173 kB  00:00:00    
(17/21): perl-Test-Simple-0.98-243.el7.noarch.rpm                   | 170 kB  00:00:00    
(18/21): zlib-devel-1.2.7-17.el7.x86_64.rpm                         |  50 kB  00:00:00    
(19/21): perl-DBD-MySQL-4.023-5.el7.x86_64.rpm                      | 140 kB  00:00:05    
(20/21): perl-Env-1.04-2.el7.noarch.rpm                             |  16 kB  00:00:05    
mariadb-test-5.5.56-2.el7.x86_ FAILED                                          7:10:46 ETA
http://ftp.kaist.ac.kr/CentOS/7.4.1708/os/x86_64/Packages/mariadb-test-5.5.56-2.el7.x86_64.rpm: [Errno 12] Timeout on http://ftp.kaist.ac.kr/CentOS/7.4.1708/os/x86_64/Packages/mariadb-test-5.5.56-2.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
(21/21): mariadb-test-5.5.56-2.el7.x86_64.rpm                       | 8.1 MB  00:00:00    
-------------------------------------------------------------------------------------------
Total                                                      285 kB/s |  43 MB  00:02:36    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mariadb-5.5.56-2.el7.x86_64                                          1/21
  Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                                      2/21
  Installing : 1:mariadb-server-5.5.56-2.el7.x86_64                                   3/21
  Installing : libsepol-devel-2.5-6.el7.x86_64                                        4/21
  Installing : pcre-devel-8.32-17.el7.x86_64                                          5/21
  Installing : libselinux-devel-2.5-11.el7.x86_64                                     6/21
  Installing : libkadm5-1.15.1-8.el7.x86_64                                           7/21
  Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64                                 8/21
  Installing : 1:mariadb-embedded-5.5.56-2.el7.x86_64                                 9/21
  Installing : libverto-devel-0.2.5-4.el7.x86_64                                     10/21
  Installing : libcom_err-devel-1.42.9-10.el7.x86_64                                 11/21
  Installing : krb5-devel-1.15.1-8.el7.x86_64                                        12/21
  Installing : perl-GD-2.49-3.el7.x86_64                                             13/21
  Installing : perl-Test-Simple-0.98-243.el7.noarch                                  14/21
  Installing : zlib-devel-1.2.7-17.el7.x86_64                                        15/21
  Installing : 1:openssl-devel-1.0.2k-8.el7.x86_64                                   16/21
  Installing : 1:mariadb-devel-5.5.56-2.el7.x86_64                                   17/21
  Installing : perl-Env-1.04-2.el7.noarch                                            18/21
  Installing : 1:mariadb-test-5.5.56-2.el7.x86_64                                    19/21
  Installing : 1:mariadb-embedded-devel-5.5.56-2.el7.x86_64                          20/21
  Installing : 1:mariadb-bench-5.5.56-2.el7.x86_64                                   21/21
  Verifying  : perl-Env-1.04-2.el7.noarch                                             1/21
  Verifying  : 1:mariadb-embedded-devel-5.5.56-2.el7.x86_64                           2/21
  Verifying  : zlib-devel-1.2.7-17.el7.x86_64                                         3/21
  Verifying  : perl-Test-Simple-0.98-243.el7.noarch                                   4/21
  Verifying  : perl-GD-2.49-3.el7.x86_64                                              5/21
  Verifying  : libcom_err-devel-1.42.9-10.el7.x86_64                                  6/21
  Verifying  : libverto-devel-0.2.5-4.el7.x86_64                                      7/21
  Verifying  : 1:mariadb-embedded-5.5.56-2.el7.x86_64                                 8/21
  Verifying  : krb5-devel-1.15.1-8.el7.x86_64                                         9/21
  Verifying  : libselinux-devel-2.5-11.el7.x86_64                                    10/21
  Verifying  : 1:mariadb-devel-5.5.56-2.el7.x86_64                                   11/21
  Verifying  : 1:mariadb-bench-5.5.56-2.el7.x86_64                                   12/21
  Verifying  : keyutils-libs-devel-1.5.8-3.el7.x86_64                                13/21
  Verifying  : libkadm5-1.15.1-8.el7.x86_64                                          14/21
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                         15/21
  Verifying  : libsepol-devel-2.5-6.el7.x86_64                                       16/21
  Verifying  : 1:mariadb-test-5.5.56-2.el7.x86_64                                    17/21
  Verifying  : 1:mariadb-server-5.5.56-2.el7.x86_64                                  18/21
  Verifying  : 1:openssl-devel-1.0.2k-8.el7.x86_64                                   19/21
  Verifying  : perl-DBD-MySQL-4.023-5.el7.x86_64                                     20/21
  Verifying  : 1:mariadb-5.5.56-2.el7.x86_64                                         21/21

Installed:
  mariadb.x86_64 1:5.5.56-2.el7                   mariadb-bench.x86_64 1:5.5.56-2.el7     
  mariadb-devel.x86_64 1:5.5.56-2.el7             mariadb-embedded.x86_64 1:5.5.56-2.el7  
  mariadb-embedded-devel.x86_64 1:5.5.56-2.el7    mariadb-server.x86_64 1:5.5.56-2.el7    
  mariadb-test.x86_64 1:5.5.56-2.el7            

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7       krb5-devel.x86_64 0:1.15.1-8.el7        
  libcom_err-devel.x86_64 0:1.42.9-10.el7        libkadm5.x86_64 0:1.15.1-8.el7          
  libselinux-devel.x86_64 0:2.5-11.el7           libsepol-devel.x86_64 0:2.5-6.el7       
  libverto-devel.x86_64 0:0.2.5-4.el7            openssl-devel.x86_64 1:1.0.2k-8.el7     
  pcre-devel.x86_64 0:8.32-17.el7                perl-DBD-MySQL.x86_64 0:4.023-5.el7     
  perl-Env.noarch 0:1.04-2.el7                   perl-GD.x86_64 0:2.49-3.el7             
  perl-Test-Simple.noarch 0:0.98-243.el7         zlib-devel.x86_64 0:1.2.7-17.el7        

Complete!
[root@junga ~]# mysql -u root -p mysql
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@junga ~]#
[root@junga ~]# systemctl restart mariadb.service
[root@junga ~]#
[root@junga ~]# mysql -u root -p mysql
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [mysql]> select version(), current_date;
+----------------+--------------+
| version()      | current_date |
+----------------+--------------+
| 5.5.56-MariaDB | 2018-02-06   |
+----------------+--------------+
1 row in set (0.00 sec)

MariaDB [mysql]>

MariaDB [mysql]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

 

 

 

 

 

 

 

* Web Server(Apache)

1> 개념

- apache 웹 서버는 공개형 웹 서버 프로그램으로써 다양한 플랫폼에서 동작할 수 있도록 설계가 되어있음

- apache 웹 서버는 클라이언트가 웹 브라우저를 통해서 요청한 데이터를 클라이언트 웹 브라우저로 보내는 역할

다시 말하면, 웹 서버는 클라이언트의 요청을 기다리고 있다가 요청을 받게 되면 해당 데이터를 보내는 프로그램

 

2> 특징

- standalone (계속 가동중, 요청 기다림)

 

3> 설정파일

① /etc/httpd/conf/httpd.conf

-httpd의 설정파일

 

31줄 : 웹 서버 설정파일, 바이너리 파일, 로그 파일, 모듈 파일 등이 저장되어 있는 기본 디렉터리를

지정

41줄 : 지정한 IP Address를 80번 포트로 듣겠음

42줄 : 모든 IP Address를 80번 포트로 듣겠음

ex> 포트를 바꾸는 경우는 보통 서버 리뉴얼을 하는 경우 바꿔서 작업하고 작업 완료시 포트를 원래로 바꿔줌

ex> clubbox에 각 메뉴 탭들을 보면 사용하는 web언어와, 포트가 각 메뉴마다 다른 것을 확인 할 수 있다.

=> 41, 42 둘 중 하나만 써야..,

( 참고로 serverTokens 항목이 centOS 6.x이하에는 있었는데 centOS 6에서는 없어짐

ServerTokens

- 오류 및 서버 메시지를 출력되는 서버에 대한 정보를 설정

CentOS 7 에서는 ServerTokens를 사용하기 위해서 별도로 추가를 해야함

ServerSignature on

값의 종류

Full    → 아파치 서버 버전, 운영체제 정보, 모듈 정보

OS    → 아파치 서버 버전, 운영 체제 정보

Major→ 어퍼차 서버의 주 버전    

Min  → 아파치 서버의 모든 버전

Minor→ 아차피 서버의 하위 버전

Prod → 아파치 서버의 정보 )

 

56줄 : 모듈 관련 파일을 httpd.conf 설정파일에 포함하겠음

(ls -l /etc/httpd/conf.modules.d/*.conf   # /conf.modules.d 하위에 모든 파일목록)

 

66, 67줄 : 실행되는 httpd의 사용자 및 그룹 권한을 설정하는 항목

(보안상 nobody로 사용함)

 

69줄은 서버 설정

86줄: 관리자 e-mail 주소를 적어주는 항목

- 웹 문서 로딩시 에러가 발생 했을 경우 에러 페이지에 보여질 관리자 e-mail 주소를 알려줌

 

94줄 : 클라이언트에게 보여줄 호스트 네임을 지정하는 항목 만약 DNS가 없을 시 IP Address

입력해야함

 

101~104줄 : 최상위 디렉터리에 대한 기본 옵션과 권한을 나타내는 설정

AllowOverride 지시자는 어떻게 접근을 허용할 것인지에 대한 설정

Require all denied는 요구하는 모든 것들을 거부하겠음

denied를 granted로 변경하면 허용하겠다라는 의미

 

118줄 : 관리자의 문서        // index.html 관련

- 서버의 웹 문서가 들어있는 경로를 지정

- 참고로 맨 마지막에 /를 추가하지 않음(dir. 티낼 필요 없음!)

- 심볼릭 링크파일이나 alias로 다른 경로를 가르키도록 설정할 수 있음

다시 말해, 웹 문서가 들어있는 경로

// centOS 6.x 버전대와 달리 centOS 7은 123, 130 라인을 추가해줘야..,

 

123~127줄은 /var/www  디렉터리에 대해서 별도로 기본 옵션과 권한을 나타내는 설정

130 ~156줄은 /var/www/html 디렉터리에 대해서 기본 옵션과 권한을 나타내는 설정

143줄 : Options 지시자는 지정한 디렉터리 하위에 모든 파일과 디렉터리를 적용할

접근 제어를 설정

Indexes는 URL(Uniform Resource Locator : 자원 위치 지정자)을 지정한 디렉터리에

index.html과 같은 지정한 파일이 없을 경우 해당 디렉터리의 파일 목록을 보여줌 

FollowSymLinks는 디렉터리내에서 심볼릭 링크의 사용을 허가함

 

② /etc/httpd/conf.d/userdir.conf
(참고로 centOS 6.x (이하)
/etc/httpd/conf/httpd.conf 파일에
포함되어 있음)
- 웹 서버에서 root 이외에 다른 계정으로
홈페이지를 운영할 때 사용자의 웹 문서
디렉터리를 지정하는 곳
- 사용자 계정의 홈 디렉터리를 이용하여
페이지 출력

 

vi /etc/httpd/conf.d/userdir.conf

17줄 : 사용할 사용자 계정을 활성화 또는
비활성화 설정하는 항목

ex)
UserDir disabled
→ 모든 사용자 계정을 비활성화
UserDir disabled 계정명
→ 지정한 사용자 계정을 비활성화
UserDir enabled
→ 모든 사용자 계정을 활성화
UserDir enabled 계정명
→ 지정한 사용자 계정을 활성화
UserDir enabled 계정명1 계정명2
→ 여러 사용자 계정을 활성화

24줄 : 지정한 사용자 계정의 웹
경로로 사용할 기본 디렉터리를 지정하는 항목

 

/etc/httpd/conf.d/autoindex.conf

(참고로 centOS 6.x (이하))

/etc/httpd/conf/httpd.conf 파일에 포함되어 있음

centOS 7.x 버전부터는 기능이 나뉘어서 파일이 분리됨)

- 특정 디렉터리를 주소의 일부 페이지처럼 사용할 수 있게 함

 

21줄 : Alias /icons/

"/usr/share/httpd/icons/"

 

/icons/ 는 fakename

"/usr/share/httpd/icons/" 는 realname

 

fakename은 realname으로 설정된 경로에 있는 index.html의 내용을

마치 웹 페이지 주소처럼 사용하기 위해 속이는 이름

realname은 fakename을 사용해서 내용을 출력하기 위한 실제

index.html 파일이 저장되어 있는 디렉터리

 

VirtualHost(가상 호스트)

(참고로 CentOS6.x(이하)에는

/etc/httpd/conf/httpd.conf 파일에 있었던 내용인데 별도로 작업을 해야함)

 

준비물

/etc/httpd/conf.d 디렉터리 하위에 파일을 생성(파일명은 예를 들면 vhost.conf)

www.miylifebravo.com 외에

cafe.mylifebravo.com을 추가

 

/etc/httpd/conf.d/vhost.conf(이 파일은 우리가 생성한 파일임)

 

1줄 : <VirtuaHost *:80> 또는 <VirtualHost IP Address:80>    // 80 : port no.

2줄 : ServerAdmin 관리자의 e-mail

3줄 : ServerName 사용할 호스트네임

4줄 : DocumentRoot 사용할 디렉터리(웹 문서 경로)

5줄 : ErrorLog  "logs/사용할 로그파일

→ 아파치 웹 서버의 에러로그파일의 위치를 지정함(별도로)

(기본: ls -l /etc/httpd/

lrwxrwxrwx 1 root root  19  2월  2 15:12 logs -> ../../var/log/httpd)

6줄 : CustomLog "logs/사용할 로그파일 (각각 파일명을 지정)

→ 아파치 웹 서버의 웹로그파일 위치를 지정

common(접근정보), agent, referer 정보를 모두 저장하기 위함

7줄 : </VirtuaHost>

 

가상호스트를 사용하면 기존에

DocumentRoot가 가상호스트의 DocumentRoot를 따라가기 때문에

이를 방지하기 위하여 맨 첫줄에 아래와 같이 작업

<VirtuaHost *:80>

</VirtuaHost>

ex)

1 → 2    => 1 → 1

1 → 2

 

위 설정이 다 되었으면 저장 후 종료

 

가상호스트의 DocumentRoot를 생성

생성한 디렉터리 하위에 index.html 생성

생성한 index.html 파일안에 내용 입력

 

/etc/httpd/conf/httpd.conf 파일에

별도로 123줄~127줄처럼 해당 경로를 추가

 

 

 

 

4> 명령어

web server(apache)

서비스명은 httpd.service

 

 

 

 

 

* Web Browser

1> 개념

- 사용자가 웹 서버에게 필요한 데이터를 요청하도록 해주며 웹 서버가 응답하게 되면 데이터를 컴파일을 통해서

사용자에게 보여주는 역할


2> Web Browser의 종류

Windows → Internet Explorer, Edge

Linux → Firefox

Google → Chrome

Apple → Safari

 

3> 관련 용어

Web Server는 80번 포트를 사용(Well-known)

 

HTTP(Hyper Text Transfer Protocol)

- WWW(World Wide Web) 상에서 정보를 주고받을 수 있는 프로토콜.

주로 html 문서를 주고받는데 쓰임.

- 클라이언트와 서버 사이에 이루어지는 요청(Request)/응답(Response) 프로토콜.

 

Web Document(웹 문서 : HTML 문서)

- 웹 문서는 이미지가 포함된 정적인 형태의 html 문서만을 제공함

 

4> 특징

① 정적 웹 서버의 동작 방식

- 기본적으로 apache 웹 서버는 HTML(HyperText Markup Language)과 같은 정적인 데이터만 처리하게 됨

- 정적이라고 하는 것은 접속 후 데이터를 요청할 때마다 똑같은(변하지 않음) 데이터만 보낸다는 것을 의미

- 호출한 파일을 클라이언트로 가지고 와서 실행함

CSSL(Client Side Script Language) : html, java scripts

- 보안상 취약

- 누구든지 다 볼 수 있음

 

② 동적 웹 서버의 동작 방식

- 동적인 데이터를 처리하기 위해서 웹 스크립트 언어인 C, ASP(Active Server Page), PHP(Personal

Hypertext Preprocessor), JSP(Pava Server Page), Python, Perl 등

 

모듈(Module)은 '전체를 다루는 일부'라고 의미를 둘 수 있음

- 프로그램 내부적으로 하나의 종합된 동작을 하도록 작은 부분을 분할함

더 찾아봥~!

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

SSSL(Server Side Script Language) : asp, php 등등

- 보안상 강함

- 나 혼자 보는 것

 

(참고로 Linux는 웹 서버는 Apache, FTP 서버는 vsftpd 사용함

Windows Server는 IIS(Internet Information Service)를 사용함

IIS가 웹 서버와 FTP Server를 포함하고 있음)

 

ex>

사용자들이 naver 요청하면 모두 같은 웹 브라우저를 보게됨 → 정적

여기서 로그인을 하면 모두 다른 화면이 나옴. 나혼자 보는 것→ 동적

인터넷 키면, 웹서버(Apache), DNS, DB 등 같이 구동중..,

 

// ② UserDir.conf 설정 (/etc/httpd/conf.d/userdir.conf 17, 24줄 )


# systemctl restart named.service
# systemctl restart httpd.service

# vi /etc/httpd/conf.d/userdir.conf
     17     UserDir enabled bonwon
 
     24     UserDir public_html

// 준비물 셋팅
[root@junga ~]# cp -r /etc/skel /userdirskel
[root@junga ~]#
[root@junga ~]# mkdir /userdirskel/public_html
[root@junga ~]#
[root@junga ~]# ls -la /userdirskel
합계 16
drwxr-xr-x   4 root root   97  2월  6 13:07 .
dr-xr-xr-x. 22 root root 4096  2월  6 13:07 ..
-rw-r--r--   1 root root   18  2월  6 13:07 .bash_logout
-rw-r--r--   1 root root  193  2월  6 13:07 .bash_profile
-rw-r--r--   1 root root  231  2월  6 13:07 .bashrc
drwxr-xr-x   4 root root   39  2월  6 13:07 .mozilla
drwxr-xr-x   2 root root    6  2월  6 13:07 public_html
[root@junga ~]#
[root@junga ~]# useradd -m -k /userdirskel bonwon
[root@junga ~]#
[root@junga ~]# ls -la /home/bonwon
합계 12
drwx------  4 bonwon bonwon  97  2월  6 13:08 .
drwxr-xr-x. 4 root   root    34  2월  6 13:08 ..
-rw-r--r--  1 bonwon bonwon  18  2월  6 13:07 .bash_logout
-rw-r--r--  1 bonwon bonwon 193  2월  6 13:07 .bash_profile
-rw-r--r--  1 bonwon bonwon 231  2월  6 13:07 .bashrc
drwxr-xr-x  4 bonwon bonwon  39  2월  6 13:07 .mozilla
drwxr-xr-x  2 bonwon bonwon   6  2월  6 13:07 public_html
[root@junga ~]#
[root@junga ~]# systemctl restart httpd.service
[root@junga ~]#
[root@junga ~]# touch /home/bonwon/public_html/index.html
[root@junga ~]#
[root@junga ~]# vi /home/bonwon/public_html/index.html
Hello~ This is UserDir Page!!! :)

[root@junga ~]#
[root@junga ~]# ls -l /home/bonwon/public_html/
합계 4
-rw-r--r-- 1 root root 34  2월  6 13:13 index.html
[root@junga ~]#

// 파이어 폭스
http://www.mylifebravo.com/~bonwon
      -------
=> NOT FOUND

# systemctl restart httpd.service

// 허가권 변경
[root@junga ~]# ls -ld /home/bonwon/
drwx------ 4 bonwon bonwon 97  2월  6 13:08 /home/bonwon/
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# chmod 711 /home/bonwon
[root@junga ~]#
[root@junga ~]# ls -ld /home/bonwon/
drwx--x--x 4 bonwon bonwon 97  2월  6 13:08 /home/bonwon/

// 파이어 폭스
http://www.mylifebravo.com/~bonwon
      -------

=> Forbidden

[root@junga ~]# chmod 711 /home/bonwon
[root@junga ~]#
[root@junga ~]# ls -ld /home/bonwon/
drwx--x--x 4 bonwon bonwon 97  2월  6 13:08 /home/bonwon/

[root@junga ~]# ls -l /etc/httpd/conf.d
합계 20
-rw-r--r-- 1 root root  366 10월 20 05:39 README
-rw-r--r-- 1 root root 2926 10월 20 05:39 autoindex.conf
-rw-r--r-- 1 root root  323 10월 20 01:44 manual.conf
-rw-r--r-- 1 root root 1257  2월  6 13:07 userdir.conf
-rw-r--r-- 1 root root  824 10월 20 01:44 welcome.conf

 

// ③ Alias dir.설정 (/etc/httpd/conf.d/autoindex.conf)

# vi /etc/httpd/conf.d/autoindex.conf

     21 Alias /icons/ "/usr/share/httpd/icons/"
     22 Alias /itbank/ "/a/b/c/"
     23
     24 <Directory "/usr/share/httpd/icons">
     25     Options Indexes MultiViews FollowSymlinks
     26     AllowOverride None
     27     Require all granted
     28 </Directory>
     29 <Directory "/a/b/c">            // 복사 후 dir 명만 변경
     30     Options Indexes MultiViews FollowSymlinks
     31     AllowOverride None
     32     Require all granted
     33 </Directory>

[root@junga ~]# mkdir -p /a/b/c
[root@junga ~]#
[root@junga ~]# touch /a/b/c/index.html
[root@junga ~]#
[root@junga ~]# vi /a/b/c/index.html
[root@junga ~]#
[root@junga ~]# systemctl restart httpd.service

 

// virtual host 실습

// 준비물 셋팅

[root@junga ~]# ls -l /etc/httpd/conf.d
합계 20
-rw-r--r-- 1 root root  366 10월 20 05:39 README
-rw-r--r-- 1 root root 3077  2월  6 13:44 autoindex.conf
-rw-r--r-- 1 root root  323 10월 20 01:44 manual.conf
-rw-r--r-- 1 root root 1257  2월  6 13:07 userdir.conf
-rw-r--r-- 1 root root  824 10월 20 01:44 welcome.conf
[root@junga ~]#
[root@junga ~]# touch /etc/httpd/conf.d/vhost.conf
[root@junga ~]#
[root@junga ~]# ls -l /etc/httpd/conf.d
합계 20
-rw-r--r-- 1 root root  366 10월 20 05:39 README
-rw-r--r-- 1 root root 3077  2월  6 13:44 autoindex.conf
-rw-r--r-- 1 root root  323 10월 20 01:44 manual.conf
-rw-r--r-- 1 root root 1257  2월  6 13:07 userdir.conf
-rw-r--r-- 1 root root    0  2월  6 13:55 vhost.conf
-rw-r--r-- 1 root root  824 10월 20 01:44 welcome.conf
[root@junga ~]#

[root@junga ~]# vi /var/named/mylife.for.zone
    cafe IN A 192.168.46.90            // 추가

[root@junga ~]#
[root@junga ~]# systemctl restart named.service
[root@junga ~]#
[root@junga ~]# nslookup
> cafe.mylifebravo.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: cafe.mylifebravo.com
Address: 192.168.46.90
> exit

[root@junga ~]#

// 파이어폭스 방문기록 전체 삭제

// 파이어 폭스 2개 켜서

http://www.mylifebravo.com/
http://cafe.mylifebravo.com/

// vhost.conf 설정

# vi /etc/httpd/conf.d/vhost.conf 
      1 <VirtualHost *:80>
      2 </VirtualHost>
      3
      4 <VirtualHost *:80>
      5         ServerAdmin     root@mylifebravo.com
      6         ServerName      cafe.mylifebravo.com
      7         DocumentRoot  /c/a/f/e
      8         ErrorLog           "logs/mlb_error_log"
      9         CustomLog       "logs/mlb_access_log" combined
     10 </VirtualHost>

// 아파치 설정파일 설정

# vi /etc/httpd/conf/httpd.conf

    123 <Directory "/web/server">
    124     AllowOverride None
    125     # Allow open access:
    126     Require all granted
    127 </Directory>
    128
    129 <Directory "/c/a/f">
    130     AllowOverride None
    131     # Allow open access:
    132     Require all granted
    133 </Directory>

[root@junga ~]# systemctl restart httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
[root@junga ~]#

[root@junga ~]# systemctl -l status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 화 2018-02-06 14:24:21 KST; 1min 27s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 6120 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 6119 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 6119 (code=exited, status=1/FAILURE)

 2월 06 14:24:21 junga.kgitbank systemd[1]: Starting The Apache HTTP Server...
 2월 06 14:24:21 junga.kgitbank httpd[6119]: httpd: Syntax error on line 357 of /etc/httpd/conf/httpd.conf: Syntax error on line 10 of /etc/httpd/conf.d/vhost.conf: Expected </VirtualHost> but saw </VirtuaHost>
 2월 06 14:24:21 junga.kgitbank systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
 2월 06 14:24:21 junga.kgitbank kill[6120]: kill: cannot find process ""
 2월 06 14:24:21 junga.kgitbank systemd[1]: httpd.service: control process exited, code=exited status=1
 2월 06 14:24:21 junga.kgitbank systemd[1]: Failed to start The Apache HTTP Server.
 2월 06 14:24:21 junga.kgitbank systemd[1]: Unit httpd.service entered failed state.
 2월 06 14:24:21 junga.kgitbank systemd[1]: httpd.service failed.

[root@junga ~]# vi /etc/httpd/conf.d/vhost.conf

=> 오타 수정

[root@junga ~]# systemctl restart httpd.service

반응형
LIST

'BigData_Off1 > 리눅스2' 카테고리의 다른 글

2018.02.07-20일차 DB  (0) 2018.02.07
2018.02.05-18일차 Web Server  (0) 2018.02.05
DNS 2(slave DNS), Web Server  (0) 2018.02.02
2018.01.30 ~ 02.02-14-17일차 DNS(개념, 실습1-4)  (0) 2018.01.30
Autofs 2(① autofs 2nd, ② 실습1)  (0) 2018.01.29
Posted by 오정oI
, |
반응형
SMALL

* 강사님 강의 노트 :

2월5일_18평일리2.txt

 

* Web Server(Apache)

1> 개념

- apache 웹 서버는 공개형 웹 서버 프로그램으로써 다양한 플랫폼에서 동작할 수 있도록 설계가 되어있음

- apache 웹 서버는 클라이언트가 웹 브라우저를 통해서 요청한 데이터를 클라이언트 웹 브라우저로 보내는 역할

다시 말하면, 웹 서버는 클라이언트의 요청을 기다리고 있다가 요청을 받게 되면 해당 데이터를 보내는 프로그램

 

2> 특징

- standalone (계속 가동중, 요청 기다림)

 

3> 설정파일

/etc/httpd/conf/httpd.conf

-httpd의 설정파일

 

31줄 : 웹 서버 설정파일, 바이너리 파일, 로그 파일, 모듈 파일 등이 저장되어 있는 기본 디렉터리를

지정

41줄 : 지정한 IP Address를 80번 포트로 듣겠음

42줄 : 모든 IP Address를 80번 포트로 듣겠음

ex> 포트를 바꾸는 경우는 보통 서버 리뉴얼을 하는 경우 바꿔서 작업하고 작업 완료시 포트를 원래로 바꿔줌

ex> clubbox에 각 메뉴 탭들을 보면 사용하는 web언어와, 포트가 각 메뉴마다 다른 것을 확인 할 수 있다.

=> 41, 42 둘 중 하나만 써야..,

( 참고로 serverTokens 항목이 centOS 6.x이하에는 있었는데 centOS 6에서는 없어짐

ServerTokens

- 오류 및 서버 메시지를 출력되는 서버에 대한 정보를 설정

CentOS 7 에서는 ServerTokens를 사용하기 위해서 별도로 추가를 해야함

ServerSignature on

값의 종류

Full    → 아파치 서버 버전, 운영체제 정보, 모듈 정보

OS    → 아파치 서버 버전, 운영 체제 정보

Major→ 어퍼차 서버의 주 버전    

Min  → 아파치 서버의 모든 버전

Minor→ 아차피 서버의 하위 버전

Prod → 아파치 서버의 정보 )

 

56줄 : 모듈 관련 파일을 httpd.conf 설정파일에 포함하겠음

(ls -l /etc/httpd/conf.modules.d/*.conf   # /conf.modules.d 하위에 모든 파일목록)

 

66, 67줄 : 실행되는 httpd의 사용자 및 그룹 권한을 설정하는 항목

(보안상 nobody로 사용함)

 

69줄은 서버 설정

86줄: 관리자 e-mail 주소를 적어주는 항목

- 웹 문서 로딩시 에러가 발생 했을 경우 에러 페이지에 보여질 관리자 e-mail 주소를 알려줌

 

94줄 : 클라이언트에게 보여줄 호스트 네임을 지정하는 항목 만약 DNS가 없을 시 IP Address

입력해야함

 

101~104줄 : 최상위 디렉터리에 대한 기본 옵션과 권한을 나타내는 설정

AllowOverride 지시자는 어떻게 접근을 허용할 것인지에 대한 설정

Require all denied는 요구하는 모든 것들을 거부하겠음

denied를 granted로 변경하면 허용하겠다라는 의미

 

118줄 : 관리자의 문서        // index.html 관련

- 서버의 웹 문서가 들어있는 경로를 지정

- 참고로 맨 마지막에 /를 추가하지 않음(dir. 티낼 필요 없음!)

- 심볼릭 링크파일이나 alias로 다른 경로를 가르키도록 설정할 수 있음

다시 말해, 웹 문서가 들어있는 경로

// centOS 6.x 버전대와 달리 centOS 7은 123, 130 라인을 추가해줘야..,

 

123~127줄은 /var/www  디렉터리에 대해서 별도로 기본 옵션과 권한을 나타내는 설정

130 ~156줄은 /var/www/html 디렉터리에 대해서 기본 옵션과 권한을 나타내는 설정

143줄 : Options 지시자는 지정한 디렉터리 하위에 모든 파일과 디렉터리를 적용할

접근 제어를 설정

Indexes는 URL(Uniform Resource Locator : 자원 위치 지정자)을 지정한 디렉터리에

index.html과 같은 지정한 파일이 없을 경우 해당 디렉터리의 파일 목록을 보여줌 

FollowSymLinks는 디렉터리내에서 심볼릭 링크의 사용을 허가함

 

 

 

 

 

 

4> 명령어

web server(apache)

서비스명은 httpd.service

 

 

* Web Browser

1> 개념

- 사용자가 웹 서버에게 필요한 데이터를 요청하도록 해주며 웹 서버가 응답하게 되면 데이터를 컴파일을 통해서

사용자에게 보여주는 역할


2> Web Browser의 종류

Windows → Internet Explorer, Edge

Linux → Firefox

Google → Chrome

Apple → Safari

 

3> 관련 용어

Web Server는 80번 포트를 사용(Well-known)

 

HTTP(Hyper Text Transfer Protocol)

- WWW(World Wide Web) 상에서 정보를 주고받을 수 있는 프로토콜.

주로 html 문서를 주고받는데 쓰임.

- 클라이언트와 서버 사이에 이루어지는 요청(Request)/응답(Response) 프로토콜.

 

Web Document(웹 문서 : HTML 문서)

- 웹 문서는 이미지가 포함된 정적인 형태의 html 문서만을 제공함

 

4> 특징

① 정적 웹 서버의 동작 방식

- 기본적으로 apache 웹 서버는 HTML(HyperText Markup Language)과 같은 정적인 데이터만 처리하게 됨

- 정적이라고 하는 것은 접속 후 데이터를 요청할 때마다 똑같은(변하지 않음) 데이터만 보낸다는 것을 의미

- 호출한 파일을 클라이언트로 가지고 와서 실행함

CSSL(Client Side Script Language) : html, java scripts

- 보안상 취약

- 누구든지 다 볼 수 있음

 

② 동적 웹 서버의 동작 방식

- 동적인 데이터를 처리하기 위해서 웹 스크립트 언어인 C, ASP(Active Server Page), PHP(Personal

Hypertext Preprocessor), JSP(Pava Server Page), Python, Perl 등

 

모듈(Module)은 '전체를 다루는 일부'라고 의미를 둘 수 있음

- 프로그램 내부적으로 하나의 종합된 동작을 하도록 작은 부분을 분할함

더 찾아봥~!

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

SSSL(Server Side Script Language) : asp, php 등등

- 보안상 강함

- 나 혼자 보는 것

 

(참고로 Linux는 웹 서버는 Apache, FTP 서버는 vsftpd 사용함

Windows Server는 IIS(Internet Information Service)를 사용함

IIS가 웹 서버와 FTP Server를 포함하고 있음)

 

ex>

사용자들이 naver 요청하면 모두 같은 웹 브라우저를 보게됨 → 정적

여기서 로그인을 하면 모두 다른 화면이 나옴. 나혼자 보는 것→ 동적

인터넷 키면, 웹서버(Apache), DNS, DB 등 같이 구동중..,

 

 

 

 

// 실습

패키지명은 httpd 설치되어 있는지 유무를 확인

패키지명은 httpd로 시작함

 

[root@junga ~]# rpm -qa | grep httpd
[root@junga ~]#
[root@junga ~]# yum -y install httpd*
httpd-manual-2.4.6-67.el7.centos.6.noarch
httpd-2.4.6-67.el7.centos.6.x86_64
httpd-tools-2.4.6-67.el7.centos.6.x86_64
httpd-devel-2.4.6-67.el7.centos.6.x86_64

// 2018.02.05

[root@junga ~]# rpm -qa | grep httpd
httpd-manual-2.4.6-67.el7.centos.6.noarch
httpd-2.4.6-67.el7.centos.6.x86_64
httpd-tools-2.4.6-67.el7.centos.6.x86_64
httpd-devel-2.4.6-67.el7.centos.6.x86_64
[root@junga ~]#
[root@junga ~]# ls -l /etc/httpd/conf/httpd.conf
-rw-r--r-- 1 root root 11753 10월 20 01:44 /etc/httpd/conf/httpd.conf
[root@junga ~]#
[root@junga ~]# cp /etc/httpd/conf/httpd.conf /backup
[root@junga ~]#
[root@junga ~]# ls -l /backup/
합계 52
-rwxr-xr-x 1 root root  8702  1월 12 13:06 00_header
-rw-r--r-- 1 root root   501  1월 23 13:14 fstab
-rw-r--r-- 1 root root  5078  1월 12 13:06 grub.cfg
-rw-r--r-- 1 root root 11753  2월  5 12:46 httpd.conf
-rw------- 1 root root  3907  1월 17 14:02 sshd_config
-r--r----- 1 root root  3938  1월 17 13:10 sudoers
-rw------- 1 root root  5030  1월 19 14:47 vsftpd.conf
[root@junga ~]#
[root@junga ~]# vi /etc/httpd/conf
conf/           conf.d/         conf.modules.d/
[root@junga ~]# vi /etc/httpd/conf
conf/           conf.d/         conf.modules.d/
[root@junga ~]# vi /etc/httpd/conf/httpd.conf
[root@junga ~]#
[root@junga ~]# systemctl restart httpd.service
[root@junga ~]#
[root@junga ~]# vi /etc/httpd/conf/httpd.conf

42 Listen 50000

:wq

[root@junga ~]#
[root@junga ~]# systemctl restart httpd.service    // 파이어 폭스 킨 후 port 50000번 눌러보기!
[root@junga ~]#
[root@junga ~]# vi /etc/httpd/conf/httpd.conf

     43 ServerTokens OS                    //ServerTokens 관련
     44 ServerSignature on

:wq
[root@junga ~]#
[root@junga ~]# systemctl restart httpd.service // 파이어 폭스 킨 후 192.168.46.90/lskjdflksjdflkjsldkf 한 후 에러보기!
[root@junga ~]#
[root@junga ~]#

[root@junga ~]# ls -l /etc/httpd/conf.modules.d/        // 56줄
합계 28
-rw-r--r-- 1 root root 3739 10월 20 01:44 00-base.conf
-rw-r--r-- 1 root root  139 10월 20 01:44 00-dav.conf
-rw-r--r-- 1 root root   41 10월 20 01:44 00-lua.conf
-rw-r--r-- 1 root root  742 10월 20 01:44 00-mpm.conf
-rw-r--r-- 1 root root  957 10월 20 01:44 00-proxy.conf
-rw-r--r-- 1 root root   88 10월 20 01:44 00-systemd.conf
-rw-r--r-- 1 root root  451 10월 20 01:44 01-cgi.conf

[root@junga ~]# vi /etc/httpd/conf/httpd.conf

94 #ServerName 192.168.46.90:80

:wq

[root@junga ~]# systemctl restart httpd.service
[root@junga ~]# :
[root@junga ~]# touch /var/www/html/index.html
[root@junga ~]#
[root@junga ~]# vi /var/www/html/index.html
    Hello~!
    Nice to meet you.

:wq

// 파이어폭스> 192.168.46.90 입력 후 확인!

 

// 118줄 관련 실습(DocumentRoot)

[root@junga ~]# vi /etc/httpd/conf/httpd.conf

    101 <Directory />
    102     AllowOverride none
    103     Require all denied
    104 </Directory>

    118 DocumentRoot "/web/server/apache"
   

    123 <Directory "/web/server">

    130 <Directory "/web/server/apache">
// centos 6.x 버전대와 달리 123, 130 라인을 추가해줘야..,

 

 

 

<실습 2>

www.mybravo.com/hello 도 내용이 나오게 하기

 

[root@junga ~]# mkdir /web/server/apache/hello
[root@junga ~]#
[root@junga ~]# touch /web/server/apache/hello/index.html
[root@junga ~]#
[root@junga ~]# vi /web/server/apache/hello/index.html
[root@junga ~]#
[root@junga ~]#

// index 목록 보이게 설정
[root@junga ~]# rm -rf /web/server/apache/hello/*
[root@junga ~]#
[root@junga ~]# ls -l /web/server/apache/hello/
합계 0    

 

 

 

 

 

<실습 1>

web 에 문자 쳤을 때 위에서 한 작업처럼(httpd, /var/www/html/ ~ 글 쓴 내용이 나오도록 DNS 설정)

 

ns : mylifebravo.com

host name : www.  ← 별도로 추가

 

 

[root@junga ~]# rpm -qa |grep bind
bind-libs-9.9.4-51.el7_4.2.x86_64
bind-pkcs11-devel-9.9.4-51.el7_4.2.x86_64
keybinder3-0.3.0-1.el7.x86_64
bind-sdb-9.9.4-51.el7_4.2.x86_64
bind-devel-9.9.4-51.el7_4.2.x86_64
bind-pkcs11-libs-9.9.4-51.el7_4.2.x86_64
bind-sdb-chroot-9.9.4-51.el7_4.2.x86_64
bind-pkcs11-9.9.4-51.el7_4.2.x86_64
bind-utils-9.9.4-51.el7_4.2.x86_64
bind-license-9.9.4-51.el7_4.2.noarch
bind-libs-lite-9.9.4-51.el7_4.2.x86_64
bind-lite-devel-9.9.4-51.el7_4.2.x86_64
bind-chroot-9.9.4-51.el7_4.2.x86_64
rpcbind-0.2.0-42.el7.x86_64
bind-dyndb-ldap-11.1-4.el7.x86_64
bind-9.9.4-51.el7_4.2.x86_64
bind-pkcs11-utils-9.9.4-51.el7_4.2.x86_64
[root@junga ~]#
[root@junga ~]# vi /etc/named.conf                // (13, 19 => any;)
[root@junga ~]#
[root@junga ~]# vi /etc/named.rfc1912.zones   // (25~, 49~; 정방향, 역방향 필요 없음!!!)
[root@junga ~]#
[root@junga ~]# vi

      1 $TTL    1W      ;
      2 @       IN      SOA     ns.mylifebravo.com.     root(
      3                         2018020500      ;       serial
      4                         6H              ;       refresh(6 hours)
      5                         30M             ;       retry  (30 minutes)
      6                         1W              ;       expire (1 week)
      7                         1W              ;       minimum(1 week)
      8                         )
      9         IN      NS      ns.mylifebravo.com.
     10         IN      A       192.168.46.90
     11
     12 ns      IN      A       192.168.46.90
     13 www     IN      A       192.168.46.90        // 마지막에 추가후 named.service 재시작

: w /var/named/mylife.for.zone

[root@junga ~]#
[root@junga ~]# ls -l /var/named/mylife.for.zone
-rw-r--r-- 1 root root 249  2월  5 13:48 /var/named/mylife.for.zone
[root@junga ~]# ls -l /var/named/
합계 20
drwxr-x--- 7 root  named   61  2월  5 13:42 chroot
drwxr-x--- 7 root  named   61  2월  5 13:42 chroot_sdb
drwxrwx--- 2 named named    6  1월 22 22:30 data
drwxrwx--- 2 named named    6  1월 22 22:30 dynamic
drwxrwx--- 2 root  named    6  8월 23 22:38 dyndb-ldap
-rw-r--r-- 1 root  root   249  2월  5 13:48 mylife.for.zone
-rw-r----- 1 root  named 2281  5월 22  2017 named.ca
-rw-r----- 1 root  named  152 12월 15  2009 named.empty
-rw-r----- 1 root  named  152  6월 21  2007 named.localhost
-rw-r----- 1 root  named  168 12월 15  2009 named.loopback
drwxrwx--- 2 named named    6  1월 22 22:30 slaves
[root@junga ~]#
[root@junga ~]# cp /var/named/mylife.for.zone /var/named/mylife.rev.zone
[root@junga ~]#
[root@junga ~]# vi /var/named/mylife.rev.zone

      1 $TTL    1W      ;
      2 @       IN      SOA     ns.mylifebravo.com.     root(
      3                         2018020500      ;       serial
      4                         6H              ;       refresh(6 hours)
      5                         30M             ;       retry  (30 minutes)
      6                         1W              ;       expire (1 week)
      7                         1W              ;       minimum(1 week)
      8                         )
      9         IN      NS      ns.mylifebravo.com.
     10         IN      A       192.168.46.90
     11
    
12 90      IN      PTR     ns.mylifebravo.com.

[root@junga ~]#
[root@junga ~]# ls -l /var/named/
합계 24
drwxr-x--- 7 root  named   61  2월  5 13:42 chroot
drwxr-x--- 7 root  named   61  2월  5 13:42 chroot_sdb
drwxrwx--- 2 named named    6  1월 22 22:30 data
drwxrwx--- 2 named named    6  1월 22 22:30 dynamic
drwxrwx--- 2 root  named    6  8월 23 22:38 dyndb-ldap
-rw-r--r-- 1 root  root   249  2월  5 13:48 mylife.for.zone
-rw-r--r-- 1 root  root   257  2월  5 13:49 mylife.rev.zone
-rw-r----- 1 root  named 2281  5월 22  2017 named.ca
-rw-r----- 1 root  named  152 12월 15  2009 named.empty
-rw-r----- 1 root  named  152  6월 21  2007 named.localhost
-rw-r----- 1 root  named  168 12월 15  2009 named.loopback
drwxrwx--- 2 named named    6  1월 22 22:30 slaves
[root@junga ~]#
[root@junga ~]# chmod 660 /var/named/mylife.for.zone
[root@junga ~]# chmod 660 /var/named/mylife.rev.zone
[root@junga ~]#
[root@junga ~]# chown root:named /var/named/m*
[root@junga ~]#
[root@junga ~]# ls -l /var/named/m*
-rw-rw---- 1 root named 249  2월  5 13:48 /var/named/mylife.for.zone
-rw-rw---- 1 root named 257  2월  5 13:49 /var/named/mylife.rev.zone
[root@junga ~]#
[root@junga ~]# named-checkzone mylifebravo.com /var/named/mylife.for.zone
zone mylifebravo.com/IN: loaded serial 2018020500
OK
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
[root@junga ~]#
[root@junga ~]# nslookup
> mylifebravo.com
Server:  168.126.63.1
Address: 168.126.63.1#53

** server can't find mylifebravo.com: NXDOMAIN
> exit

[root@junga ~]#
[root@junga ~]# vi /etc/resolv.conf
      3 nameserver 192.168.46.90

[root@junga ~]#
[root@junga ~]# nslookup
> mylifebravo.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: mylifebravo.com
Address: 192.168.46.90
> exit

[root@junga ~]#
[root@junga ~]# vi /etc/httpd/conf/httpd.conf
[root@junga ~]#
[root@junga ~]# ls -l /var/www/html/
합계 4
-rw-r--r-- 1 root root 26  2월  5 13:31 index.html
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# vi /var/named/mylife.for.zone
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
[root@junga ~]#
[root@junga ~]# vi /etc/resolv.conf
[root@junga ~]#
[root@junga ~]# nslookup
> www.mylifebravo.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: www.mylifebravo.com
Address: 192.168.46.90
> exit

[root@junga ~]#


 

 

 

 

 

 

 


 

DNS 복습~!!!

 

반응형
LIST

'BigData_Off1 > 리눅스2' 카테고리의 다른 글

2018.02.07-20일차 DB  (0) 2018.02.07
2018.02.06-19일차 Web Server2  (0) 2018.02.06
DNS 2(slave DNS), Web Server  (0) 2018.02.02
2018.01.30 ~ 02.02-14-17일차 DNS(개념, 실습1-4)  (0) 2018.01.30
Autofs 2(① autofs 2nd, ② 실습1)  (0) 2018.01.29
Posted by 오정oI
, |
반응형
SMALL

* 강사님 정리 노트 :

2월2일_17평일리2.txt

* slave(보조) DNS 설정

[서버]

master DNS(1차 네임서버)
/etc/named.rfc1912.zones

forward zone 설정 중
allow-update { none; }; 에서
none을 any로 변경한 뒤
allow-transfer { any; }; 을 추가
저장 하고 종료한 뒤 named.service를 재시작

firewall-cmd 설정
dns를 등록

 

[클라이언트]

slave DNS(2차 네임서버)

bind로 시작하는 패키지를 설치

/etc/named.conf 파일에서 master DNS(1차 네임서버)에서 했던 작업

처럼 작업(13, 19 and;)

 

/etc/named.rfc1912.zones

forward zone(정방향 영역)에서

zone "" 안에 master DNS의 domain_name을 입력

type은 slave로 입력

file은 ""안에 slaves/slave.junga.for.zone 식으로 이름을 입력

이 때 slaves는 디렉터리명임(ls -l /var/named)

masters {} master DNS의 IP Address를 입력

 

masterfile-format text;

→ 문자가 깨지는 것을 방지하기 위함

}; 을 닫기

위 작업을 할 때 ;을 넣을 곳에 반드시 잘 넣어주여야 함

// 역방향 설정한 거 지우기

// 정방향, 역방향 정의 파일 다 필요 없음!!

 

위 작업이 다 되었으면

named.service를 재시작

 

// 끝나면 snapshot 돌려주기

// 서버만 가동!

 

[server]

// 외부설정 파일에 다음 라인 추가

[root@junga named]# vi /etc/named.rfc1912.zones

     25 zone "junga.com" IN {
     26         type master;
     27         file "junga.for.zone";
     28         allow-update { none; };
     29         allow-transfer{ any; };
     30 };

// 시스템 재시작

[root@junga named]# systemctl restart named.service

 

// 방화벽 추가

[root@junga named]# firewall-cmd --add-service=dns
success
[root@junga named]#
[root@junga named]# firewall-cmd --list-services
ssh dhcpv6-client dns

 

[client]

# yum -y install bind*            // 스냅샷 돌리고 나서, bind* 관련 패키지 설치

# vi /etc/named.conf

  13         listen-on port 53 { any; };
  19         allow-query     { any; };

# vi /etc/named.rfc1912.zones

// 정방향

     25 zone "junga.com" IN {
     26         type slave;
     27         file "slaves/slave.junga.for.zone";
     28         masters { 192.168.46.90; };
     29         masterfile-format text;        # 문자 깨지는거 방지
     30 };

# systemctl restart named.service
[root@localhost ~]# ls -l /var/named/slaves/
합계 4
-rw-r--r-- 1 named named 462  2월  2 14:38 slave.junga.for.zone
[root@localhost ~]#

[root@localhost ~]# ls -l /var/named/slaves/
합계 4
-rw-r--r-- 1 named named 462  2월  2 14:38 slave.junga.for.zone
[root@localhost ~]#
[root@localhost ~]# cat /var/named/slaves/slave.junga.for.zone
Zs�\S :�
                   jungacom2nsjungacomrootjungacomxH�T`   :� :�1 :�
                                                                                   jungacom��.Z��.[��.\/ :�
                           jungacomnsjungacom* :�blogjungacom��.Z* :�cafejungacom��.Z* :�mailjungacom��.Z( :�nsjungacom��.Z4 :�seojungacomwwwjungacom) :�wwwjungacom��.Z[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# vi /etc/named.rfc1912.zones
[root@localhost ~]#
[root@localhost ~]# systemctl restart named.service
[root@localhost ~]#
[root@localhost ~]# cat /var/named/slaves/slave.junga.for.zone
$ORIGIN .
$TTL 604800 ; 1 week
junga.com  IN SOA ns.junga.com. root.junga.com. (
    2018020100 ; serial
    21600      ; refresh (6 hours)
    1800       ; retry (30 minutes)
    604800     ; expire (1 week)
    604800     ; minimum (1 week)
    )
   NS ns.junga.com.
   A 192.168.46.90
   A 192.168.46.91
   A 192.168.46.92
$ORIGIN junga.com.
blog   A 192.168.46.90
cafe   A 192.168.46.90
mail   A 192.168.46.90
ns   A 192.168.46.90
seo   CNAME www
www   A 192.168.46.90
[root@localhost ~]#

====================================================

* Web Server(Apache)

1> 개념

- apache 웹 서버는 공개형 웹 서버 프로그램으로써 다양한 플랫폼에서 동작할 수 있도록 설계가 되어있음

- apache 웹 서버는 클라이언트가 웹 브라우저를 통해서 요청한 데이터를 클라이언트 웹 브라우저로 보내는 역할

다시 말하면, 웹 서버는 클라이언트의 요청을 기다리고 있다가 요청을 받게 되면 해당 데이터를 보내는 프로그램

 

2> 특징

- standalone (계속 가동중, 요청 기다림)

 

 

* Web Browser

1> 개념

- 사용자가 웹 서버에게 필요한 데이터를 요청하도록 해주며 웹 서버가 응답하게 되면 데이터를 컴파일을 통해서

사용자에게 보여주는 역할


2> Web Browser의 종류

Windows → Internet Explorer, Edge

Linux → Firefox

Google → Chrome

Apple → Safari

 

3> 관련 용어

Web Server는 80번 포트를 사용(Well-known)

 

HTTP(Hyper Text Transfer Protocol)

- WWW(World Wide Web) 상에서 정보를 주고받을 수 있는 프로토콜.

주로 html 문서를 주고받는데 쓰임.

- 클라이언트와 서버 사이에 이루어지는 요청(Request)/응답(Response) 프로토콜.

 

Web Document(웹 문서 : HTML 문서)

- 웹 문서는 이미지가 포함된 정적인 형태의 html 문서만을 제공함

 

4> 특징

① 정적 웹 서버의 동작 방식

- 기본적으로 apache 웹 서버는 HTML(HyperText Markup Language)과 같은 정적인 데이터만 처리하게 됨

- 정적이라고 하는 것은 접속 후 데이터를 요청할 때마다 똑같은(변하지 않음) 데이터만 보낸다는 것을 의미

- 호출한 파일을 클라이언트로 가지고 와서 실행함

CSSL(Client Side Script Language) : html, java scripts

- 보안상 취약

- 누구든지 다 볼 수 있음

 

② 동적 웹 서버의 동작 방식

- 동적인 데이터를 처리하기 위해서 웹 스크립트 언어인 C, ASP(Active Server Page), PHP(Personal

Hypertext Preprocessor), JSP(Pava Server Page), Python, Perl 등

 

모듈(Module)은 '전체를 다루는 일부'라고 의미를 둘 수 있음

- 프로그램 내부적으로 하나의 종합된 동작을 하도록 작은 부분을 분할함

더 찾아봥~!

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

 

- 호출한 파일을 서버에서 실행시켜서 실행 결과 값을 가져옴

SSSL(Server Side Script Language) : asp, php 등등

- 보안상 강함

- 나 혼자 보는 것

 

(참고로 Linux는 웹 서버는 Apache, FTP 서버는 vsftpd 사용함

Windows Server는 IIS(Internet Information Service)를 사용함

IIS가 웹 서버와 FTP Server를 포함하고 있음)

 

ex>

사용자들이 naver 요청하면 모두 같은 웹 브라우저를 보게됨 → 정적

여기서 로그인을 하면 모두 다른 화면이 나옴. 나혼자 보는 것→ 동적

인터넷 키면, 웹서버(Apache), DNS, DB 등 같이 구동중..,

 

5> 실습

패키지명은 httpd 설치되어 있는지 유무를 확인

패키지명은 httpd로 시작함

 

[root@junga ~]# rpm -qa | grep httpd
[root@junga ~]#
[root@junga ~]# yum -y install httpd*
httpd-manual-2.4.6-67.el7.centos.6.noarch
httpd-2.4.6-67.el7.centos.6.x86_64
httpd-tools-2.4.6-67.el7.centos.6.x86_64
httpd-devel-2.4.6-67.el7.centos.6.x86_64

DNS 복습~!!!

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 폰트 : dejavu sans mono bold

* 강사님 정리 노트3:

2월1일_16평일리2.txt

* 강사님 정리 노트2:

1월31일_15평일리2.txt

* 강사님 정리 노트 :

1월30일_14평일리2.txt

* dns 관련 실습 정리 :

2018.02.01_실습1 정리.txt

 

 

* DNS(Domain Name System)

1> 개념

 

Network ID는 네트워크 고유 식별자(네트워크 구간을 의미)

Host ID는 호스트 고유 식별자(호스트 구간을 의미)

Host Name은 현재 경로(위치)

Domain Name은 컴퓨터가 기억하기 쉽게 숫자형태(IP Address)로 이루어진 도메인 네임을 사람이 기억하기

쉽게 문자형태로 바꾸어 사용하는 것

DNS는 사람이 기억하기 쉽게 문자 형태로 이루어진 도메인 네임을 컴퓨터가 기억하기 쉽게 숫자 형태(IP Address)

로 바꾸어주는 service.

 

- 도메인 네임은 영문자(a부터 z까지), 숫자(0부터 9까지), 특수문자(-)를 포함해서 37개의 문자들로 구성

대문자와 소문자의 구분이 없음

특수문자는 맨 처음과 맨 마지막에는 사용할 수 없음

IP Address처럼 인터넷상에서 중복된 이름은 사용할 수 없음

 

- 도메인 네임은 .(dot)으로 구분된 레이블로 구조화된 이름을 표시

즉! 루트 도메인에서부터 호스트에 이르는 경로상의 각 계층을 모두 표시함으로써 도메인 네임 공간상에서

의 그 위치를 표시

ex) www.kgitbank.co.kr.

                 ↑ 루트 도메인

 

- FQDN(Fully Qualified Domain Name)은 호스트 네임과 도메인 네임을 포함한 전체 도메인 이름을 일컫는 용어

 

- 분산된 구조의 도메인 데이터베이스가 만들어지는데 이의 효율적인 DB구성과 관리를 위해 위임(delegation)

적용

cf. 윈도우서버 : 상속(갖고 올 수 없음) ≠ 위임(다시 갖고 올 수 있음)

- 루트 도메인은 최상위 도메인에게 해당 도메인 관리를 위임하며 최상위 도메인은 다시 2차 도메인을 생성

하여 그 관리를 위임하게 됨

이러한 위임에 있어서 중요한 것은 zone(영역) 개념

 

- 영역이란 상위레벨 도메인으로부터 위임받은 도메인을 기준으로 하위 노드를 생성, 관리하고 다시 서브

도메인을 생성 위임 및 관리할 수 있는 zone(영역)을 의미

 

- 각 도메인 관리자는 해당 도메인의 하위 영역을 독자적으로 관리하는 권한까지 갖게 됨

위임은 새로운 도메인 네임의 생성, 유지, 삭제 등의 일정한 영역의 도메인에 대한 관리권한까지

위임한다는 것을 의미

 

도메인 네임 공간

- 인터넷 공간에서 사용되는 도메인 네임의 계층적 구조 공간을 의미(Tree 구조)

(참고로 도메인 네임 분배/할당 기관은 예전엔 IANA(Internet Assigned Numbers Authority)를 통해서 체계적

으로 관리.

현재는 ICANN(Internet coporation for Assigned Name and Numbers) 기관에서 인터넷 도메인 네임과 주소를

지정하고 있음)

 

도메인 네임 구조

. (root domain) 은 최상위 DNS로써, 전 세계적으로 오직 13대의 대형서버로 미국 10대, 네덜란드 1대, 노르웨이 1대,

일본 1대 각각 1대씩의 대형 서버로 구축되어 있음

우리나라의 경우 일본의 M-ROOT DNS를 사용해 왔음

ROOT DNS 미러 서버의 국내 운영 공식 개통 됨

미러(Mirror) 서버란, 글로벌 오리지널 루트 서버를 복사한 것으로써 거의 같은 기능

전 세계에 67개의 미러 서버가 있고 미국이 24개, 한국&영국&네덜란드&중국이 3대씩 보유하고 있음

미러 서버가 생긴 이유는 ROOT 서버에 DDos(분산 서비스 거부) 공격이 있었고 ROOT DNS 13대 중 9대의

대형 서버가 영향을 받게 되었음

KRNIC(한국인터넷진흥원), KT, KINX(한국인터넷연동센터)에서 각각 운영

얘 없으면 인터넷 못함 ㅋㅋㅋ

 

 

<Top Level Domain>
gTLD(Generic Top Level Domain)
ex) .com(영리기관), .org(비영리기관), .gov(정부기관), .net(네트워크), .edu(교육기관),
         개인이익   사회이익
    .mil(군사기관), ... 등

ccTLD(Country Code Top Level Domain)
ex) .kr, .jp, .us, .cn, .uk

특수도메인
ex) .arpa

 

* 수퍼DNS

우리나라 : kns.konet.net (168.126.63.1)

google => 8.8.8.8

 

2> 네임서버의 유형

 

첫번째, Primary(주) Name Server(Master DNS) ← 우리가 구축할거(모든 정보 다 갖고 있음?)

- 1차 네임서버(주 네임서버)라하며 zone(영역)에 모든 데이터를 가지고 있기 때문에 zone에 대한 모든 권

한을 가지고 있는 중요한 서버

부연설명 : 도메인 네임 서버 사용시에 반드시 구축 해야함

 

두번째, Secondary(보조) Name Server(Slave DNS)

- 2차 네임서버(보조 네임서버)라 하며 1차 네임서버가 다운 되었을 때 그 정보를 대신해서 사용하는 용도

부연설명: 1차 네임서버의 백업을 담당하며 반드시 구축할 필요는 없음

 

세번째, Caching Name Server

- 도메인에 대한 직접적인 레코드 관리를 하지 않음

- 요청시에 전체 네임 구조를 파악해서 stub resolver에게 서비스를 하게 됨

(stub resolver는 호스트 내의 응용 프로그램으로부터 도메인 네임 질의 요청이 있는 경우 시스템에 지정된

resolver 역할의 네임 서버로 DNS 질의를 요청)

부연설명 : 서버에 기록된 정보가 요청이 올 경우 응답해주는 서버

한 번 요청한 정보를 서버에 기록해두었다가 똑같은(동일한)요청이 오면 직접 조회하지 않고 바로 응답해

주는 서버

요즘엔 내장되어 있어서 구축 (x)

 

3> DNS 서비스 관련 파일

1) /etc/host.conf

- 우선순위를 지정하는 파일

 

설정

order host, bind

→ order 설정의 의미는 도메인에 대해 질의할 떄, hosts 파일을 먼저 참고하고 답을 찾지 못하면

bind 즉 DNS에 질의하라는 의미

 

multi on

→ /etc/hosts 파일에 하나의 호스트에 대해 여러 개의 IP Address를 설정 가능한 옵션

 

2) /etc/hosts

- 호스트와 네임과 IP Address의 관계를 설정

장점으로는 설정이 간단함

단점으로는 로컬 시스템에서만 유효하고 지속적인 관리와 보안이 취약함

 

설정

IP Address    FQDN    Alias

 

(참고로 Windows OS에서도 존재함 경로는 C:\Windows\system32\drivers\etc\hosts)

# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com                # x client host

 

3) /etc/resolv.conf (나가서 찾는당)

- 호스트가 사용할 DNS 서버 주소를 설정하는 파일

- 만약에 자기 자신이 DNS 서버라면 자신의 IP Address를 입력함

- nameserver 항목에 지정된 IP Address로 질의하게 됨

---------------------------------

4) /etc/named.conf    (bind 패키지 설치 후 보임!)

- named(daemon)의 환경설정파일

 

도메인별 zone 파일을 지정하는 역할

파일의 구성은 구문과 주석문(동작과 읽지 못하는 부분) 으로 구성이 되어 있으며

구문은 DNS서버 구동시 반드시 중요하므로 수정하거나 주석처리 또는 삭제 등 작업하지 않음

 

13줄 : 네임서버의 포트 번호(53)와 접근할 수 있는 IP Address를 설정하는 항목

외부를 포함하여 any로 설정

cf. 127.0.0.1 : roopback

15줄 : zone 파일이 기본적으로 저장되어있는 기본 디렉터리 (/var/named)

16줄 : 정보가 갱신 될 때 dump 파일로 저장할 파일을 지정

17줄 : 네임서버의 통계자료 파일을 지정

18줄 : 네임서버의 메모리의 통계자료 파일을 지정

19줄 : 네임 서버는 하나의 네임서버만 있는 것이 아니므로 하나의 DNS 서버에는 여러 개의

네임서버를 가져올 수 있음.

이를 허용할 IP Address나(host) 네트워크 대역대를 지정

외부를 포함하는 의미로 any로 설정

31줄 : 외부에서 현재의 네임서버를 지정해서 사용할 수 있게 하는지 유무를 설정함

no로 설정하면 외부에서 현재의 네임서버 질의시 그 결과값을 받을 수 없음

(참고로 DDoS 공격에 대비하여 운영할 때는 no로 설정)

45~50줄 : 디버그 관련 로그 설정
52~55줄 : root domain 설정
type hint에서 hint는 root domain을 의미
54줄 : named.ca 파일은 root domain의 정의 파일
cf) named.ca는 ls -l /var/named/ 하위에 존재함

57줄 : /etc/named.rfc1912.zones 파일을 포함하겠다라는 의미
58줄 : /etc/named.root.key 파일을 포함하겠다라는 의미

 

5) /etc/named.rfc1912.zones  (bind 패키지 설치 후 보임!) 논평 연구서?

- /etc/named.conf 파일의 확장개념으로써 외부 설정을 포함하고자 할 때 사용

forward zone(정방향 영역)과
reverse zone(역방향 영역)

forward zone은 도메인을 IP Address로 바꿈
reverse zone은 IP Address를 도메인으로 바꿈

 

① forward zone(정방향 영역) => 13~23줄/ 25~29줄(내가 추가)
19줄 : ""안에 domain name을 입력
20줄 : master는 1차 네임서버의 타입
21줄 : ""안에 forward zone 정의 파일의 이름을 입력(미리 선언)
cf) slave는 2차 네임서버의 타입
hint는 root domain

22줄 : allow-update { none; };
는 동기화 할 slave(보조 네임서버) 서버의 IP를 지정 또는 any를
입력
만약에 slave 서버가 없으면 그대로 두면 됨
ex) 보조 네임서버 사용할 시 any or IP 입력
23줄 : 19줄에 {를 열었으니까 }; 를 닫음

slave 서버를 구축 했을 시 아래와 같이 항목을 추가함
allow-transfer{ none; };
slave 서버와 관련된 작업으로 도메인 정보를 일일이 수정하지
않고 자동으로 적용되게끔 할 수 있음

 

② reverse zone(역방향 영역)=> 37~47 / 48~53(내가 작업함)
42줄: "x.in-addr.arpa"의 x에 network-ID를 입력하는데
거꾸로 해야함
43줄 : master는 1차 네임서버의 타입
44줄 : ""안에 reverse zone 정의 파일의 이름을 입력(미리 선언)
45줄 : allow-update { none; };
는 동기화 할 slave(보조 네임서버) 서버의 IP를 지정 또는 any를
입력
만약에 slave 서버가 없으면 그대로 두면 됨
ex) 보조 네임서버 사용할 시 any or IP 입력
slave 서버를 구축 했을 시 아래와 같이 항목을 추가함
allow-transfer{ none; };
46줄 : 19줄에 {를 열었으니까 }; 를 닫음

 

네임서버(nameserver)
- 도메인의 정보를 소유하고 클라이언트에게 질의의 대한 응답 수행
- DNS server라고도 함. 자신이 소유한 도메인 zone에 대한 응답

리소스 레코드(resource record)
- 하나의 도메인 네임이 갖는 속성 정보를 지정하는 수단

리소스 레코드의 종류
SOA(Start Of Authority) : 권한(인증)의 시작
NS(NameServer) : 네임 서버를 지정
A(Address) : 특정 서버와 도메인에 IP Address를 지정
MX(Mail eXchanger) : 메일 서버 설정할 때
CNAME(Canonical Name) : 별칭
PTR(PoinTeR) : reverse zone(역방향 영역)에서 사용하는 레코드. IP Address를 도메인으로 mapping(변환)

 

6) forward zone 정의

1줄: $TTL    숫자(초) 또는 문자

- bind에서 무조건 맨 첫 줄에 작성

다른 서버에서 자신이 설정한 정보를 가져갔을 때 그 가져간 서버의 cache에 정보가 얼마나 오랫동안

머무르게 할 것인지를 지정

 

2줄: @       IN      SOA     FQDN         root{

 

@는 origin. 실제 도메인을 뜻함 domain name을 의미 (== testdns.com)

IN은 클래스를 의미

Internet 이거나(클래스) 오른쪽에다가 들여쓰기(Indentation?, input?)

SOA는 권한의 시작

FQDN(1차 네임서버)

root는 관리자의 E-mail 주소

또는 root.testdns.com. 입력

 

3줄 : serial.

serialak은 일렬번호

기본형식은 YYYYMMDDNNd f으로 입력 또는 NM만 입력

- 도메인 데이터베이스가 갱신 되어지면 숫자가 더 크도록 직접

수정을 해 주어야 함

 

4줄 : refresh.

refresh는 새로 고침 숫자(초) 또는 문자로 입력

-2차 네임서버가 자신의 정보를 업데이트 하기 위해서

1차 네임 서버에 얼마나 자주 체크를 할 것인가를 결정

 

5줄 : retry.

retry는 다시 시도

숫자(초) 또는 문자로 입력

- 혹시라도 2차 네임서버가 1차 네임서버에 접속을 실패하게 되면

다시 시도할 시간을 설정

 

6줄 : expire.

expire 는 만료일

숫자(초) 또는 문자로 입력

 

7줄 : minimum.

minimum은 데이터의 저장 한도를 나타내는 설정

맨 첫줄과 동일하게 값을 줌

 

8줄 : 2줄에 (를 열었으므로 )를 닫아줌

9줄 : IN     NS     FQDN(1차 네임서버)

-nameserver로 사용할 1차 네임 서버를 지정

 

10줄 : IN A     IP Address

-사용할 네임서버에 IP Address를 지정(부여)


여기까지는 NS의 정보(Name Server)

-----------------------------------------------

지금부터는 host의 정보

hostname IN    A    IP Address

 

7) reverse zone 정의

reverse zone 정의할 때 forward zone 정의에서 NS의 정보는 동일 함

단! host의 정보는 다르게 작업해야 함

 

NS의 정보

-----------------------------------------------

지금부터는 host의 정보

host-ID IN PTR FQDN(1차 네임서버)

 

위 작업이 다 되었으면 forward zone 정의파일과 reverse zone 정의파일의

허가권과 소유권을 변경해야 함

허가권은 660으로 소유권은 root:named로...

 

허가권과 소유권이 모두 변경되었는지 확인 후

 

forward zone 파일 점검(체크)방법

사용형식

named-checkzone domain_name forward_zone_path

named.service를 재시작

8) nslookup(nameserver lookup)

- 도메인 네임과 IP Address를 확인하기 위해서 특정 네임서버에게 질의할 수 있는 기능을 가진 툴(도구)

사용형식

nslookup domain_name

또는

nslookup 입력 후 enter

domain_name

 

nslookup FQDN

또는

nslookup 입력 후 enter

FQDN

 

 

4> DNS 서비스 구축

 

bind 패키지 설치 유무를 확인 패키지명은 bind(berkly internet ~)로 시작함

 

 

 

 

// dns 관련 파일

[root@junga ~]# ls -l /etc/host.conf
-rw-r--r--. 1 root root 9  6월  7  2013 /etc/host.conf
[root@junga ~]#
[root@junga ~]# cat /etc/host.conf
multi on
[root@junga ~]# ls -l /etc/hosts
-rw-r--r--. 1 root root 158  6월  7  2013 /etc/hosts
[root@junga ~]#
[root@junga ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@junga ~]# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 94  1월 30 13:00 /etc/resolv.conf
[root@junga ~]#
[root@junga ~]# cat /etc/resolv.conf
# Generated by NetworkManager
search kgitbank
nameserver 168.126.63.1
nameserver 168.126.63.2

// => 내꺼 ip 보게 하려면,

① 맨 처음에 기입하거나

② 두 줄 주석 처리하거나

③ 랜선 뽑아서 밖으로 못나가게 하고 내꺼에 오게 하기

④ search abcd.co.kr

[root@junga ~]# hostname
junga.kgitbank
[root@junga ~]#

[root@junga ~]# ls -l /etc/named.conf
ls: cannot access /etc/named.conf: 그런 파일이나 디렉터리가 없습니다
[root@junga ~]#
[root@junga ~]# ls -l /etc/named.rfc1912.zones
ls: cannot access /etc/named.rfc1912.zones: 그런 파일이나 디렉터리가 없습니다
[root@junga ~]#

 

// dns 관련 패키지 설치(bind)

# rpm -qa | grep bind
keybinder3-0.3.0-1.el7.x86_64
bind-license-9.9.4-51.el7.noarch
bind-libs-9.9.4-51.el7.x86_64
bind-utils-9.9.4-51.el7.x86_64
rpcbind-0.2.0-42.el7.x86_64
bind-libs-lite-9.9.4-51.el7.x86_64
[root@junga ~]#
[root@junga ~]# yum install bind*

 

[root@junga ~]# ls -l /etc/named.rfc1912.zones
-rw-r----- 1 root named 931  6월 21  2007 /etc/named.rfc1912.zones
[root@junga ~]#

 

[root@junga ~]# vi /etc/named.conf

===========

// 2018.01.31 실습

# vi /etc/named.rfc1912.zones
// 다음 내용 추가
// 정방향
     25 zone "testdns.com" IN {
     26         type master;
     27         file "testdns.for.zone";
     28         allow-update { none; };
     29 };


// 역방향    
     49 zone "46.168.192.in-addr.arpa" IN {
     50         type master;
     51         file "testdns.rev.zone";
     52         allow-update { none; };
     53 };

// 6) forward zone 정의

# vi /test/abcd        // 빈 파일 열기

      1 $TTL    604800 ;        1 week
      2 @       IN      SOA     ns.testdns.com.         root(
      3                 2018013100      ; seriali
      4                 21600           ; refresh (6 hours)
      5                 1800            ; retry (30 minutes)
      6                 604800          ; expire(1 week)
      7                 604800          ; minimum(1 week)
      8                 )
      9         IN      NS      ns.testdns.com
     10         IN      A       192.168.46.90
     11
     12 ns      IN      A       192.168.46.90

:w /var/named/testdns.for.zone

// 7) reverse zone 정의

[root@junga ~]# cp /var/named/testdns.for.zone /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone

      1 $TTL    604800 ;        1 week
      2 @       IN      SOA     ns.testdns.com.         root(
      3                 2018013100      ; serㅑiali 
      4                 21600           ; refresh (6 hours)
      5                 1800            ; retry (30 minutes)
      6                 604800          ; expire(1 week)
      7                 604800          ; minimum(1 week)
      8                 )
      9         IN      NS      ns.testdns.com
     10         IN      A       192.168.46.90
     11
     12 ns      IN      A       192.168.46.90        // 지우고

  => 12 90      IN    PTR      ns.testdns.com.

wq:

// 해당 정의 파일들 허가권, 소유권 변경

[root@junga ~]# chmod 660 /var/named/testdns.for.zone
[root@junga ~]# chmod 660 /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# chown root:named /var/named/t*
[root@junga ~]#
[root@junga ~]# ls -l /var/named/t*
-rw-rw---- 1 root named 259  1월 31 14:22 /var/named/testdns.for.zone
-rw-rw---- 1 root named 259  1월 31 14:36 /var/named/testdns.rev.zone

// named.service 체크 및 재 시작

[root@junga ~]# systemctl restart named.service
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
[root@junga ~]#
[root@junga ~]# systemctl is-active named.service
failed
[root@junga ~]#
[root@junga ~]# systemctl is-enabled named.service
disabled
[root@junga ~]#
[root@junga ~]# systemctl -l status named.service
● named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 수 2018-01-31 14:43:21 KST; 35s ago
  Process: 5211 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=1/FAILURE)

 1월 31 14:43:21 junga.kgitbank bash[5211]: dns_master_load: testdns.rev.zone:8: isc_lex_gettoken() failed: unbalanced parentheses
 1월 31 14:43:21 junga.kgitbank bash[5211]: dns_master_load: testdns.rev.zone:8: unbalanced parentheses
 1월 31 14:43:21 junga.kgitbank bash[5211]: testdns.rev.zone:12: unknown RR type 'ns.testdns.com.'

 1월 31 14:43:21 junga.kgitbank bash[5211]: zone 46.168.192.in-addr.arpa/IN: loading from master file testdns.rev.zone failed: unexpected end of input
 1월 31 14:43:21 junga.kgitbank bash[5211]: zone 46.168.192.in-addr.arpa/IN: not loaded due to errors.
 1월 31 14:43:21 junga.kgitbank bash[5211]: _default/46.168.192.in-addr.arpa/IN: unexpected end of input
 1월 31 14:43:21 junga.kgitbank systemd[1]: named.service: control process exited, code=exited status=1
 1월 31 14:43:21 junga.kgitbank systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
 1월 31 14:43:21 junga.kgitbank systemd[1]: Unit named.service entered failed state.
 1월 31 14:43:21 junga.kgitbank systemd[1]: named.service failed.
[root@junga ~]#
[root@junga ~]# named-check
named-checkconf  named-checkzone 
[root@junga ~]# named-checkzone testdns.com /var/named/testdns.for.zone
dns_rdata_fromtext: /var/named/testdns.for.zone:2: near eol: unexpected end of input
dns_master_load: /var/named/testdns.for.zone:4: unexpected end of line
dns_master_load: /var/named/testdns.for.zone:3: unexpected end of input
dns_master_load: /var/named/testdns.for.zone:6: unexpected end of line
dns_master_load: /var/named/testdns.for.zone:5: unexpected end of input
dns_master_load: /var/named/testdns.for.zone:8: unexpected end of line
dns_master_load: /var/named/testdns.for.zone:7: unexpected end of input
dns_master_load: /var/named/testdns.for.zone:8: isc_lex_gettoken() failed: unbalanced parentheses
dns_master_load: /var/named/testdns.for.zone:8: unbalanced parentheses
zone testdns.com/IN: loading from master file /var/named/testdns.for.zone failed: unexpected end of input
zone testdns.com/IN: not loaded due to errors.
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.for.zone
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# systemctl -l status named.service
● named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 수 2018-01-31 14:47:31 KST; 18s ago
  Process: 5465 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=1/FAILURE)

 1월 31 14:47:31 junga.kgitbank bash[5465]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
 1월 31 14:47:31 junga.kgitbank bash[5465]: zone 0.in-addr.arpa/IN: loaded serial 0
 1월 31 14:47:31 junga.kgitbank bash[5465]: testdns.rev.zone:12: unknown RR type 'ns.testdns.com.'
 1월 31 14:47:31 junga.kgitbank bash[5465]: zone 46.168.192.in-addr.arpa/IN: loading from master file testdns.rev.zone failed: unknown class/type
 1월 31 14:47:31 junga.kgitbank bash[5465]: zone 46.168.192.in-addr.arpa/IN: not loaded due to errors.
 1월 31 14:47:31 junga.kgitbank bash[5465]: _default/46.168.192.in-addr.arpa/IN: unknown class/type
 1월 31 14:47:31 junga.kgitbank systemd[1]: named.service: control process exited, code=exited status=1
 1월 31 14:47:31 junga.kgitbank systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
 1월 31 14:47:31 junga.kgitbank systemd[1]: Unit named.service entered failed state.
 1월 31 14:47:31 junga.kgitbank systemd[1]: named.service failed.
[root@junga ~]#
[root@junga ~]# ifconfig | head -2
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.46.90  netmask 255.255.255.0  broadcast 192.168.46.255
[root@junga ~]#
\[root@junga ~]#
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
[root@junga ~]#
[root@junga ~]# systemctl is-active named.service
failed
[root@junga ~]#
[root@junga ~]# systemctl -l status named.service
● named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 수 2018-01-31 14:51:12 KST; 26s ago
  Process: 5696 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=1/FAILURE)

 1월 31 14:51:12 junga.kgitbank bash[5696]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
 1월 31 14:51:12 junga.kgitbank bash[5696]: zone 0.in-addr.arpa/IN: loaded serial 0
 1월 31 14:51:12 junga.kgitbank bash[5696]: testdns.rev.zone:12: unknown RR type 'ns.testdns.com.'
 1월 31 14:51:12 junga.kgitbank bash[5696]: zone 46.168.192.in-addr.arpa/IN: loading from master file testdns.rev.zone failed: unknown class/type
 1월 31 14:51:12 junga.kgitbank bash[5696]: zone 46.168.192.in-addr.arpa/IN: not loaded due to errors.
 1월 31 14:51:12 junga.kgitbank bash[5696]: _default/46.168.192.in-addr.arpa/IN: unknown class/type
 1월 31 14:51:12 junga.kgitbank systemd[1]: named.service: control process exited, code=exited status=1
 1월 31 14:51:12 junga.kgitbank systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
 1월 31 14:51:12 junga.kgitbank systemd[1]: Unit named.service entered failed state.
 1월 31 14:51:12 junga.kgitbank systemd[1]: named.service failed.
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.for.zone
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
Job for named.service failed because the control process exited with error code. See "systemctl status named.service" and "journalctl -xe" for details.
[root@junga ~]#
[root@junga ~]# systemctl -l status named.service
● named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 수 2018-01-31 14:54:51 KST; 9s ago
  Process: 5933 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=1/FAILURE)

 1월 31 14:54:51 junga.kgitbank bash[5933]: zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
 1월 31 14:54:51 junga.kgitbank bash[5933]: zone 0.in-addr.arpa/IN: loaded serial 0
 1월 31 14:54:51 junga.kgitbank bash[5933]: testdns.rev.zone:12: unknown RR type 'ns.testdns.com.'
 1월 31 14:54:51 junga.kgitbank bash[5933]: zone 46.168.192.in-addr.arpa/IN: loading from master file testdns.rev.zone failed: unknown class/type
 1월 31 14:54:51 junga.kgitbank bash[5933]: zone 46.168.192.in-addr.arpa/IN: not loaded due to errors.
 1월 31 14:54:51 junga.kgitbank bash[5933]: _default/46.168.192.in-addr.arpa/IN: unknown class/type
 1월 31 14:54:51 junga.kgitbank systemd[1]: named.service: control process exited, code=exited status=1
 1월 31 14:54:51 junga.kgitbank systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
 1월 31 14:54:51 junga.kgitbank systemd[1]: Unit named.service entered failed state.
 1월 31 14:54:51 junga.kgitbank systemd[1]: named.service failed.
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# vi /var/named/testdns.rev.zone
[root@junga ~]#
[root@junga ~]# systemctl restart named.service
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# systemctl is-active named.service
active
[root@junga ~]#
[root@junga ~]# systemctl -l status named.service
● named.service - Berkeley Internet Name Domain (DNS)
   Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled)
   Active: active (running) since 수 2018-01-31 15:00:12 KST; 42s ago
  Process: 6159 ExecStart=/usr/sbin/named -u named -c ${NAMEDCONF} $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 6156 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=0/SUCCESS)
 Main PID: 6162 (named)
   CGroup: /system.slice/named.service
           └─6162 /usr/sbin/named -u named -c /etc/named.conf

 1월 31 15:00:12 junga.kgitbank named[6162]: zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
 1월 31 15:00:12 junga.kgitbank named[6162]: all zones loaded
 1월 31 15:00:12 junga.kgitbank named[6162]: running
 1월 31 15:00:12 junga.kgitbank systemd[1]: Started Berkeley Internet Name Domain (DNS).
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './DNSKEY/IN': 2001:500:a8::e#53
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './NS/IN': 2001:500:a8::e#53
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './DNSKEY/IN': 2001:503:c27::2:30#53
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './NS/IN': 2001:503:c27::2:30#53
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './DNSKEY/IN': 2001:500:2::c#53
 1월 31 15:00:12 junga.kgitbank named[6162]: error (network unreachable) resolving './NS/IN': 2001:500:2::c#53

 

// 2018.02.01 실습 추가분

[root@junga ~]# nslookup
> testdns.com
Server:  168.126.63.1
Address: 168.126.63.1#53

Non-authoritative answer:
Name: testdns.com
Address: 81.94.198.122
> exit

[root@junga ~]# ls -l /etc/resolv.conf
-rw-r--r-- 1 root root 94  2월  1 12:43 /etc/resolv.conf
[root@junga ~]# vi /etc/resolv.conf
# Generated by NetworkManager
search kgitbank
nameserver 192.168.46.90            // 내꺼 ip 슈퍼 dns 앞에 추가 할 것!!!
nameserver 168.126.63.1
nameserver 168.126.63.2
~                         

[root@junga ~]#
[root@junga ~]# nslookup
> testdns.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: testdns.com
Address: 192.168.46.90
>  
> ns.testdns.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: ns.testdns.com
Address: 192.168.46.90

 

<실습 1>

클라이언트에서 작업(스냅샷 돌리고)

네임서버 fifa.com을 구축

 

* dns 관련 파일

1) /etc/host.conf - 우선순위를 지정하는 파일

2) /etc/hosts - 호스트와 네임과 IP Address의 관계를 설정

3) /etc/resolv.conf (나가서 찾는당) - 호스트가 사용할 DNS 서버 주소를 설정하는 파일

 

① dns 관련 패키지 설치

# yum install bind*

...

 

<실습 2>

서버에서 작업해주세요(스냅샷 돌리고)

네임서버는 여러분의 이름으로 구축하세요. ex) junga.com

① named 패키지 설치(bind)

② 설정파일 설정

1) /etc/named.conf => 13, 19

2) /etc/named.rfc1912.zones => 정방향(25), 역방향 정의(49)

named.conf

 y

3) 정방향, 역방향 정의 파일 기입

// 정방향 /var/named/junga.for.zone

      1 $TTL    1W      ;       1 week
      2 @       IN      SOA     ns.junga.com.   root(
      3                 2018020100      ;       serial
      4                 6H              ;       refresh(6 hours)
      5                 30M             ;       retry  (30 Minute)
      6                 1W              ;       expire (1 week)
      7                 1W              ;       minimum (1 week)
      8                 )
      9         IN      NS      ns.junga.com.
     10         IN      A       192.168.46.90
     11        
     12 ns      IN      A       192.168.46.90


// 역방향 junga.rev.zone

      1 $TTL    1W      ;       1 week
      2 @       IN      SOA     ns.junga.com.   root(
      3                 2018020100      ;       serial
      4                 6H              ;       refresh(6 hours)
      5                 30M             ;       retry  (30 Minute)
      6                 1W              ;       expire (1 week)
      7                 1W              ;       minute (1 week)
      8                 )
      9         IN      NS      ns.junga.com.
     10         IN      A       192.168.46.90
     11

12 ns      IN      A       192.168.46.90 
12 90      IN      PTR     ns.junga.com.


 

4) 시스템 재 시작 및 nslookup

# vi /etc/resolv.conf
nameserver 192.168.46.90
추가

 

위 작업이 다 되었으면 확인 후 아래와 같이 nslookup으로 조회될 수 있게 작업

ex)

nslookup

www.kildong.com

blog.kildong.com

cafe.kildong.com

mail.kildon퍄g.com

 

 

<실습 3>

라운드 로빈???

=> IP만 추가???

 

nslookup

kildong.com

192.168.x.128

192.168.x.129

 

//정방향

# vi /var/named/junga.for.zone
      1 $TTL    1W      ;       1 week
      2 @       IN      SOA     ns.junga.com.   root(
      3                 2018020100      ;       serial
      4                 6H              ;       refresh(6 hours)
      5                 30M             ;       retry  (30 Minute)
      6                 1W              ;       expire (1 week)
      7                 1W              ;       minimum (1 week)
      8                 )
      9         IN      NS      ns.junga.com.
     10         IN      A       192.168.46.90
     11         IN      A       192.168.46.91
     12         IN      A       192.168.46.92

     13
     14 ns      IN      A       192.168.46.90
     15 www     IN      A       192.168.46.90
     16 blog    IN      A       192.168.46.90
     17 cafe    IN      A       192.168.46.90
     18 mail    IN      A       192.168.46.90

// 시스템 재시작

[root@junga named]# nslookup
> junga.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: junga.com
Address: 192.168.46.92
Name: junga.com
Address: 192.168.46.90
Name: junga.com
Address: 192.168.46.91
>
> junga.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Name: junga.com
Address: 192.168.46.91
Name: junga.com
Address: 192.168.46.92
Name: junga.com
Address: 192.168.46.90

 

<실습4>

별칭

[root@junga named]# nslookup
> www.naver.com
Server:  192.168.46.90
Address: 192.168.46.90#53

Non-authoritative answer:
www.naver.com canonical name = www.naver.com.nheos.com.
Name: www.naver.com.nheos.com
Address: 125.209.222.142
Name: www.naver.com.nheos.com
Address: 210.89.164.90

# vi /var/named/junga.for.zone

      1 $TTL    1W      ;       1 week
      2 @       IN      SOA     ns.junga.com.   root(
      3                 2018020100      ;       serial
      4                 6H              ;       refresh(6 hours)
      5                 30M             ;       retry  (30 Minute)
      6                 1W              ;       expire (1 week)
      7                 1W              ;       minimum (1 week)
      8                 )
      9         IN      NS      ns.junga.com.
     10         IN      A       192.168.46.90
     11         IN      A       192.168.46.91
     12         IN      A       192.168.46.92
     13
     14 ns      IN      A       192.168.46.90
     15 www     IN      A       192.168.46.90
     16 blog    IN      A       192.168.46.90
     17 cafe    IN      A       192.168.46.90
     18 mail    IN      A       192.168.46.90
     19 seo     IN      CNAME   www.junga.com.    // www 는 위에 있는거이기 때문에 가능! 기존에 있는거로 추가할것!

// 데몬 재실행

[root@junga named]# nslookup
> seo.junga.com
Server:  192.168.46.90
Address: 192.168.46.90#53

seo.junga.com canonical name = www.junga.com.
Name: www.junga.com
Address: 192.168.46.90


 

반응형
LIST

'BigData_Off1 > 리눅스2' 카테고리의 다른 글

2018.02.05-18일차 Web Server  (0) 2018.02.05
DNS 2(slave DNS), Web Server  (0) 2018.02.02
Autofs 2(① autofs 2nd, ② 실습1)  (0) 2018.01.29
Autofs 1(① autofs, ② 실습1)  (0) 2018.01.26
File Service 3(③auto mount ④NFS)  (0) 2018.01.24
Posted by 오정oI
, |
반응형
SMALL

* 쌤 정리 강의 노트 :

1월29일_13평일리2.txt

* 쌤 정리 실습:

2018.01.29_쌤 실습.txt

 * 수업 끝난 후 실습 리뷰:

08.01.29_nfs_pc2_review.txt

 

* 자동서비스

1> 개념

- 시스템을 재부팅하면 서버가 자동 서비스로 설정한 서비스를 딱 한 번 시작 해줌

- 자주 사용하는 서비스를 설정

- 별도로 해당 서비스를 작업시 본인이 서비스를 껏다가 다시 시작해야 함

 

2> 명령어

centOS 6(이하) 

centOS 7 

chkconfig service(daemon) on

 systemctl enable service(daemon) 

 chkconfig service(daemon) off

 systemctl disable service(daemon) 

 chkconfig --list service(daemon) 

 

 systemctl is-enabled service(daemon) 

 systemctl list-dependencies --before service(daemon)

 systemctl list-dependencies --after service(daemon)

 chkconfig --list

 systemctl list-unit-files --type service(daemon) 

 

 

// client

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        13G  7.4G  5.6G  57% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           488M  7.1M  481M   2% /run
tmpfs           488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1        97M  5.2M   92M   6% /auto/sharedir
/dev/sdb3       297M   16M  282M   6% /server_auto
/dev/sda5       197M   16M  181M   9% /home
/dev/sda1       997M  194M  803M  20% /boot
/dev/sda3       2.0G  456M  1.5G  23% /var
tmpfs            98M  4.0K   98M   1% /run/user/42
tmpfs            98M   16K   98M   1% /run/user/0
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]# ls -l /server_auto/
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1
-rw-r--r-- 1 root root 0  1월 26 15:09 testfile2
[root@localhost ~]# systemctl restart nfs.service
[root@localhost ~]#
[root@localhost ~]# ifconfig | head -2
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.46.85  netmask 255.255.255.0  broadcast 192.168.46.255
[root@localhost ~]#

// server

[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]#
[root@localhost ~]# ls -l /misc
합계 0
dr-xr-xr-x 2 root root 0  1월 29 12:43 cd
dr-xr-xr-x 2 root root 0  1월 29 12:43 test_autofs
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/test_autofs/
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1
-rw-r--r-- 1 root root 0  1월 26 15:09 testfile2
[root@localhost ~]#
[root@localhost ~]# tail -1 /etc/auto.misc
test_autofs   -rw,intr  192.168.46.85:/server_auto

// client

# systemctl enable nfs.service

# systemctl is-enabled nfs.service

# systemctl enable nfs.service

// server

# systemctl enable autofs.service

# systemctl is-enabled autofs.service

# systemctl enable autofs.service

 

// client

// server

=> 스냅샷 : ~ _마지막으로    Go To

 

<실습1>

nfs service와 autofs service 최종 실습

서버와 클라이언트를 스냅샷 돌리고 진행(총 2대)

 

nfs server

HDD(SCSI, 1GB) partition은 5개 설정, 용량은 자유롭게

nfs service 작업할 때

첫번째 호스트가 읽고 쓰기가 가능하며 nfs client의 root를 무시하지 않고 인정

두번째 네트워크 대역으로 읽고 쓰기가 가능하며 nfs client의 root를 무시

세번째 모든 네트워크가 읽기 전용으로 가능하며 nfs client의 root를 무시

auto mount

nfs service를 자동 서비스로 등록

 

nfs client

nfs server가 공유한 파일 시스템을 nfs service를 이용하여 설정한 뒤에 nfs server와 공유되는지 확인

nfs server가 공유한 파일 시스템을 autofs service를 이용하여 설정한 뒤에 nfs server와 공유되는지 확인

nfs server가 공유한 파일 시스템을 nfs service 또는 autofs service를 이용하여 설정한 뒤에 nfs server와

공유되는지 확인(이 때, autofs service로 설정을 했으면 반드시 재부팅하여 nfs server와 공유되는지 확인)

 

 

 

======================================

// [server]

// ① partition

[root@junga ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000caf70

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200     6293503     2097152   82  Linux swap / Solaris
/dev/sda3         6293504    41943039    17824768   83  Linux

Disk /dev/sdb: 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

[root@junga ~]# fdisk /dev/sdb
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 0x6c545c73.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +100M
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (206848-2097151, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-2097151, default 2097151): +100M
Partition 2 of type Linux and of size 100 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (411648-2097151, default 411648):
Using default value 411648
Last sector, +sectors or +size{K,M,G} (411648-2097151, default 2097151): +200M
Partition 3 of type Linux and of size 200 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (821248-2097151, default 821248):
Using default value 821248
Last sector, +sectors or +size{K,M,G} (821248-2097151, default 2097151): +200M
Partition 4 of type Linux and of size 200 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux
/dev/sdb4          821248     1230847      204800   83  Linux

Command (m for help): n
If you want to create more than four partitions, you must replace a
primary partition with an extended partition first.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
If you want to create more than four partitions, you must replace a
primary partition with an extended partition first.

Command (m for help): d
Partition number (1-4, default 4): 4
Partition 4 is deleted

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): e
Selected partition 4
First sector (821248-2097151, default 821248):
Using default value 821248
Last sector, +sectors or +size{K,M,G} (821248-2097151, default 2097151): +300M
Partition 4 of type Extended and of size 300 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux
/dev/sdb4          821248     1435647      307200    5  Extended

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (823296-1435647, default 823296):
Using default value 823296
Last sector, +sectors or +size{K,M,G} (823296-1435647, default 1435647): +150M
Partition 5 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux
/dev/sdb4          821248     1435647      307200    5  Extended
/dev/sdb5          823296     1130495      153600   83  Linux

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (1132544-1435647, default 1132544):
Using default value 1132544
Last sector, +sectors or +size{K,M,G} (1132544-1435647, default 1435647):
Using default value 1435647
Partition 6 of type Linux and of size 148 MiB is set

Command (m for help): p

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux
/dev/sdb4          821248     1435647      307200    5  Extended
/dev/sdb5          823296     1130495      153600   83  Linux
/dev/sdb6         1132544     1435647      151552   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

// ② format

[root@junga ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 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: 0x6c545c73

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648      821247      204800   83  Linux
/dev/sdb4          821248     1435647      307200    5  Extended
/dev/sdb5          823296     1130495      153600   83  Linux
/dev/sdb6         1132544     1435647      151552   83  Linux
[root@junga ~]#
[root@junga ~]# mkfs -t xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=6400 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=25600, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@junga ~]#
[root@junga ~]# mkfs -t xfs /dev/sdb3
meta-data=/dev/sdb3              isize=512    agcount=4, agsize=12800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@junga ~]# mkfs.xfs /dev/sdb4
mkfs.xfs: /dev/sdb4 appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[root@junga ~]# mkfs -t xfs /dev/sdb4
mkfs.xfs: /dev/sdb4 appears to contain a partition table (dos).
mkfs.xfs: Use the -f option to force overwrite.
[root@junga ~]#
[root@junga ~]# blkid /dev/sdb1 /dev/sdb2 /dev/sdb4
/dev/sdb1: UUID="4dc153b2-466b-4203-b351-13423d424b07" TYPE="xfs"
/dev/sdb4: PTTYPE="dos"
[root@junga ~]#
[root@junga ~]# blkid /dev/sdb1 /dev/sdb3 /dev/sdb4
/dev/sdb1: UUID="4dc153b2-466b-4203-b351-13423d424b07" TYPE="xfs"
/dev/sdb3: UUID="d245d92f-fdfe-41de-8fac-91c22f684e72" TYPE="xfs"
/dev/sdb4: PTTYPE="dos"
[root@junga ~]#
[root@junga ~]# mkfs.xfs /dev/sdb5
meta-data=/dev/sdb5              isize=512    agcount=4, agsize=9600 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=38400, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@junga ~]#
[root@junga ~]# blkid /dev/sdb1 /dev/sdb3 /dev/sdb5
/dev/sdb1: UUID="4dc153b2-466b-4203-b351-13423d424b07" TYPE="xfs"
/dev/sdb3: UUID="d245d92f-fdfe-41de-8fac-91c22f684e72" TYPE="xfs"
/dev/sdb5: UUID="d6fb29c5-06e0-4b8c-a297-dffe6eee7519" TYPE="xfs"

// ③ mount, automount (/etc/fstab)

[root@junga ~]# vi /etc/fstab

     12 /dev/sdb1       /test2/nfsServer1        xfs defaults 0 0
     13 /dev/sdb3       /test2/nfsServer2        xfs defaults 0 0
     14 /dev/sdb5       /test2/nfsServer3        xfs defaults 0 0
[root@junga ~]# mkdir -p /test2/nfsServer1 /test2/nfsServer2 /test2/nfsServer3
[root@junga ~]#
[root@junga ~]# ls -l /test2
합계 0
drwxr-xr-x 2 root root 6  1월 29 13:34 nfsServer1
drwxr-xr-x 2 root root 6  1월 29 13:34 nfsServer2
drwxr-xr-x 2 root root 6  1월 29 13:34 nfsServer3
[root@junga ~]#
[root@junga ~]# mount -a
[root@junga ~]# df -h | tail -4
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1        97M  5.2M   92M   6% /test2/nfsServer1
/dev/sdb3       197M   11M  187M   6% /test2/nfsServer2
/dev/sdb5       147M  7.7M  139M   6% /test2/nfsServer3
[root@junga ~]#
[root@junga ~]# mount | tail -4
/dev/sr0 on /run/media/root/CentOS 7 x86_64 type iso9660 (ro,nosuid,nodev,relatime,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
/dev/sdb1 on /test2/nfsServer1 type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sdb3 on /test2/nfsServer2 type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sdb5 on /test2/nfsServer3 type xfs (rw,relatime,attr2,inode64,noquota)

// ④ nfs mount (/etc/exports)

// nfs 패키지 설치(portmap도 확인)

[root@junga ~]# rpm -qa | grep nfs
libnfsidmap-0.25-17.el7.x86_64
nfs-utils-1.3.0-0.48.el7.x86_64
[root@junga ~]# rpm -qa | grep portmap
[root@junga ~]#
[root@junga ~]# yum install nfs*
Is this ok [y/d/N]: y
Downloading packages:

Updated:
  nfs-utils.x86_64 1:1.3.0-0.48.el7_4.1                                       

Complete!

// /etc/exports

[root@junga ~]# ls -l /etc/exports
-rw-r--r--. 1 root root 0  6월  7  2013 /etc/exports
[root@junga ~]#
[root@junga ~]# vi /etc/exports
      1 /test2/nfsServer1 192.168.46.90(rw,no_root_squash,sync)
      2 /test2/nfsServer2 192.168.46.0(rw,root_squash,sync)
      3 /test2/nfsServer3 *(ro,root_squash,sync)

 

// nfs service 재시작 및 자동 서비스로 등록

[root@junga ~]# systemctl is-active nfs.service
unknown
[root@junga ~]#
[root@junga ~]# systemctl restart nfs.service
[root@junga ~]#
[root@junga ~]# systemctl -l status nfs.servicew
Unit nfs.servicew.service could not be found.
[root@junga ~]# systemctl -l status nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since 월 2018-01-29 13:47:11 KST; 21s ago
  Process: 3943 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 3938 ExecStartPre=/bin/sh -c /bin/kill -HUP `cat /run/gssproxy.pid` (code=exited, status=0/SUCCESS)
  Process: 3937 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 3943 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

 1월 29 13:47:11 junga.kgitbank systemd[1]: Starting NFS server and services...
 1월 29 13:47:11 junga.kgitbank systemd[1]: Started NFS server and services.
[root@junga ~]#
[root@junga ~]#
[root@junga ~]# systemctl enable nfs.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@junga ~]#
[root@junga ~]# systemctl is-enabled nfs.service
enabled
[root@junga ~]# systemctl enable nfs.service
[root@junga ~]# systemctl enable nfs.service
[root@junga ~]#
[root@junga ~]#

// nfs service 확인

[root@junga ~]# exportfs -v
/test2/nfsServer1
  192.168.46.90(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,no_root_squash,no_all_squash)
/test2/nfsServer2
  192.168.46.0(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)
/test2/nfsServer3
  <world>(ro,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)
[root@junga ~]# exportfs -ra

 

[client]

// ⑤ autofs 관련

// autofs 설치

[root@junga ~]# rpm -qa | grep autofs
[root@junga ~]#
[root@junga ~]# yum install autofs*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package autofs.x86_64 1:5.0.7-70.el7_4.1 will be installed
--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-70.el7_4.1.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package       Arch          Version                      Repository      Size
===============================================================================
Installing:
 autofs        x86_64        1:5.0.7-70.el7_4.1           updates        809 k
Installing for dependencies:
 hesiod        x86_64        3.2.1-3.el7                  base            30 k

Transaction Summary
===============================================================================
Install  1 Package (+1 Dependent package)

Total download size: 839 k
Installed size: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): hesiod-3.2.1-3.el7.x86_64.rpm                      |  30 kB   00:00    
(2/2): autofs-5.0.7-70.el7_4.1.x86_64.rpm                 | 809 kB   00:00    
-------------------------------------------------------------------------------
Total                                             1.0 MB/s | 839 kB  00:00    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : hesiod-3.2.1-3.el7.x86_64                                   1/2
  Installing : 1:autofs-5.0.7-70.el7_4.1.x86_64                            2/2
  Verifying  : 1:autofs-5.0.7-70.el7_4.1.x86_64                            1/2
  Verifying  : hesiod-3.2.1-3.el7.x86_64                                   2/2

Installed:
  autofs.x86_64 1:5.0.7-70.el7_4.1                                            

Dependency Installed:
  hesiod.x86_64 0:3.2.1-3.el7                                                 

Complete!
[root@junga ~]#

// autofs 관련 설정

[root@junga ~]# ls -l /etc/autofs.conf
-rw-r--r-- 1 root root 14392 12월  1 04:17 /etc/autofs.conf
[root@junga ~]#
[root@junga ~]# vi /etc/autofs.conf
45 browse_mode = yes

[root@junga ~]# vi /etc/auto.misc
test_nfs_c1 -rw,intr 192.168.46.90:/test2/nfsServer1
test_nfs_c2 -rw,intr 192.168.46.0:/test2/nfsServer2
test_nfs_c3 -rw,intr *:/test2/nfsServer3

[root@junga ~]#

// autofs service 재시작 및 자동 서비스 등록

[root@localhost ~]# systemctl is-active autofs.service
unknown
[root@localhost ~]#
[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]#
[root@localhost ~]# systemctl is-active autofs.service
active
[root@localhost ~]#
[root@localhost ~]# systemctl -l status autofs.service
● autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
   Active: active (running) since 월 2018-01-29 14:06:11 KST; 15s ago
  Process: 2632 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 2634 (automount)
   CGroup: /system.slice/autofs.service
           └─2634 /usr/sbin/automount --pid-file /run/autofs.pid

 1월 29 14:06:01 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:01 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:03 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:05 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:07 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:09 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:11 localhost.localdomain automount[2634]: problem reading master map, maximum wait exceeded
 1월 29 14:06:11 localhost.localdomain automount[2634]: /usr/sbin/automount: warning: could not read at least one map source after waiting, continuing ...
 1월 29 14:06:11 localhost.localdomain automount[2634]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 29 14:06:11 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.
[root@localhost ~]# test_nfs_c1 -rw,intr 192.168.46.90:/test2/nfsServer1
bash: test_nfs_c1: 명령을 찾을 수 없습니다...
[root@localhost ~]# test_nfs_c2 -rw,intr 192.168.46.0:/test2/nfsServer2
bash: test_nfs_c2: 명령을 찾을 수 없습니다...
[root@localhost ~]# test_nfs_c3 -rw,intr *:/test2/nfsServer3
bash: test_nfs_c3: 명령을 찾을 수 없습니다...
[root@localhost ~]#

// 자동 서비스 등록

[root@localhost ~]# systemctl is-enabled autofs.service
disabled
[root@localhost ~]#
[root@localhost ~]# systemctl enable autofs.service
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[root@localhost ~]#
[root@localhost ~]# systemctl is-enabled autofs.service
enabled

// autofs 확인

 

// 방화벽 내가 한거 어디감 ? -.,-

반응형
LIST
Posted by 오정oI
, |
반응형
SMALL

* 강사님 정리 노트 :

1월26일_12평일리2.txt

* autofs

# man nfs

 

 

0> 개념

- 자동 마운트의 작동을 제어하는 서비스(daemon)

- 자동으로 사용시 파일 시스템을 마운트하고 일정시간이 지나 사용하지 않으면 저절로 언마운트 함

 

autofs 패키지 설치 유무를 확인!

패키지명은 autofs로 시작함

 

1> /etc/autofs.conf

(참고로 CentOS 6.5 이후부터는 /etc/autofs.conf 파일로 바뀜.

그전에는 /etc/sysconfig/autofs 파일이었음)

 

15줄 : 일정시간동안 아무런 작업을 하지 않으면 저절로 언마운트되는 시간이 지정

45줄: 자동으로 생성되는 디렉터리 출력 여부 (기본값 no를 yes로 바꿔주어야함=> ls, cd 가능하게하려면..,)

=> etc/auto.master

 

2> /etc/auto.master

- 자동으로 생성될 디렉터리와 관련된 설정파일이 저장되어 있는 파일

=> /misc 여기 하위가 client가 autofs mount 할 경로?

=> autofs를 쓸 때 자동마운트 할 경로 (mount pt.?)

 

7줄 : 자동으로 생성되는 디렉터리 경로와 해당 관련 설정파일이 지정 되어있음

=> /etc/auto.misc

 

3> /etc/auto.misc

- client의 마운트 포인트명과 접속할 Server-IP와 Server의 공유할 디렉터리를 설정하는 파일

 

설정방법

16 client의 mount-point     -option     Server-IP:Server의 share_dir

=> 16 test_nfs_c1     -rw,intr   192.168.46.90:/test_nfs_s1

option

ro → 읽기전용 파일 시스템

rw → 읽고쓰기 파일 시스템

soft → nfs server 요청에 실패하면 returns 설정에 횟수 만큼 재 요청을 시도함

hard → nfs server 요청에 실패하면 무한정 재시도(기본값)

intr(interrupt) → 정지 프로세스를 죽이기 위함

 

 

 

 

 

 

 

[server]

① 파티션 설정

② 포맷     /dev/sdb1

③ nfs 패키지 설치

④ /etc/exports 설정

⑤ nfs.service 재시작, exportfs -ra

⑥ mount

⑦  automount(재부팅 하면 날라가니까 해줌!) : /etc/exports 쓰기

[client]

① nfs mount (nfs service가 켜져 있어야..,)

 

=> client도 automount 하고 싶다!

① /etc/fstab이 있다?

② autofs system => 저절로 mount..,

    안 쓰면 또 unmount..,

 

[root@junga /]# rpm -qa | grep autofs
[root@junga /]#
[root@junga /]# yum install autofs*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: mirror.0x.sg
Resolving Dependencies
--> Running transaction check
---> Package autofs.x86_64 1:5.0.7-70.el7_4.1 will be installed
--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-70.el7_4.1.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package           Arch              Version                       Repository          Size
============================================================================================
Installing:
 autofs            x86_64            1:5.0.7-70.el7_4.1            updates            809 k
Installing for dependencies:
 hesiod            x86_64            3.2.1-3.el7                   base                30 k

Transaction Summary
============================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 839 k
Installed size: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): hesiod-3.2.1-3.el7.x86_64.rpm                                 |  30 kB  00:00:00    
(2/2): autofs-5.0.7-70.el7_4.1.x86_64.rpm                            | 809 kB  00:00:02    
--------------------------------------------------------------------------------------------
Total                                                       303 kB/s | 839 kB  00:00:02    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : hesiod-3.2.1-3.el7.x86_64                                                1/2
  Installing : 1:autofs-5.0.7-70.el7_4.1.x86_64                                         2/2
  Verifying  : 1:autofs-5.0.7-70.el7_4.1.x86_64                                         1/2
  Verifying  : hesiod-3.2.1-3.el7.x86_64                                                2/2

Installed:
  autofs.x86_64 1:5.0.7-70.el7_4.1                                                         

Dependency Installed:
  hesiod.x86_64 0:3.2.1-3.el7                                                              

Complete!

[root@junga /]# vi /etc/autofs.conf
[root@junga /]#
[root@junga /]# ls -l /etc/autofs.conf
-rw-r--r-- 1 root root 14393  1월 26 13:18 /etc/autofs.conf
[root@junga /]#
[root@junga /]# ls -l /etc/auto.master
-rw-r--r-- 1 root root 795 12월  1 04:17 /etc/auto.master
[root@junga /]#
[root@junga /]# vi /etc/auto.master
[root@junga /]#
[root@junga /]# vi /etc/auto.misc

16 test_nfs_c1     -rw,intr   192.168.46.90:/test_nfs_s1

[root@junga /]#
[root@junga /]# tail -1 /etc/auto.misc
test_nfs_c1 -rw,intr   192.168.46.90:/test_nfs_s1
[root@junga /]#
[root@junga /]# systemctl is-active nfs.service
unknown
[root@junga /]#
[root@junga /]# systemctl is-active autofs.service
unknown

 

[root@junga /]# systemctl restart nfs.service

[root@junga /]#
[root@junga /]# systemctl restart autofs.service

[root@junga /]# systemctl -l status autofs.service
● autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
   Active: active (running) since 금 2018-01-26 14:02:04 KST; 1min 25s ago
  Process: 4379 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 4381 (automount)
   CGroup: /system.slice/autofs.service
           └─4381 /usr/sbin/automount --pid-file /run/autofs.pid

 1월 26 14:01:54 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:01:54 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:01:56 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:01:58 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:02:00 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:02:02 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:02:04 junga.kgitbank automount[4381]: problem reading master map, maximum wait exceeded
 1월 26 14:02:04 junga.kgitbank automount[4381]: /usr/sbin/automount: warning: could not read at least one map source after waiting, continuing ...
 1월 26 14:02:04 junga.kgitbank automount[4381]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:02:04 junga.kgitbank systemd[1]: Started Automounts filesystems on demand.

[root@junga /]# ls -l /misc
합계 0
dr-xr-xr-x 2 root root 0  1월 26 14:02 cd
dr-xr-xr-x 2 root root 0  1월 26 14:02 test_nfs_c1        // autofs 재 시작 후 생성
[root@junga /]#
[root@junga /]#

// 확인

[client]

[root@junga /]# ls -l /misc/test_nfs_c1
합계 0
[root@junga /]#
[root@junga /]# touch /misc/test_nfs_c1/testfile2
[root@junga /]#
[root@junga /]# ls -l /misc/test_nfs_c1
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:12 testfile2

[server]

[root@junga ~]# ls -l /test_nfs_s1
합계 0
[root@junga ~]# ls -l /test_nfs_s1
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:12 testfile2


 

// reboot 후?

==============================

<실습 1>

autofs 실습

- client에서 어제 환경설정을 이어서..

HDD : 1GB, SCSI

Partition : 100, 200, 300(이걸 사용), 400

nfs server
/etc/exports -> 호스트 방식(우리가 연습했던 옵션 그대로)
auto mount

nfs client
autofs service를 사용
nfs client 마운트포인트에서 파일이나 디렉터리 생성 후 nfs server에서도 공유되는지 확인(반드시 재부팅 후 확인)

 

[server]

① /dev/sdb3 format, automount(/etc/fstab + mount) 

② autofs 설치

③ 설정파일 : /etc/autofs.conf (line. 45)

    autofs mount pt. : /etc/auto.master (line. 7) 확인

④ autofs 재시작 및 /misc 폴더 생성 확인

⑤ 확인 및 reboot (안되면 reset!)

 

 

 

 

// ①

[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda6                      13G  7.4G  5.6G  57% /
devtmpfs                      474M     0  474M   0% /dev
tmpfs                         488M     0  488M   0% /dev/shm
tmpfs                         488M  7.1M  481M   2% /run
tmpfs                         488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1                      97M  5.2M   92M   6% /auto/sharedir
/dev/sda5                     197M   16M  181M   9% /home
/dev/sda1                     997M  194M  803M  20% /boot
/dev/sda3                     2.0G  453M  1.6G  23% /var
tmpfs                          98M  4.0K   98M   1% /run/user/42
tmpfs                          98M   24K   98M   1% /run/user/0
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 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: 0x80ac2390

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      616447      204800   83  Linux
/dev/sdb3          616448     1230847      307200   83  Linux
/dev/sdb4         1230848     2097151      433152   83  Linux
[root@localhost ~]#
[root@localhost ~]# mkfs.xfs /dev/sdb3
mkfs.xfs: /dev/sdb3 appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
[root@localhost ~]#
[root@localhost ~]# blkid /dev/sdb3
/dev/sdb3: UUID="ddf9e8e5-e124-4cf6-bf0f-49777b22637d" TYPE="xfs"
[root@localhost ~]#
[root@localhost ~]# vi /etc/exports
[root@localhost ~]#
[root@localhost ~]# vi /etc/fstab
[root@localhost ~]#
[root@localhost ~]# df -h | tail -2
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda6                      13G  7.4G  5.6G  57% /
devtmpfs                      474M     0  474M   0% /dev
tmpfs                         488M     0  488M   0% /dev/shm
tmpfs                         488M  7.1M  481M   2% /run
tmpfs                         488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1                      97M  5.2M   92M   6% /auto/sharedir
/dev/sda5                     197M   16M  181M   9% /home
/dev/sda1                     997M  194M  803M  20% /boot
/dev/sda3                     2.0G  453M  1.6G  23% /var
tmpfs                          98M  4.0K   98M   1% /run/user/42
tmpfs                          98M   24K   98M   1% /run/user/0
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1
[root@localhost ~]#
[root@localhost ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Jan 11 13:46:02 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=bbfd7ee6-e6db-40ef-8ed1-03b0efff5577 /                       xfs     defaults        0 0
UUID=4eaedded-01f7-4013-a328-364dfe587223 /boot                   xfs     defaults        0 0
UUID=bfcdb9c5-05c7-49ba-b530-8d4aedd39841 /home                   xfs     defaults        0 0
UUID=d2a7fb6a-fe3b-4022-93b0-8e4f6044cfb8 /var                    xfs     defaults        0 0
UUID=3e93d164-8196-471f-90a9-0f1937711e92 swap                    swap    defaults        0 0
/dev/sdb1 /auto/sharedir xfs defaults 0 0
/dev/sdb3 /server_auto xfs defaults 0 0
[root@localhost ~]#
[root@localhost ~]# mkdir /server_auto
[root@localhost ~]#
[root@localhost ~]# mount /dev/sdb3 /server_auto
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda6                      13G  7.4G  5.6G  57% /
devtmpfs                      474M     0  474M   0% /dev
tmpfs                         488M     0  488M   0% /dev/shm
tmpfs                         488M  7.1M  481M   2% /run
tmpfs                         488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1                      97M  5.2M   92M   6% /auto/sharedir
/dev/sda5                     197M   16M  181M   9% /home
/dev/sda1                     997M  194M  803M  20% /boot
/dev/sda3                     2.0G  453M  1.6G  23% /var
tmpfs                          98M  4.0K   98M   1% /run/user/42
tmpfs                          98M   24K   98M   1% /run/user/0
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1
/dev/sdb3                     297M   16M  282M   6% /server_auto

 

// ② autofs 설치

[root@localhost ~]# rpm -qa | grep autofs
[root@localhost ~]#
[root@localhost ~]# yum install autofs*
Loaded plugins: fastestmirror, langpacks
base                                                                 | 3.6 kB  00:00:00    
extras                                                               | 3.4 kB  00:00:00    
updates                                                              | 3.4 kB  00:00:00    
updates/7/x86_64/primary_db                                          | 6.0 MB  00:00:00    
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package autofs.x86_64 1:5.0.7-70.el7_4.1 will be installed
--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-70.el7_4.1.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================
 Package           Arch              Version                       Repository          Size
============================================================================================
Installing:
 autofs            x86_64            1:5.0.7-70.el7_4.1            updates            809 k
Installing for dependencies:
 hesiod            x86_64            3.2.1-3.el7                   base                30 k

Transaction Summary
============================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 839 k
Installed size: 5.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): hesiod-3.2.1-3.el7.x86_64.rpm                                 |  30 kB  00:00:00    
(2/2): autofs-5.0.7-70.el7_4.1.x86_64.rpm                            | 809 kB  00:00:01    
--------------------------------------------------------------------------------------------
Total                                                       598 kB/s | 839 kB  00:00:01    
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : hesiod-3.2.1-3.el7.x86_64                                                1/2
  Installing : 1:autofs-5.0.7-70.el7_4.1.x86_64                                         2/2
  Verifying  : 1:autofs-5.0.7-70.el7_4.1.x86_64                                         1/2
  Verifying  : hesiod-3.2.1-3.el7.x86_64                                                2/2

Installed:
  autofs.x86_64 1:5.0.7-70.el7_4.1                                                         

Dependency Installed:
  hesiod.x86_64 0:3.2.1-3.el7                                                              

Complete!

 

[root@localhost ~]# rpm -qa | grep autofs
autofs-5.0.7-70.el7_4.1.x86_64

 

// ③

[root@localhost ~]# ls -l /etc/autofs.conf
-rw-r--r-- 1 root root 14392 12월  1 04:17 /etc/autofs.conf
[root@localhost ~]#
[root@localhost ~]# vi /etc/autofs.conf

 45 browse_mode = yes
:wq

[root@localhost ~]# vi /etc/auto.master

 7 /misc   /etc/auto.misc

// ④

[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]#
[root@localhost ~]# systemctl is-active autofs.service
active
[root@localhost ~]#
[root@localhost ~]# systemctl -l status autofs.service
● autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
   Active: active (running) since 금 2018-01-26 14:31:45 KST; 1min 9s ago
  Process: 14645 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 14647 (automount)
   CGroup: /system.slice/autofs.service
           └─14647 /usr/sbin/automount --pid-file /run/autofs.pid

 1월 26 14:31:35 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:35 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:37 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:39 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:41 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:43 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:45 localhost.localdomain automount[14647]: problem reading master map, maximum wait exceeded
 1월 26 14:31:45 localhost.localdomain automount[14647]: /usr/sbin/automount: warning: could not read at least one map source after waiting, continuing ...
 1월 26 14:31:45 localhost.localdomain automount[14647]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:31:45 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.
[root@localhost ~]#
[root@localhost ~]#

[root@localhost ~]# vi /etc/auto.misc
16 test_autofs      -rw,intr  192.168.46.85:/server_auto

// ④

[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]# systemctl -l status autofs.service
● autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled; vendor preset: disabled)
   Active: active (running) since 금 2018-01-26 14:39:19 KST; 16s ago
  Process: 14935 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS)
 Main PID: 14937 (automount)
   CGroup: /system.slice/autofs.service
           └─14937 /usr/sbin/automount --pid-file /run/autofs.pid

 1월 26 14:39:09 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:09 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:11 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:13 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:15 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:17 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:19 localhost.localdomain automount[14937]: problem reading master map, maximum wait exceeded
 1월 26 14:39:19 localhost.localdomain automount[14937]: /usr/sbin/automount: warning: could not read at least one map source after waiting, continuing ...
 1월 26 14:39:19 localhost.localdomain automount[14937]: open_sss_lib:78: lookup(sss): failed to open /usr/lib64/sssd/modules/libsss_autofs.so: /usr/lib64/sssd/modules/libsss_autofs.so: cannot open shared object file: No such file or directory
 1월 26 14:39:19 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/
합계 0
dr-xr-xr-x 2 root root 0  1월 26 14:39 cd
dr-xr-xr-x 2 root root 0  1월 26 14:39 test_autofs
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/sda6                      13G  7.4G  5.6G  57% /
devtmpfs                      474M     0  474M   0% /dev
tmpfs                         488M     0  488M   0% /dev/shm
tmpfs                         488M  7.1M  481M   2% /run
tmpfs                         488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1                      97M  5.2M   92M   6% /auto/sharedir
/dev/sda5                     197M   16M  181M   9% /home
/dev/sda1                     997M  194M  803M  20% /boot
/dev/sda3                     2.0G  456M  1.5G  23% /var
tmpfs                          98M  4.0K   98M   1% /run/user/42
tmpfs                          98M   24K   98M   1% /run/user/0
/dev/sr0                      8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
192.168.46.85:/auto/sharedir   97M  5.3M   92M   6% /test_nfs_c1
/dev/sdb3                     297M   16M  282M   6% /server_auto
[root@localhost ~]#

 

// ⑤

[root@localhost ~]# cat /etc/auto.misc
#
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd  -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination
#linux  -ro,soft,intr  ftp.example.org:/pub/linux
#boot  -fstype=ext2  :/dev/hda1
#floppy  -fstype=auto  :/dev/fd0
#floppy  -fstype=ext2  :/dev/fd0
#e2floppy -fstype=ext2  :/dev/fd0
#jaz  -fstype=ext2  :/dev/sdc1
#removable -fstype=ext2  :/dev/hdd
test_autofs   -rw,intr  192.168.46.85:/server_auto
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/test_autofs/ /server_auto/
/misc/test_autofs/:
합계 0

/server_auto/:
합계 0
[root@localhost ~]#
[root@localhost ~]# touch /misc/test_autofs/testfile1
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/test_autofs/ /server_auto
/misc/test_autofs/:
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1

/server_auto:
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1
[root@localhost ~]#

==============================

// 실습_ 쌤 풀이

 

[server]

① format

② nfs service 관련 :  /etc/exports 에서 공유 디렉터리 설정  ★

    mount?

(장치 2개니까 공유디렉터리도 2개 생성해야..,)

# vi /etc/exports
/server_auto    192.168.46.85(rw,no_root_squash,sync)

:wq
# exportfs -ra
# mount /dev/sdb3 /sever_auto

 

③ automount

# vi /etc/fstab

/dev/sdb3       /server_auto    xfs     defaults        0 0

---------------------------------------------

[client]

① autofs 설치

# rpm -qa | grep autofs

# yum install autofs*

y

② autofs 환경설정파일 : /etc/autofs.conf

mount 관련 파일 : /etc/auto.misc

 

# vi /etc/autofs.conf

45 browse_mode = yes


# vi /etc/auto.misc

16 test_autofs      -rw,intr  192.168.46.85:/server_auto        // client가 사용할 mount pt. 이름

// ↑ client사용 영역 => client_autofs 라고 바꿔야징..,

:wq

 

③ autofs 재 시작

# systemctl restart autofs.service
# ls -l /misc
합계 0
dr-xr-xr-x 2 root root 0  1월 26 15:06 cd
dr-xr-xr-x 2 root root 0  1월 26 15:06 test_autofs

# ls -l /misc/test_autofs/ /server_auto/
/misc/test_autofs/:
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1

/server_auto/:
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1

 

-----------------------------------------------

// 확인

[server]

[root@localhost ~]# systemctl restart nfs.service
[root@localhost ~]#
[root@localhost ~]# ls -l /server_auto/
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1
-rw-r--r-- 1 root root 0  1월 26 15:09 testfile2
[root@localhost ~]#
[root@localhost ~]#


[client]

[root@localhost ~]# systemctl restart autofs.service
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/
합계 0
dr-xr-xr-x 2 root root 0  1월 26 15:15 cd
dr-xr-xr-x 2 root root 0  1월 26 15:15 test_autofs
[root@localhost ~]#
[root@localhost ~]# ls -l /misc/test_autofs/
합계 0
-rw-r--r-- 1 root root 0  1월 26 14:44 testfile1
-rw-r--r-- 1 root root 0  1월 26 15:09 testfile2
[root@localhost ~]#
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda6        13G  7.4G  5.6G  57% /
devtmpfs        474M     0  474M   0% /dev
tmpfs           488M     0  488M   0% /dev/shm
tmpfs           488M  7.1M  481M   2% /run
tmpfs           488M     0  488M   0% /sys/fs/cgroup
/dev/sdb1        97M  5.2M   92M   6% /auto/sharedir
/dev/sdb3       297M   16M  282M   6% /server_auto
/dev/sda5       197M   16M  181M   9% /home
/dev/sda3       2.0G  456M  1.5G  23% /var
/dev/sda1       997M  194M  803M  20% /boot
tmpfs            98M  4.0K   98M   1% /run/user/42
tmpfs            98M   16K   98M   1% /run/user/0
/dev/sr0        8.1G  8.1G     0 100% /run/media/root/CentOS 7 x86_64
[root@localhost ~]#

 

=> 다음 실습은,

① server restart 없이 되야 하고,

② 진짜로 서버, 클라이언트 2개 pc 이용!


 

==============================

* clinet, server snapshot 형태

 

// 요약

// autofs 설치

# rpm -qa | grep autofs
# yum install autofs*
Is this ok [y/d/N]: y


// /misc 하위 파일 설정

 

// autofs 재시작

반응형
LIST
Posted by 오정oI
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함