Unix Init Process: Systemd

숲사람·2022년 3월 24일
0

UNIX & C

목록 보기
5/12

Init precess. 커널이 부팅완료 된 뒤에 첫번째 pid 프로세스 부터 순차적으로 실행되는 서비스 관리 시스템. 서비스는 운영체제에서 부팅중 실행되어 백그라운드에서 계속 동작하는 프로그램(프로세스)을 말한다. 시스템에서 필요한 서비스들은 굳이 부팅이 완료된 이후 실행할 필요가 없기때문에 init 프로세스에서 pid1 init프로그램부터 시작해 하나하나 순차적으로 실행한다.

Service Control Manager - Used by Microsoft Windows
launchd - Used by Apple macOS
systemd - Used by many Linux distributions
Upstart - Used by Google Chrome OS
Service Management Facility - Used by illumos distributions and Oracle Solaris
Android init - Used by Google Android
sysvinit - Used by older Unix-like operating systems
rc.d or rcorder-based init - Used by BSD operating systems
cygserver - Used by Cygwin
runit - Used by Void
OpenRC - Used by Gentoo
The GNU Shepherd - Used by the Guix System Distribution and GNU Hurd but designed to work on every POSIX-like system where Guile is available

systemd

System V init 시스템에서는 init이 과거 pid 1이었다면. 최신 배포판은 systemd 가 pid 1 이다.
systemd 는 부팅시 프로그램을 병렬로 실행시켜 부팅이 더 빠르다. 여러가지 서비스를 제공한다.
사용 방법은 systemctrl 사용

  • 서비스 파일 및 디렉터리구조:
    /etc/systemd/ : configure
    /lib/systemd/ : 바이너리 실행파일이 존재
    /lib/systemd/system/ : Service, Target이 위치

  • 실행 방법

systemctl start | stop | restart [unit name] 

기타 옵션

  • 부팅시간 확인
$ systemd-analyze 
Startup finished in 3.503s (kernel) + 43.131s (userspace) = 46.635s
$ systemd-analyze blame
         31.977s apt-daily.service
          9.106s NetworkManager-wait-online.service
          3.172s apt-daily-upgrade.service
          1.974s docker.service

System V init

수 십년이 지난 너무 오래된 UNIX 부팅 시스템. 그래서 최근 systemd로 많이 대체 되었다.

  • 디렉터리 구조
    /etc/rc.d/{name}

  • 실행 방법

 $ service {name} status

소스코드 다운로드 : http://download.savannah.gnu.org/releases/sysvinit/

upstart

과거 우분투 등에서 사용하던 시스템. UNIX의 system V init과 호환 된다. 더이상 개발이 진행되지 않고 유지보수만 이루어지고 있다.

  • 서비스파일:
    /etc/init.d/{name},
    /etc/rc{runlevel}.d/[S|K]{seq}{name}

    rc는 링크파일, runlevel[2,3,4,5]는 S로 시작. [0,1,6]은 K로 시작, seq는 수행 우선순서

  • 실행 방법:

$ status {name}
$ service {name} status (sys V호환)

참고

profile
기록 & 정리 아카이브 용도 (보다 완성된 글은 http://soopsaram.com/documentudy)

0개의 댓글