[Linux] /etc/nsswitch.conf, /etc/resolv.conf

prana·2025년 2월 23일
1

ORACLE

목록 보기
83/96

/etc/nsswitch.conf

  • 리눅스 시스템에서 Name Service 설정을 담당하는 파일이다.
  • 이 파일은 인증 정보, 네트워크 호스트 이름, 그룹 정보 등과 같은 이름 관련 데이터가 어디에서 검색될지를 정의한다.

역할

  • Name Service Switch
  • 시스템이 다음과 같은 정보를 어디에서 찾을지 정의
    • 사용자 계정 정보(passwd)
    • 그룹 정보(group)
    • 호스트 이름(hosts)
    • 네트워크 정보(networks)
    • 서비스(services)
    • ex) 사용자가 시스템에 로그인할 때, 시스템은 passwd 항목을 참조하여 사용자 계정 정보를 검색한다.
[root@cowjin1 etc]# cat nsswitch.conf
# Generated by authselect on Sun Feb  9 18:46:51 2025
# Do not modify this file manually.

# If you want to make changes to nsswitch.conf please modify
# /etc/authselect/user-nsswitch.conf and run 'authselect apply-changes'.
#
# Note that your changes may not be applied as they may be
# overwritten by selected profile. Maps set in the authselect
# profile takes always precedence and overwrites the same maps
# set in the user file. Only maps that are not set by the profile
# are applied from the user file.
#
# For example, if the profile sets:
#     passwd: sss files
# and /etc/authselect/user-nsswitch.conf contains:
#     passwd: files
#     hosts: files dns
# the resulting generated nsswitch.conf will be:
#     passwd: sss files # from profile
#     hosts: files dns  # from user file

passwd:     files sss systemd
group:      files sss systemd
netgroup:   sss files
automount:  sss files
services:   sss files

# Included from /etc/authselect/user-nsswitch.conf

#
# /etc/nsswitch.conf
#
# Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# Valid databases are: aliases, ethers, group, gshadow, hosts,
# initgroups, netgroup, networks, passwd, protocols, publickey,
# rpc, services, and shadow.
#
# Valid service provider entries include (in alphabetical order):
#
#       compat                  Use /etc files plus *_compat pseudo-db
#       db                      Use the pre-processed /var/db files
#       dns                     Use DNS (Domain Name Service)
#       files                   Use the local files in /etc 👈 /etc/passwd 파일에서 먼저 검색
#       hesiod                  Use Hesiod (DNS) for user lookups
#       nis                     Use NIS (NIS version 2), also called YP
#       nisplus                 Use NIS+ (NIS version 3)
#
# See `info libc 'NSS Basics'` for more information.
#
# Commonly used alternative service providers (may need installation):
#
#       ldap                    Use LDAP directory server
#       myhostname              Use systemd host names
#       mymachines              Use systemd machine names
#       mdns*, mdns*_minimal    Use Avahi mDNS/DNS-SD
#       resolve                 Use systemd resolved resolver
#       sss                     Use System Security Services Daemon (sssd)👈SSSD을 사용해 LDAP이나 Active Directory에서 검색
#       systemd                 Use systemd for dynamic user option
#       winbind                 Use Samba winbind support
#       wins                    Use Samba wins support
#       wrapper                 Use wrapper module for testing
#
# Notes:
#
#
# WARNING: Running nscd with a secondary caching service like sssd may
#          lead to unexpected behaviour, especially with how long
#          entries are cached.
#
# Installation instructions:
#
# To use 'db', install the appropriate package(s) (provide 'makedb' and
# libnss_db.so.*), and place the 'db' in front of 'files' for entries
# you want to be looked up first in the databases, like this:
#
# passwd:    db files
# shadow:    db files
# group:     db files 
✅ passwd, shadow, group
file sss: /etc/passwd, /etc/shadow, /etc/group 파일과 SSSD를 사용해 사용자와 그룹 정보를 확인


# In order of likelihood of use to accelerate lookup.
shadow:     files sss
hosts:      files dns myhostname 
✅ hosts: 호스트 이름 해석을 위해 /etc/hosts 파일, DNS, 그리고 systemd의 호스트 이름 확인을 사용
- /etc/hosts 파일에 Public IP, Private IP, VIP 정보를 기록하고, DNS 서버를 통해 추가 확인


aliases:    files
ethers:     files
gshadow:    files
# Allow initgroups to default to the setting for group.
# initgroups: files
networks:   files dns
✅ networks: 네트워크 정보 해석 시 /etc/networks파일과 DNS 서버를 사용
protocols:  files
publickey:  files
rpc:        files

Oracle RAC에서 nsswitch.conf역할

1. 호스트 이름 해석(hosts)

  • 각 노드 간 Public IP, Private IP, VIP가 정확하게 해석되어야 클러스터 통신이 원활하다.
  • hosts: file dns 설정을 통해 /etc/hosts 파일 및 DNS 서버에서 호스트 이름을 해석한다.
    2. 사용자 계정 및 그룹 관리
  • RAC에서는 모든 노드에서 동일한 oracle 사용자 계정 및 그룹 정보가 필요
  • LDAP/AD연동
  • NIS/NFS 환경
  • 호스트 이름 해석: Oracle Listener 또는 클러스터 환경에서 호스트 이름을 IP로 해석할 때
  • RAC 환경: Oracle RAC에서 호스트 이름 및 네트워크 설정이 중요하기 때문에, 정확한 이름 해석을 위해 필요
  • DNS 설정: hosts: file dns myhostname 설정 시, RAC 환경에서 호스트이름을 DNS로 해석한다.

