Mac 에 PostgreSQL 설치 방법을 정리해 보려고 한다.
brew 가 설치 되어있다는 가정하에
# Step 1
brew install postgresql
limjian@Jians-MacBook-Pro-13 ~ % brew install postgresql
...
...
To restart postgresql after an upgrade:
brew services restart postgresql
Or, if you don't want/need a background service you can just run:
/usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres
# Step 2
pg_ctl start -D /usr/local/var/postgres && brew services start postgresql
(pg_ctl 명령은 PostgreSQL 데이터베이스 서버 제반 작업을 수행 pg_ctl document)
limjian@Jians-MacBook-Pro-13 ~ % pg_ctl start -D /usr/local/var/postgres && brew services start postgresql
waiting for server to start....2022-01-30 01:32:21.669 KST [48164] LOG: starting PostgreSQL 14.1 on x86_64-apple-darwin21.1.0, compiled by Apple clang version 13.0.0 (clang-1300.0.29.3), 64-bit
2022-01-30 01:32:21.670 KST [48164] LOG: listening on IPv6 address "::1", port 5432
2022-01-30 01:32:21.670 KST [48164] LOG: listening on IPv4 address "127.0.0.1", port 5432
2022-01-30 01:32:21.671 KST [48164] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-01-30 01:32:21.674 KST [48165] LOG: database system was shut down at 2022-01-30 01:32:04 KST
2022-01-30 01:32:21.677 KST [48164] LOG: database system is ready to accept connections
done
server started
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
# Step 3
postgres --version
(postgres -V)
잘 설치 되었는지 확인
limjian@Jians-MacBook-Pro-13 ~ % postgres --version
postgres (PostgreSQL) 14.1
이렇게 하면 postgreSQL 이 mac 에 잘 설치 된거다.
프로세스 상태 확인을 위한 명령어 (Process Status)
# ps -ef | grep "postgres"
limjian@Jians-MacBook-Pro-13 ~ % ps -ef | grep "postgres"
501 48164 1 0 1:32AM ?? 0:00.03 /usr/local/Cellar/postgresql/14.1_1/bin/postgres -D /usr/local/var/postgres
501 48166 48164 0 1:32AM ?? 0:00.01 postgres: checkpointer
501 48167 48164 0 1:32AM ?? 0:00.04 postgres: background writer
501 48168 48164 0 1:32AM ?? 0:00.01 postgres: walwriter
501 48169 48164 0 1:32AM ?? 0:00.01 postgres: autovacuum launcher
501 48170 48164 0 1:32AM ?? 0:00.01 postgres: stats collector
501 48171 48164 0 1:32AM ?? 0:00.00 postgres: logical replication launcher
501 48787 25522 0 1:39AM ttys000 0:00.00 grep postgres
위에서 서비스를 start 해주니까 backgroud 에서 계속 도는 상태가 된다.
나중에 설정을 위해 postgreSQL 을 사용할때 다시 start 해 주면 된다.
그래서 지금은 stop
# pg_ctl stop -D /usr/local/var/postgres && brew services stop postgresql
limjian@Jians-MacBook-Pro-13 ~ % pg_ctl stop -D /usr/local/var/postgres && brew services stop postgresql
waiting for server to shut down....2022-01-30 01:42:08.069 KST [48164] LOG: received fast shutdown request
2022-01-30 01:42:08.069 KST [48164] LOG: aborting any active transactions
2022-01-30 01:42:08.071 KST [48164] LOG: background worker "logical replication launcher" (PID 48171) exited with exit code 1
2022-01-30 01:42:08.071 KST [48166] LOG: shutting down
2022-01-30 01:42:08.079 KST [48164] LOG: database system is shut down
done
server stopped
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
limjian@Jians-MacBook-Pro-13 ~ % ps -ef | grep "postgres"
501 49160 25522 0 1:42AM ttys000 0:00.01 grep postgres
'Database > PostgreSQL' 카테고리의 다른 글
[PostgreSQL] cache clear (0) | 2022.02.09 |
---|---|
[PostgreSQL] Uninstall for Mac (0) | 2022.01.30 |
[PostgreSQL] 현재 연결 수 (pg_stat_activity) (1) | 2021.12.11 |
[PostgreSQL] Lock query 확인 (0) | 2021.12.11 |
[PostgreSQL] Log (0) | 2021.12.05 |