반응형
nohup은 HUP(hangup) 신호를 무시하도록 만드는 POSIX 명령어이다. HUP 신호는 전통적으로 터미널이 의존 프로세스들에게 로그아웃을 알리는 방식이다. 일반적으로 터미널로 향하는 출력은 별도로 넘겨주기 처리를 하지 않았을 경우 nohup.out이라는 이름의 파일로 출력된다.

(출처 : https://ko.wikipedia.org/wiki/Nohup)

다시 말해 nohup 명령어는 터미널을 종료해서 세션이 끊어지더라도 계속 동작을 할수 있게 해준다. 

사용방법

nohup 프로세스 &

nohup.out 파일 생성하지 않으려면 

nohup 프로세스 1>/dev/null 2>&1 &

1>dev/null 은 표준출력 사용하지 않는다는 의미
2>&1 표준 에러를 표준 출력과 같게 한다는 의미

참고사항

표준입력 = 0
표준 출력 = 1
표준 에러 = 2

> :  파일이 없으면 새로 만들고 있으면 덮어쓴다.
>> : 파일이 없으면 새로 만들고 있으면 끝에 덧붙인다. 

 

728x90
반응형

'Development > Linux' 카테고리의 다른 글

xargs 명령어  (0) 2024.01.17
[리눅스 명령어] arp  (0) 2021.11.16
[리눅스 명령어] 디스크 관련 명령어  (0) 2021.06.04
파일 찾기, 파일 날짜별 삭제  (0) 2021.05.21
[리눅스 명령어] IP 관련 명령어  (0) 2021.03.08
반응형
du 디렉토리명

디렉토리와 모든 하위 디렉토리 용량을 표시해준다.

옵션
-s : 선택한 디렉토리의 용량을 보여준다.
-h : 용량 단위를 알기 쉽게 보여준다.
-d : 숫자 숫자만큼의 하위디렉토리까지 출력한다.
-a : 파일 용량도 출력한다.

df -h

디스크의 사용량을 알 수 있다.

 

728x90
반응형

'Development > Linux' 카테고리의 다른 글

[리눅스 명령어] arp  (0) 2021.11.16
[리눅스 명령어] nohup  (0) 2021.06.09
파일 찾기, 파일 날짜별 삭제  (0) 2021.05.21
[리눅스 명령어] IP 관련 명령어  (0) 2021.03.08
dpkg lock 에러  (0) 2020.09.17
반응형

ip link
- ip link set eth0 up
- eth0 인터페이스활성화

ip addr
- IP 정보 출력

ip addr add
- ip addr add ip/24 dev eth0
- eth0 인턴페이스에 IP 추가

route
- 라우팅 정보 출력

ip route add
- ip route add default via XXX.XXX.X.X
- 게이트웨이 설정
- ip route add XX.XX.XX.X/24 via XXX.XXX.X.X dev eth0
- 정적 라우팅 정보 설정

 

728x90
반응형

'Development > Linux' 카테고리의 다른 글

[리눅스 명령어] 디스크 관련 명령어  (0) 2021.06.04
파일 찾기, 파일 날짜별 삭제  (0) 2021.05.21
dpkg lock 에러  (0) 2020.09.17
netstat 사용 중인 포트 찾기  (0) 2020.07.30
openSSH 서버 활용하기  (0) 2017.04.18
반응형

Kubernetes를 사용하면서 자주 사용하는게 kubectl 명령어 이다. 그리고 그중에서 컨테이너를 생성할때 항상 kubectl create 명령어를 사용했다. 그런데 사용하다보니 어떤 글에는 create 를 사용하고 어디에서는 apply 를 사용하는 것을 보게 되었다. 그래서 이 차이점이 궁금해서 이렇게 정리하게 되었다. 


아래 내용들은 kubernetes document 에서 요약한 내용들이다. 

https://kubernetes.io/docs/concepts/overview/object-management-kubectl/overview/



Kubernetes 에서 Object Management 에는 3가지가 있다. 


Management technique

Operates on

Recommended environment 

Supported writers 

 Imperative commands

 Live objects 

 Development 

 1+ 

 Imperative object configuration

 Individual files  

 Production 

 1 

 Declarative object configuration

 Directories of files 

 Production 

 1+ 



Imperative Commands


장점

- 클러스터에 특정 오브젝트를 한번에 실행하거나 시작할수 있는 가장 쉬운 방법이다. (실제 이미지 바로 실행 시킨다. )


단점

- 기존 설정에 대한 히스토리를 제공하지 않는다. (그래서 위에 권장 환경이 Development 인것 같다.)

- 변경사항이나 audit 내역, 템플릿등을 제공하지 않는다. 


ex)

