1. 서론

안녕하십니까? CMAS 강사 이규영입니다.

오늘은 다이버에게 발생 할 수 있는 질환 중 가장 많이 알려져 있는 감압병에 대해 알아보겠습니다.

감압병은 직업적으로 깊은 수심에서 장시간 잠수를 반복해서 하는 커머셜다이버에게 흔히 발생되며, 우리 같은 레크레이션 다이버에게는 잘 생기지 않는 질환입니다. 하지만 부주의 하면 레크레이션 다이버에게도 생길 수 있기 때문에 이번 시간에 감압병에 대해 잘 듣고 이해하신다면 감압병에 걸리지 않고 즐겁고 안전하게 다이빙을 하실 수 있을 것 입니다.

그러면 지금부터 감압병의 정의와 발생원인, 증세, 응급처치, 치료, 예방법 순으로 알아보도록 하겠습니다.

2. 본론

정의 : 감압병이란 잠수중 체내에 흡수된 질소가 호흡을 통해 충분히 배출되지 못하고 체내에서 기포를 형성하여 병증을 유발하는 것을 말합니다.

원인 : 감압병의 원인은 헨리의법칙으로 설명이 되는데 깊은 수심에서 오랜 잠수 후 급상승 하거나 감압이 필요한 잠수 후 감압 없이 상승, 비행기 탐승대기 시간을 지키지 않거나 감압병을 촉진시키는 요인에 노출  되었을 때 발생 할 수 있습니다. 잠수를 하면 주변에 높아진 압력에 의해 몸속으로 보다 많은 질소가 녹아들어가게 되는데 녹아들어간 질소는 서서히 상승하면 호흡을 통해 정상적으로 체외로 배출되게 됩니다. 하지만 깊은 수심에서 오랜 잠수 후 적절한 감압절차 없이 상승하거나 급상승하면 체내에 과다하게 녹아들어간 질소가 체외로 배출되기전에 인체속에서 질소 기포를 형성하여 혈관을 막거나 신경세포를 눌러 병증을 일으키게 됩니다.

증세 : 감압병의 증세는 경증과 중증으로 구분됩니다. 경증으로는 피부의 발진, 관절통 등이 있으며, 중증으로는 호흡곤란, 반신, 전신마비, 의식불명이 발생하기도 합니다

응급처치 : 다이버가 감압병 증상을 보이면 환자를 눕히고 산소호흡을 시키면서, 육로나 해로를 통해 가까운 재압치료시설이 있는 병원으로 이송합니다. 국내 재압치료시설은 진해, 부산, 통영, 여수, 거제, 제주, 서귀포, 강릉 등에 있습니다. 재압치료는 환자를 높은 압력을 가할 수 있는 커다란 압력실에 넣고 압력을 가해서 기포로 형성되었던 질소가 다시 혈액속으로 녹아 들어갔다가 호흡을 통해 배출될 수 있도록 하여 치료 합니다. 재압치료에 대해 주의할 점은 위급하다고 현장의 수중에서 재압을 가하는 것은 저체온증 등 다른 위급 상황이 될 수 있으므로 절대로 시도하지 말아야 합니다.

예방 : 감압병을 예방하려면 감압이 필요한 잠수 금지, 상승 중 5m 수심에서 3~5분간 안전정지하며 상승속도는 분당 9m, 초당 15cm를 지켜야 합니다, 또한 잠수 후에는 비행기 탐승 대기시간을 준수 하여야 합니다. 비행기 탑승 대기시간은 무감압 잠수 1회시 12시간, 2회 이상 잠수시 18시간, 감압이 필요한 잠수를 하거나 3일이상 연속 잠수를 했을 경우 24시간 이상 휴식 후 비행기에 탑승하여야 합니다. 감압이 필요한 잠수를 하지 않기 위해서는 잠수전 잠수표를 사용하여 무감압 잠수를 계획하고, 감압병을 촉진하는 질병, 탈수, 음주, 추위, 비만, 고령 등에 해당시 잠수를 포기하거나 훨씬 더 보수적인 잠수를 계획하고 진행해야 합니다.

3. 결론

이상에서 알아본 바와 같이 감압병은 무서운 질병이지만, 감압이 필요한 깊은 수심에서 장시간 다이빙 금지, 상승속도 준수, 안전정지 준수, 비행기 탑승 대기시간 준수 등을 통해 쉽게 예방됩니다. 상승속도는 분당 9m 초당 15cm를 유지하고, 다이빙을 종료하고 수면위로 상승 할 때는 항상 5m에서 3~5분간 안전정지를 해야 하며, 잠수 후 비행기를 타는 등 기압이 낮은 환경에 노출되지 않도록 주의 해야 한다는 것을 잊지 않으신다면 감압병에 대해 안전하고 즐거운 다이빙을 하실 수 있을 것 입니다.

이상으로 감압명에 대해 배워봤습니다. 이해되지 않는 부분이나 더 아시고 싶은 내용이 있으면 말씀해 주시기 바랍니다.

그러면 여러분께서는 감압병에 대해 이해하신 것으로 알고 다음시간에는 공기색전증에 대해 알아보도록 하겠습니다.

 

1. 서론

안녕하십니까? CMAS 강사 이규영입니다.

오늘은 공기색전증에 대해 배워보도록 하겠습니다.

여러분 색전(塞栓)이라는 말을 들어 보셨습니까? 색전이라는 단어는 막힐색(), 마개전() 입니다. 의학에서 말하는 색전은 응고된 혈액이나 이물질에 의해 혈관이 막히는 증상을 말 합니다.

막는 물질의 종류에 따라 혈전색전증, 콜레스테롤색전증, 지방색전증 등 종류에 따라 세세하게 나누기도 합니다.

이중에 우리가 알아야 할 다이빙과 연관되어 있는 증상은 혈액속의 공기에 의해 발생하는 공기색전증 입니다공기색전증은 다이빙 관련 질병 중에서도 가장 응급을 요하고 상황에 따라 다이버에게 치명적인 손상을 입힐 수 있기 때문에 다이버라면 공기색전증에 대해 반드시 알고 있어야 하고 그것을 예방하기 위해서 어떻게 해야 하는지 숙지 해야 합니다.

이제 저와 함께 공기색전증의 정의와 원인, 증세, 응급처치, 치료 방법, 예방법에 대해 알아 보고 숙지하신다면 보다 안전한 다이빙을 할 수 있을 것 입니다.

2. 본론

정의 : 공기색전증은 공기 기포들로 인해 뇌동맥이 막혀 혈액흐름이 차단되는 것을 말합니다.

원인 : 공기색전증의 원인은 스쿠버 다이빙 중 호흡을 참고 수면으로 상승하는 것 입니다. 수중에서 호흡하다가 상승하게 되면 보일의 법칙에 의해 폐 속에 있던 공기가 팽창하게 됩니다. 정상호흡 중에는 팽창된 공기가 입을 통해 밖으로 배출 되지만, 숨을 참고 상승하게 되면 과팽창된 공기가, 기포상태로 폐포나 실핏줄을 뚫고 혈관으로 유입되어, 심장의 펌프질에 의해 뇌동맥 속으로 들어가면서 모여서 뇌로 통하는 혈액의 공급을 중단 시키게 됩니다.

증세 : 공기색전증의 증상은 수면으로 상승 중 또는 상승 직후 현기증, 시야가 흐려짐, 마비, 의식불명, 가슴의 통증 호흡곤란, 입가에 피거품 등과 같은 증상이 나타가게 되며, 수면 도착 전에 기절 할 수도 있습니다.

응급처치 : 공기색전증의 응급처치는 다이버를 눕히고 산소호흡을 시키며, 필요하면 심폐소생법을 실시하고, 이송시는 육로나 해로로 운송하여야 합니다.

치료 : 공기색전증이 걸린 환자는 평평한 바닥에 눕힌 상태로 즉시 재압챔버로 옮겨 재압치료를 해야 합니다. 국내에 재압치료시설은 진해, 부산, 통영, 여수, 거제, 제주, 서귀포, 강릉 등에 있습니다.

예방 : 공기색전증은 가장 무서운 잠수병 이지만 잠수 중 절대로 숨을 참지 말고 계속 정상적인 호흡을 하는 것 만으로 쉽게 예방할 수 있습니다. 

같은 원인으로 생기는 다른 질환들에는 기흉과, 가슴중앙의 기종, 그리고 피부 밑 기종이 있습니다.

3. 결론

지금까지 공기색전증에 대해 알아보았습니다. 오늘 교육중 잊지 말아야 할 가장 중요한 것은 스쿠버다이빙 중 절대로 숨을 참고 상승하지 말라는 것 입니다.

여러분께서는 이제 공기색전증 등 폐의 과다팽창증후군을 예방하려면 상승 중 절대로 숨을 참지 말아야 한다는 것과 공기색전증이 발생 되었을 때 응급처치와 치료법에 대해 알게 되어, 이런 위험에서 벗어나 안전하고 즐거운 다이빙을 즐길 수 있게 되었습니다.

의문 나는 사항이나 더 아시고 싶은 사항이 있으면 질문해 주시기 바랍니다.

여러분은 앞으로 스쿠버다이빙 중에는 어떠한 경우라도 숨을 참고 수면으로 상승해서는 안됩니다.

그럼 이것으로 공기색전증에 대해 강의를 마치고 다음시간에는 감압병에 대해 알아보도록 하겠습니다.

CentOS 7 - MariaDB 10.4.18 DB를 mariabackup 을 이용 백업해서 복구 하는 테스트 입니다.

운영중인 서비스에서 하기가 부담스러워서 Virtual Box에 CentOS 7과 MariaDB 10.4.X를 설치 해서 검증을 하는 작업입니다.

mariabackup을 이용해서 상용 DB Full 백업은 완료 후 테스트용 가상 머신에 내려받아 놓은 상태이며, 운영중인 MariaDB와 비슷한 버전인 10.4.27 버전으로 설치 완료된 상태 입니다.

지난 버전의 MariaDB 설치 방법은 아래 링크에서 확인 할 수 있습니다.

https://opensrc.tistory.com/218

 

CentOS7 에 MariaDB 지난 버전(10.4.27) 설치

운영중인 시스템에 mariabackup 을 통해서 받은 백업에 대해 복구 테스트를 진행해야 하는 상황 운영중인 시스템은 CentOS 7, MariaDB 10.4.18 로 운영중이어서 최대한 비슷한 환경으로 맞춰서 테스트 진

opensrc.tistory.com

 

1. 운영환경과 동일한 설정 적용

스크립트등 운영에 적용을 위해 운영과 최대한 동일한 환경으로 맞춘 후 작업 하려고 합니다.

작업 후 추가
mariadb datadir이 최초 설치 했을때는 /var/lib/mysql 로 지정되어 있습니다.
운영환경에서는 데이터 크기 문제로 별도의 물리적 파티션에 지정하여 사용하였기 때문에 /data/mysql 로 지정되어 있습니다.
백업 및 복원 스크립트 작성을 염두에 두고 동일한 경로로 지정하기 위해 datadir을 /data/mysql로 변경하면서 몇가지 작업이 추가 되었습니다.
아래 작업 내용에서는 /data/mysql 디렉토리를 미리 생성하고 소유자 권한을 mysql:mysql로 수정하는 등 작업을 했지만 백업 데이터를 풀어 놓고 다시 작업해야 했습니다.

운영 환경 

  • MariaDB 데이터 디렉토리 : /data/mysql  (복원 할 때 생성해야 함)
  • MariaDB 로그 디렉토리 : /data/mysql-logs
