Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, October 27, 2023

Postgresql이 갑자기 안될 때

 

Postgresql이 갑자기 안될 때

아래와 같은 에러를 뿜으며 postgresql이 죽는다. postgresql의 로그는 우분투 리눅스의 경우 /var/log/postgresql/postgresql-버전번호-main.log 에서 볼 수 있다.

2019-00-00 00:00:00 KST [1469-2] LOG: received fast shutdown request
2019-00-00 00:00:00 KST [1469-3] LOG: aborting any active transactions
2019-00-00 00:00:00 KST [1481-2] LOG: autovacuum launcher shutting down
2019-00-00 00:00:00 KST [1478-1] LOG: shutting down
2019-00-00 00:00:00 KST [1478-2] LOG: database system is shut down
2019-00-00 00:00:00 KST [27487-1] FATAL: could not map anonymous shared memory: 메모리를 할당할 수 없습니다
2019-00-00 00:00:00 KST [27487-2] HINT: This error usually means that PostgreSQL’s request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 148488192 bytes), reduce PostgreSQL’s shared memory usage, perhaps by reducing shared_buffers or max_connections.
2019-00-00 00:00:00 KST [1782-1] LOG: database system was shut down at 2019-00-00 00:00:00 KST


원인

아래 에러 메시지에 원인과 해결책이 있다.

2019-00-00 00:00:00 KST [27487-2] HINT: This error usually means that PostgreSQL’s request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 148488192 bytes), reduce PostgreSQL’s shared memory usage, perhaps by reducing shared_buffers or max_connections.

메모리가 부족해서 서비스가 죽었다는 말이다.


해결방법

  1. free -m 명령으로 현재 메모리 상태를 본다. (뒤에 -m 옵션은 메가바이트 단위로 보겠다는 뜻이다.)

  2. /etc/postgresql/버전번호/main/postgresql.conf 설정 파일에서 약 113번 째 줄부터 메모리 관련 설정이 있다. 여기에서 shared_buffters = 128MB이런 식으로 되어 있는 값을 바꿔주면 된다. 만약 free -m으로 봤는데 buff/cache메모리가 110 이런 식으로 써져있으면 이 값보다 좀 넉넉하게 작게 설정해준다. (물론 자신이 운영하는 서비스 특성에 따라 다를 수 있다.) 나의 경우 buff/cache가 103이었고, postgresql 설정에서 shared_buffers 값을 60MB로 바꿔주고 postgresql 서비스를 재시작해주었다.


AWS 라이트셰일 $3.5/m 서비스의 메모리가 512MB인데 이렇게 메모리 오류가 나는 경우는 저사양의 서버에 기본값으로 서비스를 올려서 그런 경우가 종종 있으니 참고.


Thursday, October 26, 2023

posgresql database system is shut down 문제 해결

2023-10-26 00:40:27.923 KST [728] LOG:  could not parse file name "pg_logical/snapshots/memory"

2023-10-26 00:40:27.923 KST [728] LOG:  could not parse file name "pg_logical/snapshots/prememory"

2023-10-26 00:40:27.942 KST [678] LOG:  database system is shut down


database system is shut down 문제 해결


/data/pg_logical/replorigin_checkpoint 파일을 삭제



https://database.sarang.net/?inc=read&aid=10299&criteria=pgsql&subcrit=qna&id=0&limit=20&keyword=&page=1


클라우드 centos posgresql-12 버전으로 개발 중입니다.


백업설정 등을 하지 않고 안이하게 업무를 하다.

며칠 전 delete 명령 수행한 것을 복구하려고..

클라우드 서비스에 이전 백업본(시스템) 으로 복구를 요청했습니다.


그런데. 복구 후 postgresql-12 서비스가 올라오지 않아 로그를 보니 아래와 같은 메시지가 나오고 실패하고 있습니다.

==============

2021-11-21 00:40:18.337 KST [31681] 로그:  데이터베이스 시스템이 비정상적으로 종료되었음; 마지막 운영시간: 2021-11-15 04:21:41 KST

2021-11-21 00:40:18.781 KST [31681] 손상:  복제 체크포인트의 잘못된 매직 번호: 691087444, 기대값: 307747550

2021-11-21 00:40:18.782 KST [31677] 로그:  시작 프로세스 (PID 31681) 프로세스가 6번 시그널을 받아 종료됨: 중지됨

