[Infra - Synology NAS Docker] Ubuntu 22.04 - PostgreSQL 12 ์„ค์น˜

2022. 12. 18. 15:07ใ†System ์ž‘์—…์‹ค/DBMS

728x90
๋ฐ˜์‘ํ˜•





 

PostgreSQL 12 High Availability Cookbook Paperback

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

๐Ÿš€ Sysnology NAS

    ๐Ÿ”ฝ  Docker

        ๐Ÿ“ฆ PostgreSQL 12 ์„ค์น˜

์ตœ์ดˆ ์ฃผ๋‹ˆํ•˜๋ž‘์€ Sysnology NAS Docker ์•„๋ž˜์™€ ๊ฐ™์ด ์ž‘์—…์„ ํ•ด ์ค„๊ฑฐ์—์š”.

 

์ฃผ๋‹ˆํ•˜๋ž‘์€ Ubunt Docker์— PostgreSQL์„ ์„ค์น˜ํ•ด ๋ณด๋ ค๊ณ  ํ•ด์š”.





Container๊ฐ€ ๊ธฐ๋™ ๋˜์—ˆ๊ณ , ์œ„์™€ ๊ฐ™์ด root Password๋ฅผ ๋จผ์ € ๋ฐ”๊พธ์–ด ์ฃผ์—ˆ์–ด์š”.


apt-get update && apt-get upgrade -y


๊ทธ๋Ÿฐ ๋’ค ์œ„์™€ ๊ฐ™์ด System Update๋ฅผ ์ง„ํ–‰ํ•˜์—ฌ ๋ชจ๋“  Package๋ฅผ ์ตœ์‹ ํ™” ํ•˜์—ฌ ์ค„๊ฒŒ์š”.


๊ทธ๋Ÿฐ ๋’ค ํ•„์š”ํ•œ Package๋ฅผ ๋จผ์ € ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”.


apt-get update && apt-get upgrade


๊ทธ๋ฆฌ๊ณ  ๋‹ค์‹œ Package๋ฅผ ์ตœ์‹ ํ™” ํ•ด ์ค„๊ฒŒ์š”.





Repository์˜ ์„ค์ • ํŒŒ์ผ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•˜๋ ค ํ–ˆ์ง€๋งŒ, Package๊ฐ€ ์—†์–ด์„œ Error๊ฐ€ ๋‚ฌ์–ด์š”.



์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ•ด๋‹น Package๋ฅผ ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”.

sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'


๋ช…๋ น์–ด๊ฐ€ ์ •์ƒ ๋™์ž‘ํ•œ ๊ฑธ ํ™•์ธํ•  ์ˆ˜ ์ž‡์–ด์š”.