[root@DEVSVR01 data]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.27 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: inactive (dead)
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
[root@DEVSVR01 data]# 
[root@DEVSVR01 data]# 
[root@DEVSVR01 data]# systemctl start mariadb
[root@DEVSVR01 data]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.27 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Fri 2022-12-02 11:08:48 KST; 7s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 62859 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 62815 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 62813 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 62826 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─62826 /usr/sbin/mysqld

Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: 10.4.27 started; log sequence number 60943; transaction id 20
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: Buffer pool(s) load completed at 221202 11:08:48
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Server socket created on IP: '::'.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Reading of all Master_info entries succeeded
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Added new Master_info '' to hash table
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] /usr/sbin/mysqld: ready for connections.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: Version: '10.4.27-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Dec 02 11:08:48 DEVSVR01 systemd[1]: Started MariaDB 10.4.27 database server.
[root@DEVSVR01 data]#

maradb 를 처음 설치하고 아무런 조치를 하지 않으면 root 권한으로 비밀번호 입력 하지 않고 접속이 가능합니다.

백업 복원 후 가상머신을 제거 할 것 이기 때문에 별다른 조치를 하지 않고 바로 진행했습니다.

MariaDB 실행 및 접속

[root@DEVSVR01 data]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.27 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: inactive (dead)
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
[root@DEVSVR01 data]# 
[root@DEVSVR01 data]# 
[root@DEVSVR01 data]# systemctl start mariadb
[root@DEVSVR01 data]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.27 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Fri 2022-12-02 11:08:48 KST; 7s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 62859 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 62815 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 62813 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 62826 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─62826 /usr/sbin/mysqld

Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: 10.4.27 started; log sequence number 60943; transaction id 20
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] InnoDB: Buffer pool(s) load completed at 221202 11:08:48
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Server socket created on IP: '::'.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Reading of all Master_info entries succeeded
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] Added new Master_info '' to hash table
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: 2022-12-02 11:08:48 0 [Note] /usr/sbin/mysqld: ready for connections.
Dec 02 11:08:48 DEVSVR01 mysqld[62826]: Version: '10.4.27-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
Dec 02 11:08:48 DEVSVR01 systemd[1]: Started MariaDB 10.4.27 database server.
[root@DEVSVR01 data]# mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.27-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
MariaDB [(none)]> show global variables like 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+
1 row in set (0.000 sec)

MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| fb_ebmp            |
| information_schema |
| lcs                |
| mysql              |
| oneshot_sms        |
| performance_schema |
| server_audit       |
+--------------------+
7 rows in set (0.031 sec)

MariaDB [(none)]> quit
Bye
[root@DEVSVR01 data]#

기본 설정된 datadir은 /var/lib/mysql 입니다.

2. mariabackup 설치

데이터 복원을 위해 새로 설치한 CentOS 가상 머신에 mariabackup 을 설치 해야 합니다.

[root@DEVSVR01 ~]# yum install MariaDB-backup
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.navercorp.com
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-backup.x86_64 0:10.4.27-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================
 Package                                     Arch                                Version                                              Repository                            Size
=================================================================================================================================================================================
Installing:
 MariaDB-backup                              x86_64                              10.4.27-1.el7.centos                                 mariadb                              6.6 M

Transaction Summary
=================================================================================================================================================================================
Install  1 Package

Total download size: 6.6 M
Installed size: 27 M
Is this ok [y/d/N]: y
Downloading packages:
MariaDB-backup-10.4.27-1.el7.centos.x86_64.rpm                                                                                                            | 6.6 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : MariaDB-backup-10.4.27-1.el7.centos.x86_64                                                                                                                    1/1 
  Verifying  : MariaDB-backup-10.4.27-1.el7.centos.x86_64                                                                                                                    1/1 

Installed:
  MariaDB-backup.x86_64 0:10.4.27-1.el7.centos                                                                                                                                   

Complete!

이전 게시물에서 mariadb.repo에 버전을 지정했기 때문에 해당 버전에 맞는 mariabackup 이 설치 되었습니다.

3. 백업 데이터 복원

미리 운영 DB 에서 백업 받은 풀 데이터를 다운받아 두었습니다.

[root@DEVSVR01 ~]# cd /usr/download
[root@DEVSVR01 download]# ls -al
total 11994704
drwxr-xr-x.  3 root root          79 Dec  2 09:02 .
drwxr-xr-x. 14 root root         171 Dec  2 09:02 ..
drwx------.  8 root root        4096 Nov 27 04:43 PROD_full_20221127040001
-rw-r--r--.  1 root root 12282569817 Dec  1 20:12 PROD_full_20221127040001.tar.gz
[root@DEVSVR01 download]# cd PROD_full_20221127040001
[root@DEVSVR01 PROD_full_20221127040001]# ls -al
total 418276
drwx------. 8 root root      4096 Nov 27 04:43 .
drwxr-xr-x. 3 root root        79 Dec  2 09:02 ..
-rw-r-----. 1 root root    442368 Nov 27 04:43 aria_log.00000001
-rw-r-----. 1 root root        52 Nov 27 04:43 aria_log_control
-rw-r-----. 1 root root       391 Nov 27 04:43 backup-my.cnf
drwx------. 2 root root     12288 Nov 27 04:43 XXXXX
-rw-r-----. 1 root root 213909504 Nov 27 04:43 ibdata1
-rw-r-----. 1 root root 213909504 Nov 27 04:00 ibdata2
-rw-r-----. 1 root root         0 Nov 27 04:43 ib_logfile0
drwx------. 2 root root      4096 Nov 27 04:43 lcs
drwx------. 2 root root      4096 Nov 27 04:43 mysql
drwx------. 2 root root      4096 Nov 27 04:43 xxxxxxxxx
drwx------. 2 root root        20 Nov 27 04:43 performance_schema
drwx------. 2 root root       256 Nov 27 04:43 xxxxxxxxx
-rw-r-----. 1 root root        40 Nov 27 04:43 xtrabackup_binlog_info
-rw-r-----. 1 root root        85 Nov 27 04:43 xtrabackup_checkpoints
-rw-r-----. 1 root root       634 Nov 27 04:43 xtrabackup_info
[root@DEVSVR01 PROD_full_20221127040001]#

 

미리 만들어 놓은 datadir 때문에 복원을 하면서 에러가 발생합니다. /data/mysql를 삭제 한 후 다시 진행 했습니다.

[root@DEVSVR01 download]# which mariabackup
/usr/bin/mariabackup
[root@DEVSVR01 download]# mariabackup --copy-back --target-dir=/usr/download/PROD_full_20221127040001 --datadir=/var/lib/mysql --user root
mariabackup based on MariaDB server 10.4.27-MariaDB Linux (x86_64)
[00] 2022-12-02 12:13:55 Original data directory /var/lib/mysql is not empty!
[root@DEVSVR01 download]# mariabackup --copy-back --target-dir=/usr/download/PROD_full_20221127040001 --datadir=/data/mysql --user root
mariabackup based on MariaDB server 10.4.27-MariaDB Linux (x86_64)
[00] 2022-12-02 12:14:24 Original data directory /data/mysql is not empty!
[root@DEVSVR01 download]# rm -rf /data/mysql
[root@DEVSVR01 download]# mariabackup --copy-back --target-dir=/usr/download/PROD_full_20221127040001 --datadir=/data/mysql --user root
mariabackup based on MariaDB server 10.4.27-MariaDB Linux (x86_64)
[01] 2022-12-02 12:14:34 Copying ibdata1 to /data/mysql/ibdata1
... 생략...
[01] 2022-12-02 13:24:10 Copying ./aria_log_control to /data/mysql/aria_log_control
[01] 2022-12-02 13:24:10         ...done
[01] 2022-12-02 13:24:10 Copying ./aria_log.00000001 to /data/mysql/aria_log.00000001
[01] 2022-12-02 13:24:10         ...done
[01] 2022-12-02 13:24:10 Copying ./xtrabackup_info to /data/mysql/xtrabackup_info
[01] 2022-12-02 13:24:11         ...done
[00] 2022-12-02 13:24:11 completed OK!
[root@DEVSVR01 download]#

 

복원된 데이터를 확인하고 root 계정으로 생성된 데이터를 mysql:mysql 로 오너쉽을 변경합니다.

(서비스와 연관된 디렉토리 명은 xxxx로 마스킹 했습니다.)

[root@DEVSVR01 download]# ls -al /data
total 0
drwxr-xr-x.  4 root  root   37 Dec  2 12:14 .
dr-xr-xr-x. 18 root  root  236 Nov 30 18:46 ..
drwx------.  8 root  root  212 Dec  2 13:24 mysql
drwxr-xr-x.  3 mysql mysql  18 Dec  2 11:57 mysql-logs
[root@DEVSVR01 download]# ls -al /data/mysql
total 418260
drwx------. 8 root root       212 Dec  2 13:24 .
drwxr-xr-x. 4 root root        37 Dec  2 12:14 ..
-rw-r-----. 1 root root    442368 Dec  2 13:24 aria_log.00000001
-rw-r-----. 1 root root        52 Dec  2 13:24 aria_log_control
drwx------. 2 root root     12288 Dec  2 12:59 xxxxx
-rw-r-----. 1 root root 213909504 Dec  2 12:14 ibdata1
-rw-r-----. 1 root root 213909504 Dec  2 12:14 ibdata2
drwx------. 2 root root      4096 Dec  2 12:59 xxxx
drwx------. 2 root root      4096 Dec  2 12:57 mysql
drwx------. 2 root root      4096 Dec  2 12:59 xxxxxx
drwx------. 2 root root        20 Dec  2 13:24 performance_schema
drwx------. 2 root root       256 Dec  2 13:24 xxxxxx
-rw-r-----. 1 root root       634 Dec  2 13:24 xtrabackup_info
[root@DEVSVR01 download]# chown -R mysql:mysql /data/mysql
[root@DEVSVR01 download]# ls -al /data/mysql
total 418260
drwx------. 8 mysql mysql       212 Dec  2 13:24 .
drwxr-xr-x. 4 root  root         37 Dec  2 12:14 ..
-rw-r-----. 1 mysql mysql    442368 Dec  2 13:24 aria_log.00000001
-rw-r-----. 1 mysql mysql        52 Dec  2 13:24 aria_log_control
drwx------. 2 mysql mysql     12288 Dec  2 12:59 xxxx
-rw-r-----. 1 mysql mysql 213909504 Dec  2 12:14 ibdata1
-rw-r-----. 1 mysql mysql 213909504 Dec  2 12:14 ibdata2
drwx------. 2 mysql mysql      4096 Dec  2 12:59 xxxxx
drwx------. 2 mysql mysql      4096 Dec  2 12:57 mysql
drwx------. 2 mysql mysql      4096 Dec  2 12:59 xxxxxx
drwx------. 2 mysql mysql        20 Dec  2 13:24 performance_schema
drwx------. 2 mysql mysql       256 Dec  2 13:24 xxxxxx
-rw-r-----. 1 mysql mysql       634 Dec  2 13:24 xtrabackup_info
[root@DEVSVR01 download]#

 

/etc/my.cnf 를 수정해서 운영환경과 동일하게 맞추겠습니다.

[root@DEVSVR01 lib]# vi /etc/my.cnf
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[mysqld]
# DB의 데이터가 생성될 기본 경로
datadir=/data/mysql

# 소켓파일 경로(로컬서버 접속에 사용), 리모트 서버에는 ip와 port를 이용해서 TCP/IP 프로토콜로 접근
socket=/data/mysql/mysql.sock

# 타입존 설정
default-time-zone='+9:00'

## General LOG
general_log=1
log_output='FILE'
general_log_file=/data/mysql-logs/logs/mysql_history.log

## Slow LOG
slow_query_log=1
slow_query_log_file=/data/mysql-logs/logs/mysql_slow.log
long_query_time=10

## Error LOG
log-error=/data/mysql-logs/logs/mysql_error.log