/etc/hosts 예시

# Public IP
# 
192.168.0.101  node1-public
192.168.0.102  node2-public

# Private IP (Interconnect)
10.0.0.101    node1-priv
10.0.0.102    node2-priv

# Virtual IP (VIP)
# Virtual IP (VIP): 클러스터 노드 장애 시 Failover를 위해 사용하는 가상 IP.
192.168.0.111  node1-vip
192.168.0.112  node2-vip

# SCAN IP (Single Client Access Name)
192.168.0.121  rac-scan
192.168.0.122  rac-scan
192.168.0.123  rac-scan
## SCAN IP: 클러스터의 접속 주소. 3개의 IP를 DNS 라운드로빈 방식으로 설정.

RAC 노드 간 통신/ VIP 장애 복구 시나리오

1. 노드 간 통신

  • nsswitch.conf에서 hosts: files dns 설정으로 /etc/hosts를 우선 검색.
  • /etc/hosts에 Public, Private, VIP 설정 후 ping node2-priv 명령어 실행.
  • Private IP가 정상 응답 시, 클러스터 통신 원활.
    2. VIP 장애 복구
  • Node1 장애 시 Node2가 Node1-VIP를 인계.
  • hosts: files dns 설정으로 DNS에서 VIP 상태 확인.
  • VIP가 Node2로 이동했음을 확인하고, 클라이언트는 끊김 없이 연결 유지.

요약

  • nsswitch.conf는 사용자 인증, 네트워크 해석, 서비스 검색에 중요한 역할
  • Oracle 환경에서 LDAP/AD와 연동, RAC 구성 시 매우 중요
  • hosts 항목이 /etc/hosts와 dns를 순서대로 조회하도록 설정.

/etc/resolv.conf

  • DNS 서버 설정 파일이다.
  • 이 파일은 도메인 이름을 IP 주소로 변환하기 위해 사용하는 DNS 서버의 주소를 지정한다.
  • Oracel RAC환경에서, SCAN IP와 호스트 이름 해석에 중요한 역할을 한다.

개요

  • 네트워크 이름 해석을 위해 DNS 서버 목록을 정의한다.
  • 도메인 이름을 IP주소로 변환하거나, 그 반대 작업을 수행한다.
  • /etc/nsswitch.conf에서 hosts: files dns설정 시, DNS 서버가 /etc/resolv.conf에 정의된 순서대로 조회한다.
[root@cowjin1 etc]# cat /etc/resolv.conf
# Generated by NetworkManager 👈 NetworkManager에 의해 자동으로 생성된다.
nameserver 8.8.8.8
nameserver 210.220.163.82 👈 한국인터넷진흥원(KISA) DNS서버
nameserver 219.250.36.130 👈 한국통신(KT) DNS서버
  • nameserver: DNS 서버의 IP주소를 나타낸다. 최대 3개까지 설정 가능하며, 순서대로 조회한다.
    • 첫 번째 DNS 서버가 응답하지 않으면 두 번째로 넘어가고, ~ 세번째로 넘어간다.

Oracle RAC에서의 역할

  • 노드 간 통신과 SCAN IP 해석에서 정확한 이름 해석이 중요하다.
  • SCAN IP(Single Client Access Name)은 라운드 로빈 방식으로, 여러 IP 주소를 제공하여 부하 분산 및 고가용성을 제공한다.
  • /etc/resolv.conf에 정의된 DNS 서버가 SCAN IP를 올바르게 해석해야 클러스터 노드 간 통신과 클라이언트 연결이 정상적으로 작동한다.

추가로 찾아본 것

LDAP(Lightweight Direcotry Access Protocol)

  • 디렉터리 서비스에 접근하고 정보를 검색하거나 수정하기 위해 사용되는 프로토콜

주요 기능

  • 사용자 인증: 사용자 로그인 시 아이디와 비밀번호를 중앙 서버에서 인증
  • 디렉터리 정보 관리: 사용자 정보, 그룹 정보, 이메일 주소, 전화번호 등 중앙에서 관리
  • 권한 관리: 사용자 및 그룹에 따라 접근 권한 부여

주요 특징

  • 계층적 구조
  • 표준화된 프로토콜
  • 속도와 효율성

사용 예시

  • Active Directory: 윈도우 서버에서 사용하는 디렉터리 서비스로 LDAP 사용
  • Sigle Sign-On (SSO): 한 번 로그인으로 여러 시스템에 접근할 수 있게 하는 인증 시스템
  • 이메일 서버

작동 방식

    1. 클라이언트가 서버에 요청 (사용자 인증 요청)
    1. LDAP 서버가 요청 처리: DN(고유 식별자, Distinguished Name)과 비밀번호 확인
    1. 응답 반환: 인증 성공 또는 실패 결과를 클라이언트에 반환

0개의 댓글