==============


구글링 중 resetwal 을 해 보라는 의견이 있어 수행했으나 변화는 없었고.

pg_wal 디렉토리에 원래 2개 파일이 있었던것이 끝번호가 증가한 하나의 파일만 생겼습니다.

(혹시 몰라 기존 pg_wal 디렉토리는 백업해 두었습니다.)


다른서버에 유사한 환경을 만들어 data/base/ 내 디렉토리들을 옯겨봤으나 역시 되지 않았습니다.

http://piccom.egloos.com/3281875 게시글을 참조했으나 버전의 차이가 있어서인지(/global/pg_database 파일이 12버전에는 없습니다.) 되지 않습니다.


1) 위 오류를 해결하거나 회피하여 디비를 가동하는 방법이 있을지요.

2) 유사한 환경(다른 서버)에 옮겨 복구하는 방법이 있을지요.


백업설정 없이 안이하게 업무를 한 것이 잘못입니다.

경험 있으신 분들의 귀한 의견 부탁드리겠습니다.

감사합니다.

이 글에 대한 댓글이 총 1건 있습니다.

[자답]


1)  /data/pg_logical/replorigin_checkpoint 파일을 백업하고 지웁니다.(mv 로 이동시켰습니다.)


2) 서비스를 시작했습니다. systemctl start postgresql-12


구글링을 좀 더 하던 중 아래 링크에서 설명한 내용입니다.

감사합니다. 백업인으로 살겠습니다. ㅠ


https://community.bmc.com/s/article/PostgreSQL-database-from-Control-M-Server-cannot-start-with-error-replication-checkpoint-has-wrong-magic-number-xxxxxx-instead-of-yyyyyyy-in-postgresql-logs

우분투 gui 환경 지우기 / 우분투 gui 없애기

 

우분투 gui 환경 지우기 / 우분투 gui 없애기 

 

1. 우분투 데스크탑 환경 제거

sudo apt-get remove ubuntu-desktop

2. GNOME 데스크톱 매니저 제거

sudo apt-get remove gdm3

3. 그래픽 드라이버 제거

sudo apt-get remove xserver-xorg-video-*

4. 그래픽 서버 제거

sudo apt-get remove xserver-xorg-core

5. autoremove

sudo apt-get autoremove

6. 재부팅

sudo reboot

 

Tuesday, October 24, 2023

2023 AWS PostgreSQL could not connect to server: Connection refused (0x0000274D/10061) PostgreSQL

 

systemctl status postgresql.service 실행시


아래처럼 실행되고 있어야 되는데. 죽어있는 경우.





sudo service postgresql restart 로 실행시키고

접속해본다.

Saturday, June 18, 2016

[우분투] GUI화면에서 메뉴바 사라졌을 경우 해결책


ALT + CTRL + T 를 입력하여 터미널을 띄운다.

터미널에서 ccsm 실행

$ccsm 실행

없을 경우 설치

$apt-get install compoziconfig-settings-manager

설치후 컴피즈 설정 관리자(ccsm)를 실행

실행후 Ubuntu Unity Plugin을 설치하면 나온다.

Sunday, June 12, 2016

[우분투] GUI에서 sh 파일을 더블클릭으로 실행하기

#!/bin/sh 로 시작하는  .sh파일이나
#!/usr/bin/env python 로 시작하는 .py파일 등을

우분투 GUI에서 마우스 더블클릭으로 실행시킬려면

dconf-editor를 설치하여 설정을 변경하면 됩니다.

우분투소프트웨어 센터에서 검색후 설치하거나

콘솔에서 아래를 실행하면 됩니다.

sudo apt-get install dconf-tools 

설정방법은 dconf-editor 실행

org > gnome > nautilus > preferences 항목에서

exeutable-text-activation 항목의 display를 launch로 변경하면 됩니다.


Friday, June 3, 2016

[우분투] 탐색기(파일,Nautilus)에서 책갈피 추가하기

탐색기(파일,Nautilus) 을 실행한 후에
추가하고 싶은 폴더에 들어가서 메뉴 > 책갈피 > 이 위치에 책갈피 추가 선택
혹은 Ctrl+D 



Tuesday, May 3, 2016

[우분투]현재 위치를 터미널에서 열기


#sudo apt-get install nautilus-open-terminal nautilus-actions

설치후 로그아웃 로그인.