## Binary LOG
log-bin=/data/mysql-logs/logs/mysql_binary
binlog_cache_size=2M
max_binlog_size=50M
expire_logs_days=2

[client-server]

#
# include *.cnf from the config directory
#
!includedir /etc/my.cnf.d

~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~

[mysqld] 부분을 추가 하고 몇가지 설정을 추가 했습니다.

중요한 것은 위에서 복사한 경로를 지정 하는 datadir = /data/mysql 입니다. (저장 공간등의 이슈가 없으면 설치시 지정된 디렉토리 그대로 진행해도 관계 없습니다.)

3. 복원된 데이터로 mariadb 실행

 

[root@DEVSVR01 download]# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
[root@DEVSVR01 download]# 
[root@DEVSVR01 download]# journalctl -xe
... 생략 ...
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [Note] /usr/sbin/mysqld (mysqld 10.4.27-MariaDB-log) starting as process 2831 ...
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [Warning] Can't create test file /data/mysql/DEVSVR01.lower-test
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: /usr/sbin/mysqld: Can't create file '/data/mysql-logs/logs/mysql_error.log' (errno: 13 "Permission denied")
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] mysqld: File '/data/mysql/aria_log_control' not found (Errcode: 13 "Permission denied")
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/data/mysql/aria_log_control'
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Plugin 'Aria' init function returned error.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [Note] InnoDB: Using Linux native AIO
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] InnoDB: Operating system error number 13 in a file operation.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Plugin 'InnoDB' init function returned error.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [Note] Plugin 'FEEDBACK' is disabled.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Failed to initialize plugins.
Dec 02 15:11:47 DEVSVR01 mysqld[2831]: 2022-12-02 15:11:47 0 [ERROR] Aborting
Dec 02 15:11:47 DEVSVR01 systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Dec 02 15:11:47 DEVSVR01 systemd[1]: Failed to start MariaDB 10.4.27 database server.
-- Subject: Unit mariadb.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mariadb.service has failed.
-- 
-- The result is failed.
Dec 02 15:11:47 DEVSVR01 systemd[1]: Unit mariadb.service entered failed state.
Dec 02 15:11:47 DEVSVR01 systemd[1]: mariadb.service failed.
Dec 02 15:11:47 DEVSVR01 polkitd[582]: Unregistered Authentication Agent for unix-process:2782:16916940 (system bus name :1.134, object path /org/freedesktop/PolicyKit1/Authenti
[root@DEVSVR01 download]#

퍼미션 문제로 정상 실행이 안됩니다.

journalctl -xe 명령으로 원인을 찾아 보면 

/usr/sbin/mysqld: Can't create file '/data/mysql-logs/logs/mysql_error.log' (errno: 13 "Permission denied") Dec 02 [ERROR] mysqld: File '/data/mysql/aria_log_control' not found (Errcode: 13 "Permission denied") Dec 02 15:11:47 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/data/mysql/aria_log_control'

mysql_error.log, 

aria_log_control 등의 파일에 퍼미션이 없어서 실행이 안된다고 나옵니다.

[root@DEVSVR01 download]# ls -al /data/
total 0
drwxr-xr-x.  4 root  root   37 Dec  2 12:14 .
dr-xr-xr-x. 18 root  root  236 Nov 30 18:46 ..
drwx------.  8 mysql mysql 212 Dec  2 13:24 mysql
drwxr-xr-x.  3 mysql mysql  18 Dec  2 11:57 mysql-logs
[root@DEVSVR01 download]# chmod 755 /data/mysql
[root@DEVSVR01 download]# ls -al /data/
total 0
drwxr-xr-x.  4 root  root   37 Dec  2 12:14 .
dr-xr-xr-x. 18 root  root  236 Nov 30 18:46 ..
drwxr-xr-x.  8 mysql mysql 212 Dec  2 13:24 mysql
drwxr-xr-x.  3 mysql mysql  18 Dec  2 11:57 mysql-logs
[root@DEVSVR01 download]# ls -al /data/mysql
total 418260
drwxr-xr-x. 8 mysql mysql       212 Dec  2 13:24 .
drwxr-xr-x. 4 root  root         37 Dec  2 12:14 ..
-rw-r-----. 1 mysql mysql    442368 Dec  2 13:24 aria_log.00000001
-rw-r-----. 1 mysql mysql        52 Dec  2 13:24 aria_log_control
drwx------. 2 mysql mysql     12288 Dec  2 12:59 xxxxxxx
-rw-r-----. 1 mysql mysql 213909504 Dec  2 12:14 ibdata1
-rw-r-----. 1 mysql mysql 213909504 Dec  2 12:14 ibdata2
drwx------. 2 mysql mysql      4096 Dec  2 12:59 xxxxxxx
drwx------. 2 mysql mysql      4096 Dec  2 12:57 mysql
drwx------. 2 mysql mysql      4096 Dec  2 12:59 xxxxxxx
drwx------. 2 mysql mysql        20 Dec  2 13:24 performance_schema
drwx------. 2 mysql mysql       256 Dec  2 13:24 xxxxxxx
-rw-r-----. 1 mysql mysql       634 Dec  2 13:24 xtrabackup_info
[root@DEVSVR01 download]#

권한 및 퍼미션을 설정해 줘도 안됩니다.

구글링 구글링

4. SELinux 로 보호되는 mysql 컨텍스트 해제

원인은 SELinux로 mysql 관련 디렉토리들이 보호되고 있어서 생긴 문제였습니다.

자세한 내용은 MariaDB 공식 문서를 확인 해주세요

https://mariadb.com/kb/en/selinux/

 

SELinux

SELinux is a Linux kernel module that provides a framework for configuring mandatory access control (MAC). Learn how we can help configure your framework.

mariadb.com

문서의 내용을 보면 semanage 라는 파이썬 패키지를 통해 관리 가능하다고 나옵니다.

[root@DEVSVR01 download]# semanage fcontext -a -t mysqld_db_t "/data/mysql(/.*)?"
-bash: semanage: command not found
[root@DEVSVR01 download]# semanage 
-bash: semanage: command not found
[root@DEVSVR01 download]#

아래 링크에서 semanage 패키지를 설치 하는 방법이 나옵니다.

https://ko.linux-console.net/?p=528#gsc.tab=0 

[root@DEVSVR01 download]# yum provides /usr/sbin/semanage
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.navercorp.com
policycoreutils-python-2.5-34.el7.x86_64 : SELinux policy core python utilities
Repo        : base
Matched from:
Filename    : /usr/sbin/semanage


[root@DEVSVR01 download]# yum install policycoreutils-python
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.navercorp.com
Resolving Dependencies

... 생략 ...

Installed:
  policycoreutils-python.x86_64 0:2.5-34.el7                                                                                                                                     

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.5-4.el7  checkpolicy.x86_64 0:2.5-8.el7  libcgroup.x86_64 0:0.41-21.el7  libsemanage-python.x86_64 0:2.5-14.el7  python-IPy.noarch 0:0.75-6.el7 
  setools-libs.x86_64 0:3.3.8-4.el7      

Complete!
[root@DEVSVR01 download]#

mysql에서 허용된 정책을 살펴 보고 동일한 정책으로 /data/mysql, /data/mysql-logs 디렉토리를 추가 합니다.

(중간에 디렉토리 경로를 안써주고 추가한 fcontext 는 -d 옵션으로 삭제 했습니다. 참고용으로 기록 남깁니다.)

[root@DEVSVR01 download]# semanage fcontext --list | grep mysqld_db_t
/var/lib/mysql(-files|-keyring)?(/.*)?             all files          system_u:object_r:mysqld_db_t:s0 
[root@DEVSVR01 download]# semanage fcontext -d "(-files|-keyring)?(/.*)?"
[root@DEVSVR01 download]# semanage fcontext --list | grep mysqld_db_t
/var/lib/mysql(-files|-keyring)?(/.*)?             all files          system_u:object_r:mysqld_db_t:s0 
(-files|-keyring)?(/.*)?                           all files          system_u:object_r:mysqld_db_t:s0 
[root@DEVSVR01 download]# semanage fcontext -d "/data/mysql(-files|-keyring)?(/.*)?"
[root@DEVSVR01 download]# semanage fcontext -d "/data/mysql-logs(-files|-keyring)?(/.*)?"
[root@DEVSVR01 download]# semanage fcontext --list | grep mysqld_db_t
/var/lib/mysql(-files|-keyring)?(/.*)?             all files          system_u:object_r:mysqld_db_t:s0 
/data/mysql(-files|-keyring)?(/.*)?                all files          system_u:object_r:mysqld_db_t:s0 
/data/mysql-logs(-files|-keyring)?(/.*)?           all files          system_u:object_r:mysqld_db_t:s0 
[root@DEVSVR01 download]#

 

mysqld 는 정상 실행 되지만 접속하려고 하면 mysql.sock을 /var/lib/mysql/mysql.sock 에서 찾고 있습니다.

/etc/my.cnf를 수정 하면서
[mysqld] 섹션에
socket=/data/mysql/mysql.sock 라고 수정 했습니다.
이것은 mariadb 서버가 실행 될 때 참고 하는 섹션입니다.
cli에서 mysql 을 접속 하는 것은 mysql client 로 서버에 접속하는 행위 이므로 mysql.sock 파일의 위치를 찾지 못하는 것 입니다.
[root@DEVSVR01 download]# systemctl start mariadb
[root@DEVSVR01 download]# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@DEVSVR01 download]# vi /etc/my.cnf.d/
enable_encryption.preset  mysql-clients.cnf         server.cnf                
[root@DEVSVR01 download]# vi /etc/my.cnf.d/mysql-clients.cnf 
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]
socket=/data/mysql/mysql.sock

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]

~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~  
:wq

/etc/my.cnf.d/mysql-clients.conf 에 [mysql] 섹션에 해당 소켓의 위치를 지정해 줍니다.

관리가 불편하면 /etc/my.cnf 파일 하단에 [mysql] 테그를 추가하고 해당 위치에 추가 해도 됩니다.

이외에 innodb 관련 설정들 몇가지가 달라서 mariadb 서버 실행에 에러가 발생했었습니다.

See "systemctl status mariadb.service" and "journalctl -xe" for details. 메시지 대로

journalctl -xe 명령으로 어디서 에러가 발생했는지 살펴 보시면서 하나씩 해결 하면 됩니다.

 

6. mariadb 실행 및 데이터 복원 확인

[root@DEVSVR01 download]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.4.27-MariaDB-log MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| fb_ebmp            |
| information_schema |
| lcs                |
| mysql              |
| oneshot_sms        |
| performance_schema |
| server_audit       |
+--------------------+
7 rows in set (0.031 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> select user, host, password from user;
+---------------+--------------+-------------------------------------------+
| User          | Host         | Password                                  |
+---------------+--------------+-------------------------------------------+
| mariadb.sys   | localhost    |                                           |
| root          | localhost    | *보안삭제                                 |
| mysql         | localhost    | invalid                                   |
... 생략 ...
+---------------+--------------+-------------------------------------------+
26 rows in set (0.001 sec)

MariaDB [mysql]> 
MariaDB [(none)]> quit
Bye
[root@DEVSVR01 download]#

정상 복원이 완료 되었습니다.

7. 외부에서 접근하기 위해서는 OS 방화벽 설정이 필요합니다.

[root@DEVSVR01 download]# vi /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
  <short>Public</short>
  <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  <service name="ssh"/>
  <service name="dhcpv6-client"/>
  <!-- mariadb start -->
  <rule family="ipv4">
    <port protocol="tcp" port="3306"/>
    <accept/>
  </rule>
  <!-- mariadb end -->
</zone>
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                                                                                                                                                                                                         
~                        
[root@DEVSVR01 download]# firewall-cmd --reload
success
[root@DEVSVR01 download]#

 

끝.

운영중인 시스템에 mariabackup 을 통해서 받은 백업에 대해 복구 테스트를 진행해야 하는 상황

운영중인 시스템은 CentOS 7, MariaDB 10.4.18 로 운영중이어서 최대한 비슷한 환경으로 맞춰서 테스트 진행하기 위해

Virtual Box 에 CentOS 7을 설치하고 덤프 파일을 내려 받음

MariaDB 10.4.X 버전을 설치 하기로 함

0. 도움 받은 글

https://bangu4.tistory.com/128

1. OS 버전 확인

[root@DEVSVR01 download]# rpm --query centos-release
centos-release-7-9.2009.1.el7.centos.x86_64
[root@DEVSVR01 download]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
[root@DEVSVR01 download]# cat /etc/system-release
CentOS Linux release 7.9.2009 (Core)
[root@DEVSVR01 download]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@DEVSVR01 download]#