kubectl run nginx --image nginx



Imperative object configuration


- 최소한 1개 이상의 YAML 이나 JSON 포맷의 파일을 이용해서 Object 를 생성한다. 


ex)

kubectl create -f nginx.yaml

Imperative object configuration vs Imperative Commands

장점

- 설정파일 내용을 Git 같은 곳에 저장이 가능하기 때문에 설정에 대한 변경 히스토리가 확인 가능하다. 

- 새로운 Object를 생성하기 위한 템플릿을 제공한다. 

단점

- YAML 파일 작성이 필요하며 템플릿 사용을 위해 Object schema 에 대해서 이해가 필요하다.


Imperative object configuration vs Declarative object configuration 

장점
- 더 간단하고 이해하기 쉽다.

단점

- 파일로 적용할때에만 동작한다. 디렉토리는 불가능.

- 실행중인 object 를 update 하기 위해서는 설정파일에 반영을 해야 한다. 



Declarative object configuration

- 모든 설정 파일들은 디렉토리 안에 들어있고 오브젝트를 생성하거나 패치 한다.


ex)

kubectl apply -f configs/


Declarative object configuration vs Imperative object configuration

장점

- 실행중인 오브젝트 직접 적용한 변경사항을 설정파일에 merge 하지 않더라도 유지된다.(???)


단점

- 디버깅 하기 어렵고 예상한 결과가 아닐 경우 이해하기 어렵다.

- diffs 를 사용한 부분 업데이트는 복잡한 병합과 패치를 만들게 된다.


Imperative commands 나  Imperative object configuration 는 이해가 되는데  Declarative object configuration 은 약간 이해가 안된다. 


https://kubernetes.io/docs/concepts/overview/object-management-kubectl/declarative-config/


여기 있는 샘플을 가지고 확인해보자.


sample_deployment.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  minReadySeconds: 5
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
cs



Create : kubectl apply -f sample_deployment.yaml 

Live configuration : kubectl get -f sample_deployment.yaml -o yaml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
kind: Deployment
metadata:
  annotations:
    # ...
    # This is the json representation of simple_deployment.yaml
    # It was written by kubectl apply when the object was created
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"apps/v1","kind":"Deployment",
      "metadata":{"annotations":{},"name":"nginx-deployment","namespace":"default"},
      "spec":{"minReadySeconds":5,"selector":{"matchLabels":{"app":nginx}},"template":{"metadata":{"labels":{"app":"nginx"}},
      "spec":{"containers":[{"image":"nginx:1.7.9","name":"nginx",
      "ports":[{"containerPort":80}]}]}}}}
  # ...
spec:
  # ...
  minReadySeconds: 5
cs


kubectl.kubernetes.io/last-applied-configuration 어노테이션에 보면 sample_deployment.yaml  에 적용한 내용들이 나와있다. 


다시 아래와 같이 명령어를 실행해보고 확인해보자.


kubectl scale deployment/nginx-deployment --replicas=2

Live configuration : kubectl get -f sample_deployment.yaml -o yaml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    # ...
    # note that the annotation does not contain replicas
    # because it was not updated through apply
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"apps/v1","kind":"Deployment",
      "metadata":{"annotations":{},"name":"nginx-deployment","namespace":"default"},
      "spec":{"minReadySeconds":5,"selector":{"matchLabels":{"app":nginx}},"template":{"metadata":{"labels":{"app":"nginx"}},
      "spec":{"containers":[{"image":"nginx:1.7.9","name":"nginx",
      "ports":[{"containerPort":80}]}]}}}}
  # ...
spec:
  replicas: 2 # written by scale
  # ...
  minReadySeconds: 5
cs


이 경우에는 apply를 하지 않았기 때문에 kubectl.kubernetes.io/last-applied-configuration 어노테이션에 포함되지 않았다.


sample_deployment.yaml 파일을 수정해보자. 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.11.9 # update the image
        ports:
        - containerPort: 80
cs


nginx image 버전이 1.7.9 에서 1.11.9 로 변경 되었다.


Create : kubectl apply -f sample_deployment.yaml 

Live configuration : kubectl get -f sample_deployment.yaml -o yaml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    # ...
    # The annotation contains the updated image to nginx 1.11.9,
    # but does not contain the updated replicas to 2
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"apps/v1","kind":"Deployment",
      "metadata":{"annotations":{},"name":"nginx-deployment","namespace":"default"},
      "spec":{"selector":{"matchLabels":{"app":nginx}},"template":{"metadata":{"labels":{"app":"nginx"}},
      "spec":{"containers":[{"image":"nginx:1.11.9","name":"nginx",
      "ports":[{"containerPort":80}]}]}}}}
    # ...
