|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
sudo journalctl -u apache2 -b -o short-monotonic --no-pager systemctl show apache2 -p TimeoutStartUSec [ 22.211390] ubuntu systemd[1]: Starting apache2.service - The Apache HTTP Server... [ 112.271786] ubuntu systemd[1]: apache2.service: start operation timed out. Terminating. [ 112.273757] ubuntu systemd[1]: apache2.service: Killing process 1111 (apache2) with signal SIGKILL. [ 112.279341] ubuntu systemd[1]: apache2.service: Failed with result 'timeout'. [ 112.280191] ubuntu systemd[1]: Failed to start apache2.service - The Apache HTTP Server. [ 2160.731494] ubuntu systemd[1]: Starting apache2.service - The Apache HTTP Server... [ 2160.857537] ubuntu apachectl[2103]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message [ 2160.904833] ubuntu systemd[1]: Started apache2.service - The Apache HTTP Server. TimeoutStartUSec=1min 30s |
부팅 시 Apache2가 90초(1분 30초) 동안 대기하다가 타임아웃으로 실패한 후, 나중에 수동(또는 재시도)으로 실행했을 때는 0.17초 만에 정상 실행된 상황입니다.
이 로그 패턴은 부팅 극초기에 네트워크나 필수 리소스가 아직 준비되지 않은 상태에서 Apache가 실행을 시도했기 때문에 발생합니다.
주요 원인 3가지
- DNS / Hostname 확인 병목 (가장 유력)
- 네트워크 대기 설정 누락 (
Type=notify/ systemd 의존성) - SSL/TLS 엔트로피(Entropy) 부족
해결 방법 (순서대로 진행)
1
1. /etc/hosts 파일에 Hostname 등록
DNS 타임아웃 방지
1.1. /etc/hosts 파일에 Hostname 등록:DNS 타임아웃 방지.
Apache가 로컬 호스트명을 즉시 찾을 수 있도록 설정합니다.
- 터미널에서 호스트명을 확인합니다.
Bash
hostname
/etc/hosts파일을 엽니다.
Bash
sudo nano /etc/hosts
127.0.0.1및127.0.1.1라인에 확인한 호스트명을 명시해 줍니다.
Plaintext
127.0.0.1 localhost
127.0.1.1 ubuntu # 본인의 hostname 입력
- Apache 설정 파일(
/etc/apache2/apache2.conf) 맨 밑에 아래 줄을 추가하여 경고 메시지(AH00558)도 함께 해결합니다.
Apache
ServerName localhost
확인 방법:
sudo apache2ctl configtest실행 시Syntax OK가 나오는지 확인합니다.
2
2. systemd 서비스 네트워크 대기 설정 추가
부팅 순서 동기화
2.2. systemd 서비스 네트워크 대기 설정 추가:부팅 순서 동기화.
네트워크가 완전하게 활성화된 이후에만 Apache가 시작되도록 서비스 설정을 오버라이드합니다.
- 서비스 드롭인(Drop-in) 설정 에디터를 엽니다.
Bash
sudo systemctl edit apache2
- 열린 파일에 다음 내용을 입력하고 저장합니다.
Ini, TOML
[Unit]
After=network-online.target
Wants=network-online.target
확인 방법:
sudo systemctl daemon-reload실행 후 오류 없이 적용되는지 확인합니다.
3
3. 재부팅 후 타임아웃 발생 여부 검증
결과 확인
3.3. 재부팅 후 타임아웃 발생 여부 검증:결과 확인.
시스템을 재부팅하여 부팅 과정에서 Apache가 대기 없이 바로 시작되는지 확인합니다.
- 시스템을 재부팅합니다.
Bash
sudo reboot
- 부팅 완료 후 Apache 부팅 로그 시간을 확인합니다.
Bash
sudo journalctl -u apache2 -b -o short-monotonic --no-pager
확인 방법: Starting 이후 Failed나 90초 대기 없이 1~2초 내에
Started apache2.service가 출력되면 정상 해결된 것입니다.
|
1 2 3 4 5 6 7 |
sudo journalctl -u apache2 -b -o short-monotonic --no-pager [ 22.151850] ubuntu systemd[1]: Starting apache2.service - The Apache HTTP Server... [ 35.447946] ubuntu systemd[1]: Started apache2.service - The Apache HTTP Server. |
Apache2 서비스는 커널 부팅 후 35.45초 시점에 완료되었으며, 실행을 시작하여 완료되기까지 총 13.30초가 걸렸습니다.
로그의 [-o short-monotonic] 표기는 시스템이 부팅된 순간(0초)을 기준으로 경과한 시간을 의미합니다.
- 시작 요청 시점: 부팅 후
22.151850초 - 시작 완료 시점: 부팅 후
35.447946초 - 총 소요 시간:
35.447946 - 22.151850 = 13.296096초 (약 13.3초)