$ rpm --query centos-release 명령이 가장 정확한 버전을 보여줌

2. yum 에 MariaDB Repository 추가

원하는 버전의 Repository 확인

https://downloads.mariadb.org/mariadb/repositories

 

Download MariaDB Server - MariaDB.org

REST API Release Schedule Reporting Bugs … Continue reading "Download MariaDB Server"

mariadb.org

사이트에서 CentOS 7 (x86_64)를 선택하면 MariaDB 버전은 10.4 밖에 나오지 않는다.

다운 받을 미러 사이트 선택 (그나마 일본이 좀 안전하다는 뇌피셜...)

다른 버전이 없는지 사이트 확인

https://mirror.mariadb.org/yum/

10.4.27 버전이 사용하고 있는 10.4.17 보다 약간 상위 버전으로 해당 패키시 설치 하기로 선택함

위 사이트에서 나온 내용에 baseurl 을 https://mirrors.xtom.jp/mariadb/yum/10.4.27/centos7-amd64

로 바꾸고 미러사이트에 존재 하는지 확인 (브라우저로 확인)후 mariadb.repo 생성

[root@DEVSVR01 download]# vi /etc/yum.repos.d/mariadb.repo
# MariaDB 10.4 CentOS repository list - created 2022-12-02 01:12 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://mirrors.xtom.jp/mariadb/yum/10.4.27/centos7-amd64
gpgkey=https://mirrors.xtom.jp/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
~                                                                                                                                                                                
~                                                                                                                                                                                
~                                                                                                                                                                                
~

 

3. yum 을 이용하여 MariaDB 설치

[root@DEVSVR01 download]# yum install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                      | 7.0 kB  00:00:00     
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.navercorp.com
base                                                                                                                                                      | 3.6 kB  00:00:00     
epel                                                                                                                                                      | 4.7 kB  00:00:00     
extras                                                                                                                                                    | 2.9 kB  00:00:00     
mariadb                                                                                                                                                   | 3.4 kB  00:00:00     
updates                                                                                                                                                   | 2.9 kB  00:00:00     
(1/5): mariadb/updateinfo                                                                                                                                 | 5.9 kB  00:00:00     
(2/5): mariadb/primary_db                                                                                                                                 |  65 kB  00:00:00     
(3/5): epel/x86_64/primary_db                                                                                                                             | 7.0 MB  00:00:01     
(4/5): epel/x86_64/updateinfo                                                                                                                             | 1.0 MB  00:00:01     
(5/5): updates/7/x86_64/primary_db                                                                                                                        |  18 MB  00:00:02     
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.4.27-1.el7.centos will be installed
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: MariaDB-client-10.4.27-1.el7.centos.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: MariaDB-client-10.4.27-1.el7.centos.x86_64
--> Processing Dependency: MariaDB-common for package: MariaDB-client-10.4.27-1.el7.centos.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: MariaDB-client-10.4.27-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.4.27-1.el7.centos will be installed
--> Processing Dependency: perl(DBI) for package: MariaDB-server-10.4.27-1.el7.centos.x86_64
--> Processing Dependency: galera-4 for package: MariaDB-server-10.4.27-1.el7.centos.x86_64
--> Processing Dependency: lsof for package: MariaDB-server-10.4.27-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-common.x86_64 0:10.4.27-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.4.27-1.el7.centos.x86_64
---> Package galera-4.x86_64 0:26.4.13-1.el7.centos will be installed
--> Processing Dependency: socat for package: galera-4-26.4.13-1.el7.centos.x86_64
--> Processing Dependency: libboost_program_options-mt.so.1.53.0()(64bit) for package: galera-4-26.4.13-1.el7.centos.x86_64
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package lsof.x86_64 0:4.87-6.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.4.27-1.el7.centos will be obsoleting
---> Package boost-program-options.x86_64 0:1.53.0-28.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be obsoleted
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
---> Package socat.x86_64 0:1.7.3.2-2.el7 will be installed
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================
 Package                                            Arch                              Version                                           Repository                          Size
=================================================================================================================================================================================
Installing:
 MariaDB-client                                     x86_64                            10.4.27-1.el7.centos                              mariadb                             12 M
 MariaDB-compat                                     x86_64                            10.4.27-1.el7.centos                              mariadb                            2.2 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.el7
 MariaDB-server                                     x86_64                            10.4.27-1.el7.centos                              mariadb                             26 M
Installing for dependencies:
 MariaDB-common                                     x86_64                            10.4.27-1.el7.centos                              mariadb                             81 k
 boost-program-options                              x86_64                            1.53.0-28.el7                                     base                               156 k
 galera-4                                           x86_64                            26.4.13-1.el7.centos                              mariadb                             10 M
 libaio                                             x86_64                            0.3.109-13.el7                                    base                                24 k
 lsof                                               x86_64                            4.87-6.el7                                        base                               331 k
 perl-Compress-Raw-Bzip2                            x86_64                            2.061-3.el7                                       base                                32 k
 perl-Compress-Raw-Zlib                             x86_64                            1:2.061-4.el7                                     base                                57 k
 perl-DBI                                           x86_64                            1.627-4.el7                                       base                               802 k
 perl-IO-Compress                                   noarch                            2.061-2.el7                                       base                               260 k
 perl-Net-Daemon                                    noarch                            0.48-5.el7                                        base                                51 k
 perl-PlRPC                                         noarch                            0.2020-14.el7                                     base                                36 k
 socat                                              x86_64                            1.7.3.2-2.el7                                     base                               290 k

Transaction Summary
=================================================================================================================================================================================
Install  3 Packages (+12 Dependent packages)

Total download size: 52 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mariadb/packages/MariaDB-common-10.4.27-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEYB/s |    0 B  --:--:-- ETA 
Public key for MariaDB-common-10.4.27-1.el7.centos.x86_64.rpm is not installed
(1/15): MariaDB-common-10.4.27-1.el7.centos.x86_64.rpm                                                                                                    |  81 kB  00:00:00     
(2/15): MariaDB-compat-10.4.27-1.el7.centos.x86_64.rpm                                                                                                    | 2.2 MB  00:00:00     
(3/15): boost-program-options-1.53.0-28.el7.x86_64.rpm                                                                                                    | 156 kB  00:00:00     
(4/15): MariaDB-server-10.4.27-1.el7.centos.x86_64.rpm                                                                                                    |  26 MB  00:00:02     
(5/15): libaio-0.3.109-13.el7.x86_64.rpm                                                                                                                  |  24 kB  00:00:00     
(6/15): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                                                                     |  57 kB  00:00:00     
(7/15): lsof-4.87-6.el7.x86_64.rpm                                                                                                                        | 331 kB  00:00:00     
(8/15): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                                                                    |  32 kB  00:00:00     
(9/15): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                                                           | 260 kB  00:00:00     
(10/15): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                                                              |  36 kB  00:00:00     
(11/15): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                                                            |  51 kB  00:00:00     
(12/15): perl-DBI-1.627-4.el7.x86_64.rpm                                                                                                                  | 802 kB  00:00:00     
(13/15): socat-1.7.3.2-2.el7.x86_64.rpm                                                                                                                   | 290 kB  00:00:00     
(14/15): galera-4-26.4.13-1.el7.centos.x86_64.rpm                                                                                                         |  10 MB  00:00:01     
(15/15): MariaDB-client-10.4.27-1.el7.centos.x86_64.rpm                                                                                                   |  12 MB  00:00:05     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                            8.9 MB/s |  52 MB  00:00:05     
Retrieving key from https://mirrors.xtom.jp/mariadb/yum/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid     : "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
 From       : https://mirrors.xtom.jp/mariadb/yum/RPM-GPG-KEY-MariaDB
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libaio-0.3.109-13.el7.x86_64                                                                                                                                 1/16 
  Installing : lsof-4.87-6.el7.x86_64                                                                                                                                       2/16 
  Installing : MariaDB-common-10.4.27-1.el7.centos.x86_64                                                                                                                   3/16 
  Installing : MariaDB-compat-10.4.27-1.el7.centos.x86_64                                                                                                                   4/16 
  Installing : MariaDB-client-10.4.27-1.el7.centos.x86_64                                                                                                                   5/16 
  Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                   6/16 
  Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                  7/16 
  Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                          8/16 
  Installing : boost-program-options-1.53.0-28.el7.x86_64                                                                                                                   9/16 
  Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                           10/16 
  Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                             11/16 
  Installing : perl-DBI-1.627-4.el7.x86_64                                                                                                                                 12/16 
  Installing : socat-1.7.3.2-2.el7.x86_64                                                                                                                                  13/16 
  Installing : galera-4-26.4.13-1.el7.centos.x86_64                                                                                                                        14/16 
  Installing : MariaDB-server-10.4.27-1.el7.centos.x86_64                                                                                                                  15/16 


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                          16/16 
  Verifying  : galera-4-26.4.13-1.el7.centos.x86_64                                                                                                                         1/16 
  Verifying  : socat-1.7.3.2-2.el7.x86_64                                                                                                                                   2/16 
  Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                                                            3/16 
  Verifying  : MariaDB-compat-10.4.27-1.el7.centos.x86_64                                                                                                                   4/16 
  Verifying  : MariaDB-client-10.4.27-1.el7.centos.x86_64                                                                                                                   5/16 
  Verifying  : boost-program-options-1.53.0-28.el7.x86_64                                                                                                                   6/16 
  Verifying  : lsof-4.87-6.el7.x86_64                                                                                                                                       7/16 
  Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                                                                  8/16 
  Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                                                              9/16 
  Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                                                                  10/16 
  Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                                                                 11/16 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                                                                                                12/16 
  Verifying  : MariaDB-server-10.4.27-1.el7.centos.x86_64                                                                                                                  13/16 
  Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                                                         14/16 
  Verifying  : MariaDB-common-10.4.27-1.el7.centos.x86_64                                                                                                                  15/16 
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64                                                                                                                          16/16 

Installed:
  MariaDB-client.x86_64 0:10.4.27-1.el7.centos              MariaDB-compat.x86_64 0:10.4.27-1.el7.centos              MariaDB-server.x86_64 0:10.4.27-1.el7.centos             

Dependency Installed:
  MariaDB-common.x86_64 0:10.4.27-1.el7.centos   boost-program-options.x86_64 0:1.53.0-28.el7   galera-4.x86_64 0:26.4.13-1.el7.centos        libaio.x86_64 0:0.3.109-13.el7  
  lsof.x86_64 0:4.87-6.el7                       perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7   perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7   perl-DBI.x86_64 0:1.627-4.el7   
  perl-IO-Compress.noarch 0:2.061-2.el7          perl-Net-Daemon.noarch 0:0.48-5.el7            perl-PlRPC.noarch 0:0.2020-14.el7             socat.x86_64 0:1.7.3.2-2.el7    

Replaced:
  mariadb-libs.x86_64 1:5.5.68-1.el7                                                                                                                                             

Complete!
[root@DEVSVR01 download]#

