-
Barman 설치PostgreSQL 2019. 10. 11. 13:27
Barman 설치에 대해 설명한다.
참고: http://rajeshmadiwale.blogspot.com/2016/03/barmanbackup-and-recovery-manager-is.html
설치
1. 다운로드
[bylee@localhost install]$ git clone https://github.com/2ndquadrant-it/barman.gi [bylee@localhost install]$ cd barman/ [bylee@localhost barman]$ ll 합계 256 -rw-rw-r--. 1 bylee bylee 1356 8월 2 16:10 AUTHORS -rw-rw-r--. 1 bylee bylee 135084 8월 2 16:10 ChangeLog -rw-rw-r--. 1 bylee bylee 225 8월 2 16:10 INSTALL -rw-rw-r--. 1 bylee bylee 35147 8월 2 16:10 LICENSE -rw-rw-r--. 1 bylee bylee 196 8월 2 16:10 MANIFEST.in -rw-rw-r--. 1 bylee bylee 27078 8월 2 16:10 NEWS -rw-rw-r--. 1 bylee bylee 2191 8월 2 16:10 README.rst -rw-rw-r--. 1 bylee bylee 662 8월 2 16:10 TODO drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 barman drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 bin drwxrwxr-x. 7 bylee bylee 4096 8월 2 16:10 doc drwxrwxr-x. 5 bylee bylee 4096 8월 2 16:10 rpm drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 scripts -rw-rw-r--. 1 bylee bylee 181 8월 2 16:10 setup.cfg -rwxrwxr-x. 1 bylee bylee 3625 8월 2 16:10 setup.py drwxrwxr-x. 3 bylee bylee 4096 8월 2 16:10 sphinx drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 tests -rw-rw-r--. 1 bylee bylee 867 8월 2 16:10 tox.ini
2.빌드 및 설치
[bylee@localhost barman]$ ./setup.py build [bylee@localhost barman]$ sudo ./setup.py install ... Installed /usr/lib/python2.7/site-packages/psycopg2-2.7.5-py2.7-linux-x86_64.egg Searching for six>=1.5 Reading https://pypi.python.org/simple/six/ Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl#sha256=832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb Best match: six 1.11.0 Processing six-1.11.0-py2.py3-none-any.whl Installing six-1.11.0-py2.py3-none-any.whl to /usr/lib/python2.7/site-packages Adding six 1.11.0 to easy-install.pth file Installed /usr/lib/python2.7/site-packages/six-1.11.0-py2.7.egg Finished processing dependencies for barman==2.4a1 [bylee@localhost install]$ sudo chown -R bylee:bylee barman [bylee@localhost barman]$ ll 합계 268 -rw-rw-r--. 1 bylee bylee 1356 8월 2 16:10 AUTHORS -rw-rw-r--. 1 bylee bylee 135084 8월 2 16:10 ChangeLog -rw-rw-r--. 1 bylee bylee 225 8월 2 16:10 INSTALL -rw-rw-r--. 1 bylee bylee 35147 8월 2 16:10 LICENSE -rw-rw-r--. 1 bylee bylee 196 8월 2 16:10 MANIFEST.in -rw-rw-r--. 1 bylee bylee 27078 8월 2 16:10 NEWS -rw-rw-r--. 1 bylee bylee 2191 8월 2 16:10 README.rst -rw-rw-r--. 1 bylee bylee 662 8월 2 16:10 TODO drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 barman drwxr-xr-x. 2 bylee bylee 4096 8월 2 16:26 barman.egg-info drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 bin drwxrwxr-x. 5 bylee bylee 4096 8월 2 16:26 build drwxr-xr-x. 2 bylee bylee 4096 8월 2 16:26 dist drwxrwxr-x. 7 bylee bylee 4096 8월 2 16:10 doc drwxrwxr-x. 5 bylee bylee 4096 8월 2 16:10 rpm drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 scripts -rw-rw-r--. 1 bylee bylee 181 8월 2 16:10 setup.cfg -rwxrwxr-x. 1 bylee bylee 3625 8월 2 16:10 setup.py drwxrwxr-x. 3 bylee bylee 4096 8월 2 16:10 sphinx drwxrwxr-x. 2 bylee bylee 4096 8월 2 16:10 tests -rw-rw-r--. 1 bylee bylee 867 8월 2 16:10 tox.ini
3. config
[bylee@localhost doc]$ sudo cp barman.conf /etc/ [bylee@localhost doc]$ sudo chown -R bylee:bylee /etc/barman.conf [bylee@localhost etc]$ cat barman.conf [barman] barman_home = /home/bylee/install/barman barman_user = bylee log_file = /home/bylee/install/barman/barman.log compression = gzip reuse_backup = link minimum_redundancy = 1 [pg] description = "Main DB Server" ssh_command = ssh bylee@127.0.0.1 conninfo = host=127.0.0.1 user=bylee dbname=postgres
4. ssh-keygen 생성
[bylee@localhost ~]$ ssh-keygen [bylee@localhost etc]$ ssh-copy-id -i /home/bylee/.ssh/id_rsa.pub bylee@127.0.0.1 --확인(비밀번호를 묻지 않아야 올바르게 설정된 것이다) [bylee@localhost etc]$ ssh bylee@127.0.0.1 Last failed login: Fri Aug 3 10:10:12 KST 2018 from 127.0.0.1 on ssh:notty There was 1 failed login attempt since the last successful login. Last login: Thu Aug 2 18:02:22 2018 from ::1 [bylee@localhost ~]$ exit
5. 디렉터리 확인
[bylee@localhost etc]$ barman show-server pg | grep incoming_wals_directory /usr/lib/python2.7/site-packages/psycopg2-2.7.5-py2.7-linux-x86_64.egg/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>. """) WARNING: No archiver enabled for server 'pg'. Please turn on 'archiver', 'streaming_archiver' or both WARNING: Forcing 'archiver = on' incoming_wals_directory: /home/bylee/install/barman/pg/incoming [bylee@localhost etc]$
6. backup
[bylee@localhost etc]$ barman backup pg Starting backup using rsync-exclusive method for server pg in /home/bylee/install/barman/pg/base/20180803T104319 Backup start at LSN: 0/6000028 (000000010000000000000006, 00000028) This is the first backup for server pg WAL segments preceding the current backup have been found: 000000010000000000000001 from server pg has been removed 000000010000000000000002 from server pg has been removed 000000010000000000000003 from server pg has been removed 000000010000000000000004 from server pg has been removed Starting backup copy via rsync/SSH for 20180803T104319 Copy done (time: 1 second) This is the first backup for server pg Asking PostgreSQL server to finalize the backup. Backup size: 23.5 MiB. Actual size on disk: 23.5 MiB (-0.00% deduplication ratio). Backup end at LSN: 0/6000130 (000000010000000000000006, 00000130) Backup completed (start time: 2018-08-03 10:43:19.841382, elapsed time: 2 seconds) Processing xlog segments from file archival for pg 000000010000000000000005 000000010000000000000006 000000010000000000000006.00000028.backup
7. backup 확인
[bylee@localhost etc]$ barman list-backup pg pg 20180803T104319 - Fri Aug 3 10:43:22 2018 - Size: 23.5 MiB - WAL Size: 0 B
8. restore
--데이터 삭제 [bylee@localhost data]$ rm -rf /home/bylee/install/agensgraph/data/* --restore [bylee@localhost etc]$ barman recover pg 20180803T104319 /home/bylee/install/agensgraph/data
9.restore 확인
[bylee@localhost agensgraph]$ ag_ctl -D data start waiting for server to start.... done server started [bylee@localhost agensgraph]$ agens -d postgres agens (AgensGraph 1.4devel, based on PostgreSQL 10.3) Type "help" for help. postgres=# set graph_path to p; SET postgres=# match (n) return n; n ---------------------------- v[3.1]{"name": "jelee"} v[3.2]{"name": "jelee100"} (2 rows)
10. 증분 백업(--reuse=link 옵션)
[bylee@localhost etc]$ barman backup --reuse=link pg Starting backup using rsync-exclusive method for server pg in /home/bylee/install/barman/pg/base/20180803T105539 Backup start at LSN: 0/A000028 (00000001000000000000000A, 00000028) Starting backup copy via rsync/SSH for 20180803T105539 Copy done (time: less than one second) Asking PostgreSQL server to finalize the backup. Backup size: 23.7 MiB. Actual size on disk: 562.2 KiB (-97.69% deduplication ratio). Backup end at LSN: 0/A000130 (00000001000000000000000A, 00000130) Backup completed (start time: 2018-08-03 10:55:40.195683, elapsed time: 1 second) Processing xlog segments from file archival for pg 000000010000000000000009 00000001000000000000000A 00000001000000000000000A.00000028.backup
문제 해결
문제 해결 1
ssh: connect to host 127.0.0.1 port 22: Connection refused
[bylee@localhost etc]$ sudo netstat -anp | grep -w LISTEN [sudo] bylee의 암호: tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1682/cupsd tcp6 0 0 ::1:631 :::* LISTEN 1682/cupsd [bylee@localhost etc]$ systemctl start sshd [bylee@localhost etc]$ sudo netstat -anp | grep -w LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 25576/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1682/cupsd tcp6 0 0 :::22 :::* LISTEN 25576/sshd tcp6 0 0 ::1:631 :::* LISTEN 1682/cupsd
문제 해결 2
[bylee@localhost etc]$ barman backup pg
/usr/lib/python2.7/site-packages/psycopg2-2.7.5-py2.7-linux-x86_64.egg/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")[bylee@localhost etc]$ sudo pip install --upgrade pip [sudo] bylee의 암호: WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead. Collecting pip Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 166kB/s Installing collected packages: pip Found existing installation: pip 9.0.3 Uninstalling pip-9.0.3: Successfully uninstalled pip-9.0.3 Successfully installed pip-18.0 [bylee@localhost etc]$ sudo pip install psycopg2-binary Collecting psycopg2-binary Downloading https://files.pythonhosted.org/packages/fc/21/5c3bb878be56fc2236a6274c326b91fe0888c089d8e80d0a2c09da43444f/psycopg2_binary-2.7.5-cp27-cp27mu-manylinux1_x86_64.whl (2.7MB) 100% |████████████████████████████████| 2.7MB 393kB/s Installing collected packages: psycopg2-binary Successfully installed psycopg2-binary-2.7.5
문제 해결 3
[bylee@localhost etc]$ barman backup pg
ERROR: Impossible to start the backup. Check the log for more details, or run 'barman check pg'[bylee@localhost etc]$ barman check pg Server pg: WAL archive: FAILED (please make sure WAL shipping is setup) PostgreSQL: OK is_superuser: OK wal_level: OK directories: OK retention policy settings: OK backup maximum age: OK (no last_backup_maximum_age provided) compression settings: OK failed backups: OK (there are 0 failed backups) minimum redundancy requirements: FAILED (have 0 backups, expected at least 1) ssh: OK (PostgreSQL server) not in recovery: OK archive_mode: OK archive_command: OK continuous archiving: OK archiver errors: OK
[bylee@localhost etc]$ barman switch-xlog --force --archive pg The WAL file 000000010000000000000004 has been closed on server 'pg' Waiting for the WAL file 000000010000000000000004 from server 'pg' (max: 30 seconds) Processing xlog segments from file archival for pg 000000010000000000000001 000000010000000000000002 000000010000000000000003 Processing xlog segments from file archival for pg 000000010000000000000004 [bylee@localhost etc]$ barman check pg Server pg: PostgreSQL: OK is_superuser: OK wal_level: OK directories: OK retention policy settings: OK backup maximum age: OK (no last_backup_maximum_age provided) compression settings: OK failed backups: OK (there are 0 failed backups) minimum redundancy requirements: FAILED (have 0 backups, expected at least 1) ssh: OK (PostgreSQL server) not in recovery: OK archive_mode: OK archive_command: OK continuous archiving: OK archiver errors: OK
'PostgreSQL' 카테고리의 다른 글
pgBouncer 설치 (0) 2019.10.11 PostgreSQL 백업 도구 비교 (0) 2019.10.11 WAL-E 설치 (0) 2019.10.11 pgBackRest 설치 (0) 2019.10.11 temboard에 대하여(작성필요) (0) 2019.08.12