{"originWidth":1467,"originHeight":261,"style":"widthContent","caption":"wget -O- https://www.postgresql.org/media/keys/ACCC4CF8.asc


์ด๋ฒˆ์—๋Š” ์„ค์น˜ Package์˜ ์‹ ๋ขฐ์„ฑ์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด PostgreSQL GPG ํ‚ค๋ฅผ ๊ฐ€์ ธ์˜ค๋„๋ก ํ•˜์—ฌ ์ฃผ์—ˆ์–ด์š”.



์ด๋ฒˆ์—๋Š” ์›ํ•˜๋Š” ์„ค์น˜์— ๋”ฐ๋ผ ์•ˆ์ • Version๊ณผ Test Version์— ๋Œ€ํ•œ Repository๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์–ด์š”.
์šด์˜ ํ™˜๊ฒฝ ๋“ฑ ์‹ค์ œ ์‚ฌ์šฉ ์šฉ๋„์ธ ๊ฒฝ์šฐ PostgreSQL Repository์—์„œ ์ง์ ‘ ์„ค์น˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ž์ฃผ Update ๋˜๋Š” ์•ˆ์ •์ ์ธ Repository๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹์•„์š”.


์ด์ œ ๋ณธ๊ฒฉ์ ์œผ๋กœ PostgreSQL์„ ์„ค์น˜ํ•ด ๋ณผ๊ฒŒ์š”.

apt-get update && apt-get upgrade -y


PostgreSQL์˜ Repository๋ฅผ ๊ฐ€์ ธ์™”๊ธฐ ๋•Œ๋ฌธ์— ์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ๋‹ค์‹œ ์ฃผ์–ด ์ƒˆ๋กœ ์ถ”๊ฐ€๋œ ๋‚ด์šฉ์ด ๋ฐ˜์˜๋˜์–ด Repository Source List๋ฅผ Update ํ•ด ์ฃผ์—ˆ์–ด์š”.

apt install postgresql-client postgresql -y

๋ฐ˜์‘ํ˜•



๊ทธ๋ฆฌ๊ณ  ์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ PostgreSQL์„ ๋ณธ๊ฒฉ์ ์œผ๋กœ ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”.


ํŠน์ • Version์„ ์„ค์น˜ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์œ„์™€ ๊ฐ™์ด Version์„ ๋ช…์‹œํ•ด ์ฃผ๋ฉด ๋˜์š”.
์ฃผ๋‹ˆํ•˜๋ž‘์€ 12 Version์„ ์„ค์น˜ํ•ด ์ฃผ์—ˆ์–ด์š”.




service postgresql status


์„ค์น˜๊ฐ€ ์™„๋ฃŒ ๋˜์—ˆ๊ณ , postgreSQL์ด Down ๋˜์–ด ์žˆ์–ด์š”.



์œ„์™€ ๊ฐ™์ด PostgreSQL์„ ๊ธฐ๋™ ์‹œ์ผœ ์ฃผ์—ˆ์–ด์š”.



 

 

 

 

        ๐Ÿ“ฆ ๊ณ„์ • ์„ค์ •

์ตœ์ดˆ PostgreSQL ์ดˆ๊ธฐ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•ด ์ค„๊ฒŒ์š”.

passwd postgres


์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์„œ ์ดˆ๊ธฐ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.


createuser {User ๋ช…}


์œ„์™€ ๊ฐ™์ด postgres๋กœ Switching์„ ํ•˜๊ณ , junysonar๋ผ๋Š” ๊ณ„์ •์„ ๋งŒ๋“ค์–ด ์ฃผ์—ˆ์–ด์š”.


psql


์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด postgreSQL๋กœ ์ ‘์†ํ•ด ์ฃผ์—ˆ์–ด์š”.

alter user {๊ณ„์ •๋ช…} with encrypted password '{๋น„๋ฐ€๋ฒˆํ˜ธ}';

728x90


์œ„์˜ SQL ๋ฌธ์„ ํ†ตํ•ด ์ƒ์„ฑํ•œ ๊ณ„์ •์— ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•ด ์ค„ ์ˆ˜ ์žˆ์–ด์š”.


create database {DB ์ด๋ฆ„} owner {๊ณ„์ •๋ช…};


์œ„์™€ ๊ฐ™์ด ํŠน์ • DB๋ฅผ ๋งŒ๋“ค์–ด์ฃผ๊ณ , ๋‹ด๋‹น ๊ณ„์ •์„ ์„ค์ •ํ•ด ์ฃผ์—ˆ์–ด์š”.


grant all privileges on database {DB ์ด๋ฆ„} to {๊ณ„์ •๋ช…};


ํŠน์ • Data Base์— ํŠน์ • ๊ณ„์ •์—๊ฒŒ ๊ถŒํ•œ์„ ์œ„์™€ ๊ฐ™์ด ์ค„ ์ˆ˜ ์žˆ์–ด์š”.



์œ„์˜ ๋ช…๋ น์–ด๋กœ postgreSQL ์„ ์žฌ ๊ธฐ๋™ํ•ด์ฃผ์–ด์•ผ ํ•ด์š”.

 

 

 










๐Ÿง ์ฐธ๊ณ  ์ž๋ฃŒ

 

PostgreSQL: Linux downloads (Ubuntu)

Linux downloads (Ubuntu) PostgreSQL is available in all Ubuntu versions by default. However, Ubuntu "snapshots" a specific version of PostgreSQL that is then supported throughout the lifetime of that Ubuntu version. Other versions of PostgreSQL are availab

www.postgresql.org

 

 

PostgreSQL 12 High Availability Cookbook Paperback

COUPANG

www.coupang.com

"์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค."

 

 

 

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•