정상 설치 완료

[root@DEVSVR01 download]# systemctl status mariadb
● mariadb.service - MariaDB 10.4.27 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: inactive (dead)
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
[root@DEVSVR01 download]#
[root@DEVSVR01 download]# mariadb --version
mariadb  Ver 15.1 Distrib 10.4.27-MariaDB, for Linux (x86_64) using readline 5.1
[root@DEVSVR01 download]#

 

우분투 버전 Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-52-generic x86_64)

기본적으로 X Window 가 설치되어 있는 상태에서 시작

주의
상용 서비스를 운영중인 또는 운영 예정인 서버에 GUI 환경을 설치하는 것은 매우 신중하시기 바랍니다.
미니멀 설치 외에 추가로 설치되는 많은 패키지들로 인한 보안 문제가 발생할 수 있으며, 그로 인한 잦은 업데이트 권고 및 업데이트 후 예상치 못한 상황으로 전개 될 수 있습니다.

 

0. 사용자를 root 로 전환 (sudo 명령을 사용하기 귀찮아서...)

myuser@myserver:~$ su -
Password: 
root@myserver:~# id
uid=0(root) gid=0(root) groups=0(root)
root@myserver:~#

 

1. xrdp 설치

root@myserver:~# apt-get install xrdp
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python3-cliapp python3-markdown python3-pygments python3-ttystatus
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  libfuse2 xorg xorgxrdp
Suggested packages:
  xorg-docs xfonts-100dpi xfonts-75dpi x11-xfs-utils guacamole
The following NEW packages will be installed:
  libfuse2 xorg xorgxrdp xrdp
