본문 바로가기
  • ▒ 네모의 쉽게 배우는 네트워크 | 개발 ▒
데이터베이스(PostgrSQL)/트러블슈팅

FATAL: unrecognized configuration parameter "unix_socket_directory" 오류 해결 방법

by 너l모 2021. 8. 9.
반응형

※ 업무하면서 습득한 내용들을 정리해 놓은 포스팅입니다 :P 추가로 궁금하신 점은 댓글로 남겨주시고 필요한 자료 있으면 요청주세요! 잘못된 내용이 있으면 고쳐주시면 감사하겠습니다. 자료 퍼가실 때는 출처 남겨주세요!


 ο 목차

     


    ※ 코드 보는 방법 참고

    ㅇ 달러 기호($)가 있는 경우 -> 리눅스 터미널에서 cli 명령어 입력

    ㅇ 샵 기호(#)가 있는 경우 -> root 계정으로 cli 명령어 입력


    1. 문제 사례

    PostgreSQL 데이터베이스 버전 노후로 pg_upgrade 실행 중 사전 check 단계에서 아래와 같은 오류 발생

     

    2. 오류 메세지 내용 상세 

    1) pg_upgrade_internal.log 오류 메시지


    connection to database failed: could not connect to server: No such file or directory
    Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.50432"?

     

    could not connect to source postmaster started with the command:
    "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data" -o "-p 50432 -b -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/tmp'" start Failure, exiting


    2) pg_upgrade_server.log 오류 메시지


    command: "/usr/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/pgsql/data" -o "-p 50432 -b  -c listen_addresses='' -c unix_socket_permissions=0700 -c unix_socket_directory='/tmp'" start >> "pg_upgrade_server.log" 2>&1
    waiting for server to start....FATAL:  unrecognized configuration parameter "unix_socket_directory"
     stopped waiting
    pg_ctl: could not start server
    Examine the log output.


    3. 문제 원인

    기존 postgresql 버전 conf 파일의 소켓 디렉토리("unix_socket_directory")와 최신 postgresql 버전 conf 파일의 소켓 디렉토리("unix_socket_directories")가 달라 pg_upgrade에서 이를 제대로 처리하지 못하고 오류를 발생시킴.

     

    4. 문제 해결 방법

    아래 사이트를 참고하여 문제 해결하였음

    https://dba.stackexchange.com/questions/50135/pg-upgrade-unrecognized-configuration-parameter-unix-socket-directory

     

    pg_upgrade unrecognized configuration parameter "unix_socket_directory"

    I'm trying to upgrade Postgresql from 9.2 to 9.3 in Fedora 18 using this command as the postgres user $ pg_upgrade -b /bin -B /usr/pgsql-9.3/bin -d /var/lib/pgsql/data -D /var/lib/pgsql/9.3/data/ ...

    dba.stackexchange.com

     

     

    (개요) 문제가 되는 pg_ctl 파일의 "unix_socket_directory" 변수를 "unix_socket_directories"로 변경하여 pg_upgrade 작업을 완료한 후, 다시 원복하여 문제 해결. 


    ** 아래 작업은 root 권한(sudo)로만 실행하는 경우 제대로 동작하지 않음. root 계정으로 접속한 후 단계 진행하기. **

    1) pg_ctl 파일 원본 백업

    # mv /usr/bin/pg_ctl{,-orig}

     

    2) pg_ctl 파일 새로 생성

    # echo '#!/bin/bash' > /usr/bin/pg_ctl

     

    3) 원본 파일에서 "unix_socket_directory" 를 "unix_socket_directories"로 변경하여 새로운 pg_ctl 파일 내용 추가 

    # echo '"$0"-orig "${@/unix_socket_directory/unix_socket_directories}"' >> /usr/bin/pg_ctl

     

    4) 새로 생성된 pg_ctl 파일에 실행 권한 추가

    # chmod +x /usr/bin/pg_ctl

     

    5) pg_upgrade 재실행

    6) pg_upgrade 작업이 끝난 후 원본 파일 원복시키기

    # mv -f /usr/bin/pg_ctl{-orig,}

     

     

    포스팅이 도움이 되시길 바랍니다.


    ※ 좋아요와 구독은 큰 힘이 됩니다 :P  감사합니다. 

     

     

    반응형

    댓글