spec:
  replicas: 2 # Set by `kubectl scale`.  Ignored by `kubectl apply`.
  # minReadySeconds cleared by `kubectl apply`
  # ...
  selector:
    matchLabels:
      # ...
      app: nginx
  template:
    metadata:
      # ...
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.11.9 # Set by `kubectl apply`
cs


확인을 해보면 apply 로 적용한 nginx 버전은 kubectl.kubernetes.io/last-applied-configuration 어노테이션에 포함 되어있다. 하지만 replicas 는 포함되지 않았다.


Warning: Mixing kubectl apply with the imperative object configuration commands create and replace is not supported. This is because create and replace do not retain the kubectl.kubernetes.io/last-applied-configuration that kubectl apply uses to compute updates


그리고 위와 같은 주의 사항도 있다. apply 는 create 나 replace 를 지원하지 않는다는 거다. 이유는 create 나 replace 는 kubectl.kubernetes.io/last-applied-configuration 어노테이션을 유지 하지 않기 때문이라고 한다. 



apply 와 create 의 차이점을 찾아보다가 여기까지 오게 되었다. 결과적으로 가장 큰 차이점은 apply 를 할 경우에는 기존 설정에 대한 정보를 가지고 있다는 점인것 같다. 


apply 이외에도 다른 명령어들이 있지만 우선은 이것만 이해하는걸로 하자.





728x90
반응형
반응형

~ : user 홈디렉토리

. : 히든 파일


alias pd="pwd"

현재 session 에 pd 를 입력할 경우 pwd 로 인식한다.


export USER="kim"

환경변수 USER에 kim 을 바인딩한다.

echo $USER 하면 kim 나옴


export PS1=">>" 

마크업 스타일


728x90
반응형

'Development > Linux' 카테고리의 다른 글

openSSH 서버 활용하기  (0) 2017.04.18
우분투 리눅스 설치 삽질기!  (3) 2017.04.17
sed 명령어  (0) 2016.01.12
[Unix]tar 명령어  (0) 2012.11.12
[Unix]vi 편집기  (0) 2012.04.20
반응형

- chmod : 권한 변경
chmod 8진수 표기 filename
u:사용자 허가권        g:그룹 허가권,     o:타 사용자 허가권,     a:모두
+ : 허가권 추가        - : 허가권 삭제        = : 허가권 절대적 할당
r:읽기                     w:쓰기     x:실행

- chown : 파일 소유자 변경
chown user_id filename

- touch : 파일 날짜 및 시간을 현재시간으로 변경
touch filename

- mv : 파일을 이동하거나 이름변경
mv sourcefile targetfile

-cp :파일 복사
cp[option] sourcefile targetfile
option 
    -i : 이미 존재할경우 덮어쓸지 물어봄
    -p : 이미 존재할 경우 기존 파일의 속성 시간 그대로 유지
    -r : 하부 디렉토리 까지 복사

-rm : 파일 삭제
rm[option] filename
    -i : w 권한 없을때 삭제할것인지 물어봄
    -f : w 권한 없어도 삭제
    -r : 하부 디렉토리 까지 삭제

-find : 파일 찾기
find starting-dir criteria acitons
ex>find /test -name *.txt -print

-head : 파일 내용 보기(1부터 n줄까지) / tail : 파일 내용보기 (끝에서 n까지)
head [-n] filename

- cat  : 파일 전체 내용 출력
cat [option] filename 

- more : 파일 내용을 한 화면씩
more filename

- wc : line 수, word 수, 문자수에 대한 정보출력
wc [option] filename
    -l : 라인수 
    -w : word 수
    -c : 문자수

-grep : 파일내 특정 패턴 검색하여 그 행을 화면에 출력
grep[option] 패턴 filename
    -i : 대소문자 무시하고 출력
    -l : 패턴에서 일치하는 파일명만 출력
    -c : 일치하는 패턴을 포함한 라인수
    -n : 라인번호 붙여서 출력

-tr : 지정한 데이터로 변환해서 출력
tr 원래문자 바꿀문자 < filename

-cmp : 두개 파일 틀린위치 출력
cmp filename1 filename2

-pcat : pack 명령으로 압축된 파일을 풀지않고 내용을 볼수 있게 한다.
pcat filename.z

728x90
반응형

'Development > Linux' 카테고리의 다른 글

Command Line 명령어  (0) 2016.01.14
sed 명령어  (0) 2016.01.12
[Unix]tar 명령어  (0) 2012.11.12
[Unix]vi 편집기  (0) 2012.04.20
[Unix]Unix 구조  (0) 2012.04.17

+ Recent posts