0 upgraded, 4 newly installed, 0 to remove and 64 not upgraded.
Need to get 675 kB of archives.
After this operation, 3,764 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libfuse2 amd64 2.9.9-5ubuntu3 [90.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/universe amd64 xrdp amd64 0.9.17-2ubuntu2 [517 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 xorg amd64 1:7.7+23ubuntu2 [2,890 B]
Get:4 http://archive.ubuntu.com/ubuntu jammy/universe amd64 xorgxrdp amd64 1:0.2.17-1build1 [65.3 kB]
Fetched 675 kB in 3s (265 kB/s)    
Selecting previously unselected package libfuse2:amd64.
(Reading database ... 297274 files and directories currently installed.)
Preparing to unpack .../libfuse2_2.9.9-5ubuntu3_amd64.deb ...
Unpacking libfuse2:amd64 (2.9.9-5ubuntu3) ...
Selecting previously unselected package xrdp.
Preparing to unpack .../xrdp_0.9.17-2ubuntu2_amd64.deb ...
Unpacking xrdp (0.9.17-2ubuntu2) ...
Selecting previously unselected package xorg.
Preparing to unpack .../xorg_1%3a7.7+23ubuntu2_amd64.deb ...
Unpacking xorg (1:7.7+23ubuntu2) ...
Selecting previously unselected package xorgxrdp.
Preparing to unpack .../xorgxrdp_1%3a0.2.17-1build1_amd64.deb ...
Unpacking xorgxrdp (1:0.2.17-1build1) ...
Setting up libfuse2:amd64 (2.9.9-5ubuntu3) ...
Setting up xorg (1:7.7+23ubuntu2) ...
Setting up xorgxrdp (1:0.2.17-1build1) ...
Setting up xrdp (0.9.17-2ubuntu2) ...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Scanning processes...                                                                                                                                                                                                                                                                                                      
Scanning candidates...                                                                                                                                                                                                                                                                                                     
Scanning processor microcode...                                                                                                                                                                                                                                                                                            
Scanning linux images...                                                                                                                                                                                                                                                                                                   

The processor microcode seems to be up-to-date.

Restarting services...
 systemctl restart avahi-daemon.service colord.service packagekit.service polkit.service
Service restarts being deferred:
 /etc/needrestart/restart.d/dbus.service
 systemctl restart gdm3.service
 systemctl restart networkd-dispatcher.service
 systemctl restart unattended-upgrades.service
 systemctl restart user@1000.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
root@myserver:~

정상 실행 확인

root@mserver:~$ systemctl status xrdp
● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-11-29 10:43:05 KST; 12min ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
    Process: 3608275 ExecStartPre=/bin/sh /usr/share/xrdp/socksetup (code=exited, status=0/SUCCESS)
    Process: 3608283 ExecStart=/usr/sbin/xrdp $XRDP_OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 3608284 (xrdp)
      Tasks: 2 (limit: 76917)
     Memory: 20.7M
        CPU: 4.682s
     CGroup: /system.slice/xrdp.service
             ├─3608284 /usr/sbin/xrdp
             └─3608350 /usr/sbin/xrdp

이상태에서 윈도우 원격데스크탑연결로 연결시 인증화면까지 진행되고 id / pw 입력 하면 윈도우가 종료된다.

구글링 구글링...

 

2. xrdp 유저, ssl-cert 그룹에 추가

root@myserver:~# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
... 생략...
xrdp:x:134:140::/run/xrdp:/usr/sbin/nologin
root@myserver:~# 
root@myserver:~# adduser xrdp ssl-cert
Adding user `xrdp' to group `ssl-cert' ...
Adding user xrdp to group ssl-cert
Done.
root@myserver:~#

 

3.  방화벽 허용 (내부방 172.30.*.*  에서 접속 가능하도록 방화벽 정책 추가)

root@myserver:~# ufw allow from 172.30.0.0/16 to any port 3389
Rules updated
root@myserver:~# ufw reload
Firewall not enabled (skipping reload)
root@myserver:~# ufw status
Status: inactive
root@myserver:~#

우분투 방화벽은 활성화 되어 있지 않았음 (-.,-a)

사실 인증 화면까지 나왔다는 것은 방화벽 문제는 아니었음을...

 

4. xfce4 인스톨

구글링 결과 기본 xrdp 만으로는 버그로 인해 원격데스크톱연결이 잘 안되는 것 같다.

ubuntu-desktop과 xfce4 추가 인스톨

서두에서 언급한 보안 및 업데이트 문제로 상용 서비스에 사용하는 서버는 ubuntu-desktop 설치에 신중하시기 바랍니다. 

root@myserver:~# apt install ubuntu-desktop
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
... 생략...
root@myserver:~# apt-get install xfce4 -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python3-cliapp python3-markdown python3-pygments python3-ttystatus
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  dbus-x11 desktop-base elementary-xfce-icon-theme exo-utils fonts-quicksand gir1.2-libxfce4util-1.0 gir1.2-xfconf-0 greybird-gtk-theme libexo-2-0 libexo-common libgarcon-1-0 libgarcon-common libgarcon-gtk3-1-0 libkeybinder-3.0-0 libthunarx-3-0 libtumbler-1-0 libxfce4panel-2.0-4 libxfce4ui-2-0 libxfce4ui-common
  libxfce4ui-utils libxfce4util-bin libxfce4util-common libxfce4util7 libxfconf-0-3 libxpresent1 pavucontrol tango-icon-theme thunar thunar-data thunar-volman tumbler tumbler-common xfce4-appfinder xfce4-helpers xfce4-notifyd xfce4-panel xfce4-pulseaudio-plugin xfce4-screensaver xfce4-session xfce4-settings
  xfconf xfdesktop4 xfdesktop4-data xfwm4 xiccd
Suggested packages:
  devhelp gnome-icon-theme kdelibs-data thunar-archive-plugin thunar-media-tags-plugin tumbler-plugins-extra xfce4-goodies xfce4-power-manager fortunes-mod
The following NEW packages will be installed:
  dbus-x11 desktop-base elementary-xfce-icon-theme exo-utils fonts-quicksand gir1.2-libxfce4util-1.0 gir1.2-xfconf-0 greybird-gtk-theme libexo-2-0 libexo-common libgarcon-1-0 libgarcon-common libgarcon-gtk3-1-0 libkeybinder-3.0-0 libthunarx-3-0 libtumbler-1-0 libxfce4panel-2.0-4 libxfce4ui-2-0 libxfce4ui-common
  libxfce4ui-utils libxfce4util-bin libxfce4util-common libxfce4util7 libxfconf-0-3 libxpresent1 pavucontrol tango-icon-theme thunar thunar-data thunar-volman tumbler tumbler-common xfce4 xfce4-appfinder xfce4-helpers xfce4-notifyd xfce4-panel xfce4-pulseaudio-plugin xfce4-screensaver xfce4-session
  xfce4-settings xfconf xfdesktop4 xfdesktop4-data xfwm4 xiccd
0 upgraded, 46 newly installed, 0 to remove and 64 not upgraded.
Need to get 18.3 MB of archives.
After this operation, 88.5 MB of additional disk space will be used.
... 생략 ...
root@myserver:~#

설정 파일 수정

root@overtake:~# vi /etc/xrdp/startwm.sh

#!/bin/sh
# xrdp X session start script (c) 2015, 2017, 2021 mirabilos
# published under The MirOS Licence

# Rely on /etc/pam.d/xrdp-sesman using pam_env to load both
# /etc/environment and /etc/default/locale to initialise the
# locale and the user environment properly.

if test -r /etc/profile; then
        . /etc/profile
fi
# 내용 추가
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

# 실행 명령 변경
#test -x /etc/X11/Xsession && exec /etc/X11/Xsession
#exec /bin/sh /etc/X11/Xsession
test -x /usr/bin/startxfce4 && exec /usr/bin/startxfce4
exec /bin/sh /usr/bin/startxfce4
~                                                                                                                                                                                                                                                                                                                          
~                                                                                                                                                                                                                                                                                                                          
~                                                                                                                                                                                                                                                                                                                          
~                                                                                                                                                                                                                                                                                                                          
~                                                                                                                                                                                                                                                                                                                          
~

xrdp 재시작

root@myserver:~# systemctl restart xrdp
root@myserver:~#

5. 원격데스크탑연결

원격데스트탑 연결 화면

 

XDRP 인증화면
Ubuntu 접속 화면

끝.

1. volumio 이미지 굽기

2. volumio 부팅

3. volumio 초기 설정

4. Tuch Display 플러그인 Install

5. SSH 활성화 

6. vi 에디터 설치 (생략 가능, nano 사용)

나는 nano editor 보다 vi가 편해서 설치 했음

volumio@volumio:~$ sudo apt update
[sudo] password for volumio:
Hit:1 https://deb.nodesource.com/node_14.x buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:3 http://archive.raspberrypi.org/debian buster InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
28 packages can be upgraded. Run 'apt list --upgradable' to see them.
volumio@volumio:~$
volumio@volumio:~$
volumio@volumio:~$
volumio@volumio:~/LCD-show/usr$ sudo apt install apt-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libapt-inst2.0
The following NEW packages will be installed:
  apt-utils libapt-inst2.0
0 upgraded, 2 newly installed, 0 to remove and 31 not upgraded.
Need to get 600 kB of archives.
After this operation, 1529 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf libapt-inst2.0 armhf 1.8.2.3 [200 kB]
Get:2 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf apt-utils armhf 1.8.2.3 [400 kB]
Fetched 600 kB in 4s (151 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libapt-inst2.0:armhf.
(Reading database ... 53885 files and directories currently installed.)
Preparing to unpack .../libapt-inst2.0_1.8.2.3_armhf.deb ...
Unpacking libapt-inst2.0:armhf (1.8.2.3) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_1.8.2.3_armhf.deb ...
Unpacking apt-utils (1.8.2.3) ...
Setting up libapt-inst2.0:armhf (1.8.2.3) ...
Setting up apt-utils (1.8.2.3) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u1) ...
volumio@volumio:~/LCD-show/usr$ sudo apt install xserver-xorg-input-evdev
Reading package lists... Done
Building dependency tree
Reading state information... Done
xserver-xorg-input-evdev is already the newest version (1:2.10.6-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.
volumio@volumio:~$
volumio@volumio:~$
volumio@volumio:~$
volumio@volumio:~$ sudo apt install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libgpm2 vim-common vim-runtime xxd
Suggested packages:
  gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
  libgpm2 vim vim-common vim-runtime xxd
0 upgraded, 5 newly installed, 0 to remove and 31 not upgraded.
Need to get 7150 kB of archives.
After this operation, 33.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf xxd armhf 2:8.1.0875-5+deb10u2 [139 kB]
Get:2 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf vim-common all 2:8.1.0875-5+deb10u2 [195 kB]
Get:3 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf libgpm2 armhf 1.20.7-5 [34.4 kB]
Get:4 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf vim-runtime all 2:8.1.0875-5+deb10u2 [5775 kB]
Get:5 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf vim armhf 2:8.1.0875-5+deb10u2 [1006 kB]
Fetched 7150 kB in 15s (482 kB/s)
Selecting previously unselected package xxd.
(Reading database ... 51986 files and directories currently installed.)
Preparing to unpack .../xxd_2%3a8.1.0875-5+deb10u2_armhf.deb ...
Unpacking xxd (2:8.1.0875-5+deb10u2) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a8.1.0875-5+deb10u2_all.deb ...
Unpacking vim-common (2:8.1.0875-5+deb10u2) ...
Selecting previously unselected package libgpm2:armhf.
Preparing to unpack .../libgpm2_1.20.7-5_armhf.deb ...
Unpacking libgpm2:armhf (1.20.7-5) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a8.1.0875-5+deb10u2_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.0875-5+deb10u2) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a8.1.0875-5+deb10u2_armhf.deb ...
Unpacking vim (2:8.1.0875-5+deb10u2) ...
Setting up libgpm2:armhf (1.20.7-5) ...
Setting up xxd (2:8.1.0875-5+deb10u2) ...
Setting up vim-common (2:8.1.0875-5+deb10u2) ...
Setting up vim-runtime (2:8.1.0875-5+deb10u2) ...
Setting up vim (2:8.1.0875-5+deb10u2) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/vi.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/vi.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/vi.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/vi.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/vi.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/vi.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/vi.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/view.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/view.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/view.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/view.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/view.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/view.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/view.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/ex.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/ex.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/ex.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/ex.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/ex.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/ex.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/ex.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: forcing reinstallation of alternative /bin/nano because link group editor is broken
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/nano.1.gz (of link group editor) doesn't exist
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for libc-bin (2.28-10+rpt2+rpi1+deb10u1) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for mime-support (3.62) ...
volumio@volumio:~$

7. LCD Driver 다운로드

volumio@volumio:~$ git clone https://github.com/goodtft/LCD-show
Cloning into 'LCD-show'...
remote: Enumerating objects: 1582, done.
remote: Counting objects: 100% (559/559), done.
remote: Compressing objects: 100% (135/135), done.
remote: Total 1582 (delta 488), reused 447 (delta 424), pack-reused 1023
Receiving objects: 100% (1582/1582), 2.46 MiB | 6.62 MiB/s, done.
Resolving deltas: 100% (1051/1051), done.
volumio@volumio:~$ ls -al
total 27
drwxr-xr-x 1 volumio volumio 1024 Oct 20 12:06 .
drwxr-xr-x 1 root    root    1024 Sep 30 08:43 ..
-rw------- 1 volumio volumio  101 Oct 20 11:44 .Xauthority
-rw-r--r-- 1 volumio volumio  220 Apr 18  2019 .bash_logout
-rw-r--r-- 1 volumio volumio 3526 Apr 18  2019 .bashrc
drwxr-xr-x 5 volumio volumio 1024 Oct 20 11:44 .cache
-rw-r--r-- 1 volumio volumio   49 Sep 30 08:44 .cdcdrc
-rw-r--r-- 1 volumio volumio  171 Sep 30 08:44 .cdserverrc
drwx------ 4 volumio volumio 1024 Oct 20 11:44 .config
drwx------ 3 volumio volumio 1024 Sep 30 08:49 .gnupg
drwx------ 3 volumio volumio 1024 Oct 20 11:44 .pki
-rw-r--r-- 1 volumio volumio  807 Apr 18  2019 .profile
-rw------- 1 volumio volumio 3786 Oct 20 11:44 .xsession-errors
drwxr-xr-x 6 volumio volumio 3072 Oct 20 12:06 LCD-show
volumio@volumio:~$

7. 기본 터치 디스플레이 설정 삭제

volumio@volumio:~$ ls -al /etc/X11/xorg.conf.d
total 5
drwxr-xr-x 2 root root 1024 Oct 20 11:27 .
drwxr-xr-x 1 root root 1024 Oct 20 11:27 ..
-rw-r--r-- 1 root root  316 Oct 20 11:27 95-touch_display-plugin.conf
volumio@volumio:~$ sudo rm /etc/X11/xorg.conf.d/95-touch_display-plugin.conf

8. 드라이버 복사

volumio@volumio:~$ sudo rm /etc/X11/xorg.conf.d/95-touch_display-plugin.conf
volumio@volumio:~$ cd LCD-show
volumio@volumio:~/LCD-show$ cd usr
volumio@volumio:~/LCD-show/usr$ ls
40-libinput.conf-0            99-calibration.conf-3508-270     99-calibration.conf-5-180       99-calibration.conf-mhs35b-90      99-calibration.conf-nano24-90  mhs24-overlay.dtb
40-libinput.conf-180          99-calibration.conf-3508-90      99-calibration.conf-5-270       99-calibration.conf-mhs395-0       99-fbturbo-fbcp.conf           mhs32-overlay.dtb
40-libinput.conf-270          99-calibration.conf-3508-FLIP-H  99-calibration.conf-5-90        99-calibration.conf-mhs395-180     99-fbturbo.conf                mhs35-overlay.dtb
40-libinput.conf-90           99-calibration.conf-3508-FLIP-V  99-calibration.conf-5-FLIP-H    99-calibration.conf-mhs395-270     99-fbturbo.conf-HDMI           mhs35b-overlay.dtb
40-libinput.conf-FLIP-H       99-calibration.conf-397-0        99-calibration.conf-5-FLIP-V    99-calibration.conf-mhs395-90      99-fbturbo.conf-original       mhs395-overlay.dtb
40-libinput.conf-FLIP-V       99-calibration.conf-397-180      99-calibration.conf-HDMI7C      99-calibration.conf-mhs397-0       bcm2709-rpi-2-b.dtb            mis35-overlay.dtb
99-calibration.conf-24        99-calibration.conf-397-270      99-calibration.conf-mhs24       99-calibration.conf-mhs397-180     bcm2710-rpi-3-b.dtb            modules-HDMI
99-calibration.conf-28        99-calibration.conf-397-90       99-calibration.conf-mhs32-0     99-calibration.conf-mhs397-270     cmdline.txt                    qddpi18.dtb
99-calibration.conf-32-0      99-calibration.conf-397-FLIP-H   99-calibration.conf-mhs32-180   99-calibration.conf-mhs397-90      cmdline.txt-noobs              qddpi24.dtb
99-calibration.conf-32-180    99-calibration.conf-397-FLIP-V   99-calibration.conf-mhs32-270   99-calibration.conf-mhs397-FLIP-H  cmdline.txt-noobs-original     rpi-fbcp
99-calibration.conf-32-270    99-calibration.conf-3971-0       99-calibration.conf-mhs32-90    99-calibration.conf-mhs397-FLIP-V  cmdline.txt-original           tft35a-overlay.dtb
99-calibration.conf-32-90     99-calibration.conf-3971-180     99-calibration.conf-mhs35-0     99-calibration.conf-mis35-0        fbcp                           tft7789-overlay.dtb
99-calibration.conf-35-0      99-calibration.conf-3971-270     99-calibration.conf-mhs35-180   99-calibration.conf-mis35-180      fbcp-ili9341                   tft9341-overlay.dtb
99-calibration.conf-35-180    99-calibration.conf-3971-90      99-calibration.conf-mhs35-270   99-calibration.conf-mis35-270      ft6236.dtb
99-calibration.conf-35-270    99-calibration.conf-3971-FLIP-H  99-calibration.conf-mhs35-90    99-calibration.conf-mis35-90       goodix.dtbo
99-calibration.conf-35-90     99-calibration.conf-3971-FLIP-V  99-calibration.conf-mhs35b-0    99-calibration.conf-nano24-0       goodix_dpi.dtb
99-calibration.conf-3508-0    99-calibration.conf-43           99-calibration.conf-mhs35b-180  99-calibration.conf-nano24-180     inittab
99-calibration.conf-3508-180  99-calibration.conf-5-0          99-calibration.conf-mhs35b-270  99-calibration.conf-nano24-270     local.desktop
volumio@volumio:~/LCD-show/usr$ sudo cp tft35a-overlay.dtb /boot/overlays
volumio@volumio:~/LCD-show/usr$ sudo cp tft35a-overlay.dtb /boot/overlays/tft35a.dtbo
volumio@volumio:~/LCD-show/usr$ sudo cp 99-calibration.conf-35-270 /etc/X11/xorg.conf.d/99-calibration.conf
volumio@volumio:~/LCD-show/usr$ ls -al /usr/share/X11/xorg.conf.d
total 13
drwxr-xr-x 2 root root 1024 Oct 20 11:22 .
drwxr-xr-x 1 root root 1024 Oct 20 11:23 ..
-rw-r--r-- 1 root root   92 Feb  7  2019 10-amdgpu.conf
-rw-r--r-- 1 root root 1350 Aug  4 12:56 10-quirks.conf
-rw-r--r-- 1 root root   92 Apr  6  2019 10-radeon.conf
-rw-r--r-- 1 root root 1429 Mar 31  2019 40-libinput.conf
-rw-r--r-- 1 root root 2747 Jun 26  2017 70-wacom.conf
volumio@volumio:~/LCD-show/usr$ sudo cp 99-fbturbo.conf /usr/share/X11/xorg.conf.d

9. calibration.conf 수정

volumio@volumio:~/LCD-show/usr$ sudo vi /etc/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "227 3936 3880 268"
        Option  "SwapAxes"      "1"
        Driver  "evdev"
EndSection
~
~
~
~

Driver "evdev" 추가

10. boot config 수정

volumio@volumio:~/LCD-show/usr$ sudo vi /boot/config.txt
display_auto_detect=1
disable_overscan=1
initramfs volumio.initrd
gpu_mem=32
max_usb_current=1
dtparam=audio=on
audio_pwm_mode=2
dtparam=i2c_arm=on
dtparam=spi=on
disable_splash=1
hdmi_force_hotplug=1
force_eeprom_read=0

include userconfig.txt

#### Volumio i2s setting below: do not alter ####
dtoverlay=iqaudio-dacplus,unmute_amp
dtoverlay=tft35a:rotate=270
~
~
~
~

11 fbdurbo.conf 수정

volumio@volumio:~$ sudo vi /usr/share/X11/xorg.conf.d/99-fbturbo.conf
# This is a minimal sample config file, which can be copied to
# /etc/X11/xorg.conf in order to make the Xorg server pick up
# and load xf86-video-fbturbo driver installed in the system.
#
# When troubleshooting, check /var/log/Xorg.0.log for the debugging
# output and error messages.
#
# Run "man fbturbo" to get additional information about the extra
# configuration options for tuning the driver.

Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb1"

        Option          "SwapbuffersWait" "true"
EndSection
~
~
~
~
volumio@volumio:~$

 

11. xserver 설치

volumio@volumio:~/LCD-show/usr$ sudo apt install xserver-xorg-input-evdev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  xserver-xorg-input-evdev
0 upgraded, 1 newly installed, 0 to remove and 31 not upgraded.
Need to get 117 kB of archives.
After this operation, 170 kB of additional disk space will be used.
Get:1 http://ftp.kaist.ac.kr/raspbian/raspbian buster/main armhf xserver-xorg-input-evdev armhf 1:2.10.6-1+b1 [117 kB]
Fetched 117 kB in 2s (62.5 kB/s)
Selecting previously unselected package xserver-xorg-input-evdev.
(Reading database ... 53875 files and directories currently installed.)
Preparing to unpack .../xserver-xorg-input-evdev_1%3a2.10.6-1+b1_armhf.deb ...
Unpacking xserver-xorg-input-evdev (1:2.10.6-1+b1) ...
Setting up xserver-xorg-input-evdev (1:2.10.6-1+b1) ...
Processing triggers for man-db (2.8.5-2) ...
volumio@volumio:~/LCD-show/usr$
volumio@volumio:~/LCD-show/usr$
volumio@volumio:~/LCD-show/usr$ sudo apt-get install xserver-xorg-video-fbturbo

12. volumio 실행 설정

volumio@volumio:~$ sudo vi /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

[ -d /etc/boot.d ] && run-parts /etc/boot.d

/usr/bin/xinit /usr/bin/chromium-browser --no-sandbox --no-first-run --noerrdialogs --start-fullscreen --start-maximized --disable-notifications --disable-infobars --kiosk --incognito http://localhost:3000 &

exit 0
~
~
~
~
volumio@volumio:~$

13. 재부팅

volumio@volumio:~$ sync
volumio@volumio:~$ sync
volumio@volumio:~$ sync
volumio@volumio:~$ sync
volumio@volumio:~$ reboot

 

취약점 개요 (나무위키)

https://namu.wiki/w/2021%EB%85%84%20%EC%9E%90%EB%B0%94%20%EB%B3%B4%EC%95%88%20%EC%B7%A8%EC%95%BD%EC%A0%90%20%EC%82%AC%ED%83%9C

 

요약

log4j 가 내부적으로 사용하고 있는 JNDI와 LDAP을 기능을 이용해 서버 권한을 탈취할 수 있는 취약점

log4j core v2.0 ~ v2.14.x 까지 해당

 

조치 권고

  • log4j core 모듈 v2.15로 업그레이드
  • 2.0-beta9 ~ 2.10.0 : log4j-core-*.jar 파일에서 org/apache/logging/log4j/core/lookup/JndiLookup.class 클래스를 제거 후 리빌드
  • 2.10 ~ 2.14.1 : log4j2.formatMsgNoLookups 또는 LOG4J_FORMAT_MSG_NO_LOOKUPS 환경 변수를 true로 설정

 

나의 현황

운영중인 Spring Boot 어플리케이션을 점검한 결과 log4j의 상위 버전인 logback + slf4j 로 로깅을 하고 있어서 큰 문제는 없는 것으로 판단

Maven dependency 확인 결과 Spring Boot 프로잭트를 생성하면서 자동으로 추가된 log4j 1.6 이 포함되어 있으나 사용하지 않은 패키지로 배포파일에는 포함되어 있지 않은 것으로 확인됨

 

추가로 검증을 위해 취약점을 확인 할 솔루션을 찾아보니 오픈소스인 로그프레소 제품 제작사에서 스케너를 배포한 것이 있었습니다.

로그프레소 스캐너 관련 기사

http://www.weeklypost.kr/news/articleView.html?idxno=2890 

 

로그프레소, 로그4셸 취약점 대응 스캐너 배포 - 위클리포스트(weeklypost)

로그4셸 보안 취약점이 보고 되면서, 이를 통해 발생할 원격으로 악성코드를 실행하는 문제점이 우려되고 있다. 사실상 거의 모든 자바 서버가 대상인 취약점으로 업계 전문가는 신속하게 취약

www.weeklypost.kr

스캐너 소스 : https://github.com/logpresso/CVE-2021-44228-Scanner


스캐너 검증

실 운영서버에 적용하기 전에 소스 부터 확인 해보았습니다.

https://github.com/logpresso/CVE-2021-44228-Scanner/blob/main/src/main/java/com/logpresso/scanner/Log4j2Scanner.java

 

GitHub - logpresso/CVE-2021-44228-Scanner: Vulnerability scanner and mitigation patch for Log4j2 CVE-2021-44228

Vulnerability scanner and mitigation patch for Log4j2 CVE-2021-44228 - GitHub - logpresso/CVE-2021-44228-Scanner: Vulnerability scanner and mitigation patch for Log4j2 CVE-2021-44228

github.com

내용은 간단해 보였습니다. 지정된 경로의 jar파일을 해제 해서 

org/apache/logging/log4j/core/lookup/JndiLookup.class

클래스가 존재 하는지 체킹하고 실행 파라메터에 추가에 따라 해당 클래스를 삭제해주는 내용이었습니다.

간단해 보이지만 취약점의 원인을 정확히 모르는 우리에겐 이런 것을 만들어서 공개 해주시는 분들께 그저 감사할 따름 입니다.

소스를 살펴 보고 실제 취약점을 찾아 내는지 검증 해보았습니다.

간단한 Spring Boot 프로잭트를 생성후 정상 동작 하는 것을 확인 하고

1. Maven > Update Project

2. Run > Maven Install

3. 커맨드 창에서 스캐너 실행

C:\temp\logpresso-log4j2-scan-1.2.1-win64>log4j2-scan.exe C:\temp\log4j_test\workspace\demo\target

Scanned 26 directories and 16 files
Found 0 vulnerable files
Completed in 0.90 seconds

C:\temp\logpresso-log4j2-scan-1.2.1-win64>

문제 없음

문제가 된 log4j 2.14 버전 추가

pom.xml 추가

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.14.0</version>
</dependency>

1. Maven > Update Project

2. Run > Maven Install

3. 커맨드 창에서 스캐너 실행

C:\temp\logpresso-log4j2-scan-1.2.1-win64>log4j2-scan.exe C:\temp\log4j_test\workspace\demo\target
[*] Found CVE-2021-44228 vulnerability in C:\temp\log4j_test\workspace\demo\target\demo-0.0.1-SNAPSHOT.jar (BOOT-INF/lib/log4j-core-2.14.0.jar), log4j 2.14.0

Scanned 26 directories and 16 files
Found 1 vulnerable files
Completed in 0.95 seconds

C:\temp\logpresso-log4j2-scan-1.2.1-win64>

취약점 발견됨

같은 방법으로 업데이트 권고 버전인 log4j 2.15로 변경 후 테스트 결과

C:\temp\logpresso-log4j2-scan-1.2.1-win64>log4j2-scan.exe C:\temp\log4j_test\workspace\demo\target

Scanned 26 directories and 16 files
Found 0 vulnerable files
Completed in 0.90 seconds

C:\temp\logpresso-log4j2-scan-1.2.1-win64>

취약점 발견 안됨

 

같은 방법으로 

서버에서 실행

[myservice@MY_HOST_NAME ~]$ pwd                 <== 경로 확인
/home/myservice/log4j_scan
[myservice@MY_HOST_NAME ~]$ mkdir log4j_scan    <== 스케너 다운로드 경로 확인
[myservice@MY_HOST_NAME ~]$ cd log4j_scan/
[myservice@MY_HOST_NAME log4j_scan]$ wget https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.1/logpresso-log4j2-scan-1.2.1-linux.tar.gz
--2021-12-13 14:39:38--  https://github.com/logpresso/CVE-2021-44228-Scanner/releases/download/v1.2.1/logpresso-log4j2-scan-1.2.1-linux.tar.gz
Resolving github.com (github.com)... 15.164.81.167
Connecting to github.com (github.com)|15.164.81.167|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/437261211/2c31e904-1f15-4f6d-93f4-aa6c8b3df5b5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211213%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211213T053815Z&X-Amz-Expires=300&X-Amz-Signature=003efe369b272cca8846a43f4b0b38bd45e47ec82c7613612cdb12c49ba851d3&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=437261211&response-content-disposition=attachment%3B%20filename%3Dlogpresso-log4j2-scan-1.2.1-linux.tar.gz&response-content-type=application%2Foctet-stream [following]
--2021-12-13 14:39:38--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/437261211/2c31e904-1f15-4f6d-93f4-aa6c8b3df5b5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211213%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211213T053815Z&X-Amz-Expires=300&X-Amz-Signature=003efe369b272cca8846a43f4b0b38bd45e47ec82c7613612cdb12c49ba851d3&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=437261211&response-content-disposition=attachment%3B%20filename%3Dlogpresso-log4j2-scan-1.2.1-linux.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2957824 (2.8M) [application/octet-stream]
Saving to: ‘logpresso-log4j2-scan-1.2.1-linux.tar.gz’

100%[================================================================================================================================================================================================================================================>] 2,957,824   11.8MB/s   in 0.2s

2021-12-13 14:39:39 (11.8 MB/s) - ‘logpresso-log4j2-scan-1.2.1-linux.tar.gz’ saved [2957824/2957824]

[myservice@MY_HOST_NAME log4j_scan]$ ls -al    <== 스캐너 다운로드 확인
합계 2892
drwxrwxr-x 2 myservice dev      54 12월 13 14:39 .
drwx------ 5 myservice dev     124 12월 13 14:39 ..
-rw-rw-r-- 1 myservice dev 2957824 12월 13 12:34 logpresso-log4j2-scan-1.2.1-linux.tar.gz
[myservice@MY_HOST_NAME log4j_scan]$ tar zxvf logpresso-log4j2-scan-1.2.1-linux.tar.gz     <== 압축 해제
log4j2-scan
[myservice@MY_HOST_NAME log4j_scan]$ ls
log4j2-scan  logpresso-log4j2-scan-1.2.1-linux.tar.gz
[myservice@MY_HOST_NAME log4j_scan]$ ./log4j2-scan /usr/local/myservice/apiserver     <== jar 파일이 존재하는 경로 지정하여 스캔

Scanned 4 directories and 40 files
Found 0 vulnerable files                 <== 취약점 0 발견
Completed in 6.92 seconds
[myservice@MY_HOST_NAME log4j_scan]$

확인 완료 후 스캐너 파일 삭제함.

소중한 소스코드 공유해 주신 로그프레소 제작사께 감사드립니다.

https://ko.logpresso.com/

MySQL 설치후 초기 root 패스워드를 설정 하는 방법은 아래 링크를 참고 하세요.

https://opensrc.tistory.com/207

 

[MySQL] MySQL 5.7 설치 후 초기 root 계정 비밀번호 변경 하기

이전 포스트 [CentOS 7 minimal 설치 #3] MySQL 5.7 설치에서도 한번 언급을 했었습니다만, 이전 버전과 방식이 좀 바뀐것 같습니다. MySQL 5.6 까지는 설치후 콘솔에서 바로 root 로 접속 해서 비밀번호를

opensrc.tistory.com

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

MySQL root 계정의 패스워드 분실 했을 경우 바꾸는 방법

MySQL 이전 버전에서 root 비밀번호를 분실 했을때 유용하게 이용되던 mysqld-safe 명령이 MySQL 7 부터는 없어진 것 같습니다.

MySQL 5.7버전을 설치 한 후에 저 명령을 아무리 찾아도 없었습니다. 구글링 끝에 

https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7

이런 내용의 글을 보았습니다.

간단히 요약해 보면

1. mysqld-safe  명령은 사라졌음

2. user 테이블의 구조가 바뀌었음

그래서 아래의 순서에 따라서 비밀번호를 바꿀 수 있습니다.

1. MySQL 서버 중지

[root@localhost ~]# systemctl stop mysqld

2. MySQL 환경변수 설정

[root@localhost ~]# systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. MySQL  서버 가동

[root@localhost ~]# systemctl start mysqld

4. 비번 없이  root 로그인

[root@localhost ~]# mysql -u root

5.  root 비밀번호 업데이트

mysql> UPDATE mysql.user SET authentication_string = PASSWORD('새비밀번호')

    -> WHERE User = 'root' AND Host = 'localhost';
    
ERROR 1348 (HY000): Column 'authentication_string' is not updatable
마리아 DB  10.4.12 에서는 위와 같은 방법으로는 에러가 발생합니다.
아래 방법으로 해결 가능합니다.

mysql> ALTER mysql.user 'root'@'localhost' identified by '새비밀번호';
Query OK, 0 rows affected (0.012 sec)

mysql> COMMIT;

mysql> FLUSH PRIVILEGES;

mysql> quit

6.  MySQL 중지

[root@localhost ~]# systemctl stop mysqld

7. MySQL 환경변수 초기화

[root@localhost ~]# systemctl unset-environment MYSQLD_OPTS

8. MySQL 서버 시작

[root@localhost ~]# systemctl start mysqld

9. 새 비밀번호로 로그인 확인

[root@localhost ~]# mysql -u root -p

참고로  user 테이블이 변경 된것은 user 테이블의 접근을 쿼리가 아닌 시스템 명령으로 하면 큰 차이는 없을 것 같습니다.

MySQL 공식 문서에서도

alter user 'root'@'localhost' identified by '새비밀번호';

이런 형태를 권장 하는 것 같습니다.

유저 생성 및 비밀번호, 권한 부여는 [CentOS 7 minimal 설치] MySQL DB생성, User 생성 글을 참고 하시기 바랍니다.

운영하는 시스템에 MySql 데이터를 crone tab을 이용하여 정기적으로 백업을 받는 설정을 하기로 했다.

MySql에서 제공하는 mysqldump 를 이용하여 매일 새벽 1시에 Full Dump를 해당 날짜의 이름으로 받아서 압축 하고 1주일 이상 지난 덤프파일은 삭제 하는 방식으로 스크립트를 만들었다.

mysqldump를 사용하기 위해  root 계정으로 진행 하였다.

 

/usr/local/backup/mysql/backup.sh 내용

#!/bin/bash 
echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] start backup"
export backup_file_name="MySystem_db_backup_$(date +%Y%m%d)" echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] start backup"
#echo ${backup_file_name} 
echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] daily backup start dump : ${backup_file_name}"
/usr/bin/mysqldump -uDBUSERID -pDBUSERPW DBNAME > /usr/local/backup/mysql/${backup_file_name}.sql
echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] daily backup compress : ${backup_file_name}.sql to ${backup_file_name}.sql.tar.gz"
/usr/bin/tar cvfpzR /usr/local/backup/mysql/${backup_file_name}.tar.gz /usr/local/backup/mysql/${backup_file_name}.sql 
echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] daily backup delete dump : ${backup_file_name}.sql"
/usr/bin/rm /usr/local/backup/mysql/${backup_file_name}.sql
echo "[$(date +%Y-%m-%d) $(date +%H:%M:%S)] end backup successfully"

※ 각 명령의 수행 시간을 로그에 남기도록 추가 하였다. echo ...

위 스트립트는 실행하면 지정한 DBNAME에 해당하는 데이터베이스를 MySystem_db_backup_YYYYMMDD.sql 파일로 dump 받고 해당 파일을 tar.gz 파일로 압축 후 sql 파일을 삭제하는 명령을 순서대로 기술 한 것이다.

MySQL 계정과 비밀번호가 적혀 있으므로 다른 계정에서는 접근 못하도록 퍼미션 변경

[root@localhost mysql]# chmod 600 backup.sh

[root@localhost mysql]# ls -al backup.sh[root@localhost mysql]# ls -al backup.sh
-rw-------. 1 root root 382 10월 11  2018 backup.sh
[root@localhost mysql]#

 

이제 매일 7일 지난 백업 파일을 삭제하는 스크립트를 만들어 보자

/usr/local/backup/mysql/delete_backup.sh 내용

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

#!/bin/bash
/usr/bin/find /usr/local/backup/mysql -name '*.tar.gz' -mtime +7 -exec rm {} \;

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

위 스크립트는 백업 폴더에 *.tar.gz 에 해당하는 모든 파일 중 생성된지 7일이 지난 파일을 삭제하는 명령이다.

코맨드 라인에서 개별로 실행 했을 때 잘 시행 된다면 크론텝에 등록하자.

[root@localhost mysql]#crontab -e 

아래 내용을 입력하고 저장한다.

0 0 * * * /usr/local/backup/mysql/backup.sh >> /usr/local/backup/mysql/backup.log
0 1 * * * /usr/local/backup/mysql/delete_backup.sh >> /usr/local/backup/mysql/backup.log

위 내용은 매일 0시에 backup.sh 를 실행하고 STDOUT으로 출력되는 내용은  backup.log 파일에 추가

매일 1시에 최근 7일 이전에 생성된 backup 파일을 삭제하고 STDOUT으로 출력되는 내용은 backup.log 파일에 추가

크론텝에 잘 지정이 되었는지 확인

[root@localhost mysql]# crontab -l
0 0 * * * /usr/local/backup/mysql/backup.sh >> /usr/local/backup/mysql/backup.log
0 1 * * * /usr/local/backup/mysql/delete_backup.sh >> /usr/local/backup/mysql/backup.log
[root@localhost mysql]#

이후에 /usr/local/backup/mysql 폴더에

[root@localhost mysql]# ls -al 
합계 6888652 
drwxr-xr-x. 2 root root      4096 12월 23 01:00 . 
drwxr-xr-x. 3 root root        19  9월 18  2018 .. 
-rw-r--r--. 1 root root 878195635 12월 16 00:02 MYSystem_db_back_20191216.tar.gz 
-rw-r--r--. 1 root root 879246960 12월 17 00:02 MYSystem_db_back_20191217.tar.gz 
-rw-r--r--. 1 root root 880465270 12월 18 00:02 MYSystem_db_back_20191218.tar.gz 
-rw-r--r--. 1 root root 881659467 12월 19 00:02 MYSystem_db_back_20191219.tar.gz 
-rw-r--r--. 1 root root 882824252 12월 20 00:02 MYSystem_db_back_20191220.tar.gz 
-rw-r--r--. 1 root root 883832714 12월 21 00:02 MYSystem_db_back_20191221.tar.gz 
-rw-r--r--. 1 root root 883838930 12월 22 00:02 MYSystem_db_back_20191222.tar.gz 
-rw-r--r--. 1 root root 883857070 12월 23 00:02 MYSystem_db_back_20191223.tar.gz 
-rw-r--r--. 1 root root     28840 12월 23 00:00 backup.log 
-rw-------. 1 root root       382 10월 11  2018 backup.sh 
-rw-r--r-x. 1 root root        92 10월 11  2018 delete_backup.sh 
[root@localhost mysql]# 

이런 식으로 Dump파일이 압축되어 저장된다.

 

끝.

1. 생년월일

주민번호 앞 6자리는 호적상 생년월일

2. 성별

뒷 7자리 숫자중 첫자리는 성별

 - 1900년대생 남자:1, 여자:2

 - 2000년대생 남자:3, 여자:4

 - 기타 1800년대생 남/녀도 있고

 - 귀화한 외국인 남/녀도 있다.

아래 표를 참조 하자

태어난 년도 한국인 외국인
남자 여자 남자 여자
1800~1899 9 0    
1900~1999 1 2 5 6
2000~2099 3 4 7 8

언젠가 카드사 홈페이지 회원가입에 주민번호를 입력해도 주민번호를 확인하라고 계속 뜬다고 해서 확인해 보니, 189? 년생 여자분... 기존에 개발 하신 분이 1,2만 체크하도록 만들어 놓으신 것인데, 그때가 100살이 넘은 분이 직접 카드사 홈페이지에 회원가입을 할리는 없고 아들이 본인 신용상의 문제로 어머니(할머니?) 주민번호로 카드를 발급한 상태였음

 

3. 지역코드

성별 다음 4자리는 지역 코드 (주민번호 지역코드 정도로 구글링 하면 많은 정보가 나온다)

4. 순차번호

다음으로 뒷자리 7개 숫자중 끝에서 두번째 자리는 같은 지역에서 같은날 여러명이 태어난 경우를 대비해 만들어 놓은 순차 번호이다.

5. Check Digit

맨마지막 1자리는 앞의 자리가 정상적으로 입력되었는지 확인하는 Check Digit 이다. 예전에 전산을 처음 배울때 Check Digit을 구하는 공식은 국가2급 기밀이라고 했었는데, 요즘 인터넷에 검색해 보면 수도 없이 나온다.

 

실명인증으로 대체

최근에는 개인정보 중요성이 대두되면서 주민번호 뒷자리까지 입력받는 경우는 의료나, 금융쪽밖에 없다. 웬만해선 이름+생년월일+성별로 대부분 식별이 가능하니 구지 주민번호 뒷자리까지 공개하지 않고 있다. 그리고 그것을 이용하여 신용평가회사 등에서 휴대폰 등을 통해 확인을 해주는 방식을 쓰고 있다.

위에 이야기 했던 카드사쇼핑몰에서 일하던 시절... 회원가입하면서 주민번호가 잘못되었다는 메시지가 계속 나온다고해서 확인해 보니 80세 여성고객의 자제분 새로 카드를 만들려고 하는데 주민번호 인증이 안된다고 연락이 왔다... 이분은 1900년대 생으로 주민번호 성별이 잘못된 케이스도 아님... 당시 실명인증을 대행하던 신평사에 문의했더니 진짜 없는 주민번호라고... 어째 그럴수가 있을까?

신용평가사는 금융결재원에서 전국민이 이용한 금융거래 기록에서 이름과 주민번호를 제공받아서 그것으로 장사를 하는 것이다.

그분은 80세가 넘도록 금융거래를 한번도 한적이 없었던 분으로 판명됨.

 

주민번호 중복 가능성

현재의 주민번호 체계는 같은지역(읍/면/동)에서 같은날 출생신고를 하는 동성의 사람이 10명을 초과 하게 되면 주민번호가 중복 될수 밖에 없는 구조이다. 앞의 11자리는 모두 동일할 것이고 순차번호는 0~9까지 10명 밖에 수용하지 못한다. 과거에 인구가 적던 시절에 만들어진 체계 이기 때문에 현실적으로 서울의 큰 동에서는 이를 초과하는 경우가 발생할 수도 있을 것 같다.(실제 있을것 같은데... 어떻게 하는지는 잘 모르겠음)

물론 현재 의 출산율을 봤을 때 인구가 줄어드는 상황으로 큰 문제는 없을 것 같다는 생각이...

2020.02.07 추가 : 최근 뉴스에서 주민번호 지역코드를 전국으로 통합하겠다고 하는 기사를 본것 같다. 아마도 주민번호4자리 + 순차코드 1자리로 대도시의 출생률에 대응하는데 문제가 있어서 아닐까?

 

성별코드 고갈

성별코드 역시 0~9까지 모두 사용한 상태이다. 향후 2100년(...그때 까지 살 수 있을까?) 이후에는 새로운 성별코드가 필요하다. 그때가 되면 현재의 주민번호 체계가 아닌 다른 체계의 인식코드를 사용하거나, 설마... 현재의 주민번호 체계를 그때까지 계속 쓴다면 1800년대 생을 위해 할당되었던 0,9를 재활용하지 않을까... 그때 되면 데이타 마이그레이션 할 일이 많을까? 어쩌면.... 2100년에 호모사피엔스가 지구에 존재하지 않을수도... 

아 쓸데 없는 80년 후의 걱정을 하고 있어... 실명인증이나 얼른 마무리 해야겠다.

 

+ Recent posts