Myd data server » 이력 » 개정판 5
개정판 4 (이름없음, 2023/07/11 07:03) → 개정판 5/23 (이름없음, 2023/07/11 07:05)
h1. Getting Started On-Premise! <pre> Category: Guide Document Last updated on: Jul 11, 2023 </pre> --- > **Requirement and Supported OS** > - Intel Celeron J4025 @ 2.00 GHz, 2.9 (burst) GHz or later > - Memory 6GB or more > - Ubuntu 20.04.6 version x86_64 > **Test Environment** > - VMware 17.0.2 > - Ubuntu > - CentOS 7.9 --- h2. 1. Introduction MyD-Data-Center | 구성 요소 | Docker container name | 설명 | | Server | b2b.on-premise | openjdk:11.0.10-slim 기반의 web application server 로써 유일 하게 외부에 노출되는 서버 (17070 port), 암호화 및 복호화 및 데이터 수신 검증을 담당함 | | DB | b2b.on-premise.db | mariadb:10.1.34 기반의 database | | CsvConverter | Data-Analysis | tiangolo/uwsgi-nginx-flask:python3.9 기반의 Web application 으로써 JSON 형식 데이터를 csv로 변환하는 역할을 담당 | --- h2. 2. Git repository 접근 권한 부여받기 gitlab을 통해 MyD-Data-Center를 다운로드 받아 설치 할 수 있습니다. SNPLAB측에 gitlab 계정을 전달해 주시면, 접근 권한을 부여해 드립니다. --- h2. 3. Ubuntu에 MyD-Data-Server 설치 준비 하기 해당 Repository 솔루션은 Linux 기반의 Docker 구동 가능한 환경에서 동작할 수 있습니다. 해당 솔루션은 Ubuntu 20.04 기준으로 테스트 되었으며 Server, Desktop 관계 없이 사용할 수 있습니다. 설치 준비할 요소는 다음과 같습니다. h3. Git 설치 Git repository로부터 서버 구성 요소를 다운로드 받기 위해 git을 설치해야 합니다. <pre><code class="shell"> sudo apt install git </code></pre> h3. Docker 설치 Linux 상에서 docker container 를 구동하기 위해 docker engine 을 설치해야 합니다. Ubuntu 기준으로는 아래와 같이 진행할 수 있습니다. <pre><code class="shell"> sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin </code></pre> Ref: https://docs.docker.com/engine/install/ubuntu/ h3. docker-compose 설치 Linux 내에 container 배포를 위해서는 docker-compose 설치가 필요합니다. <pre><code class="shell"> $ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ... $ sudo chmod +x /usr/local/bin/docker-compose $ docker-compose --version docker-compose version 1.29.2, build 5becea4c </code></pre> Ref: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04 --- h2. 4. MyD-Data-Server 설치하기 h3. Git 을 통해 파일 받기 **1) git clone으로 repository 설치하기** <pre><code class="shell"> $ git clone https://gitlab.com/snplab1/myd-data-server.git $ cd myd-data-server </code></pre> **2) Setting database password** Database 는 gitlab의 사용자의 자산이므로, password역시 사용자가 설정해야 합니다. > 중요*** : 한번 설정된 password 는 변경할 때, database 내부의 데이터를 읽지 못하게 될 수 있으므로 신중히 기억하거나, 안전하게 보관해야 합니다 아래와 같이 .env.prod.hostmode 파일에서 PASSWORD 항목 2개를 찾아 변경합니다. <pre><code class="shell"> $ vi .env.prod.hostmode MYSQL_ROOT_PASSWORD=inputyourrootpassword // replace this MYSQL_USER=cranberry MYSQL_PASSWORD=inputyourpassword // replace this </code></pre> **3) Docker container 시작하기** 아래 명령어를 통해 간단하게 서버를 시작할 수 있습니다. 최초 구동에는 python package 설치에 시간이 소요되어 네트워크 상태에 따라 3분가량 소요될 수 있습니다. <pre><code class="shell"> $ docker-compose up -d Creating Data-Analysis ... done Creating b2b.on-premise ... done Creating b2b.on-premise.db ... done </code></pre> h2. 4. MyD-Data-Server 설치 검증 설치 후 동작 확인을 위해 아래 주소를 web browser 로 접근 하여 동작을 확인합니다. <pre><code class="shell"> http://{your-ip-address}:17070 </code></pre> 정상 설치 되었다면 아래와 같이 표시됩니다. <pre><code class="shell"> MyD data server status Server version "1.0.0 (2023.06.30)" CsvConverter "1.0.0 (2023.06.05)" URL location http://{your-ip-address}:17070 </code></pre> h2. 5. 외부 IP 및 HTTPS 설정 웹 애플리케이션 구동에 필요한 HTTPS 제공이 필요한 경우와, 불필요한 경우를 나누어 설명합니다. h3. 자체 HTTPS 제공이 가능한 경우 사용자가 사내에 이미 domain 과 연결된 HTTPS 제공이 가능하다면, MyD data server 가 17070 port 를 열어두고 있으므로 사용자의 도메인에 17070 포트를 reverse proxy로 연결하면 안전하게 사용하실 수 있습니다. h3. 외부 IP 나 domain은 있지만, HTTPS 제공이 불가능한 경우 nginx 와 letsencrypt를 통해서 HTTPS 를 제공할 수 있습니다. **NginX 설정 및 도메인 연결 방법** > 참고 문서: https://mindsers.blog/post/https-using-nginx-certbot-docker > Nginx 설정 이전에 사용자의 domain 의 IP 가, 현재 설치 중인 서버이거나, 현재 설치 중인 서버의 80 포트로 포워딩 되는지 확인해 주십시오. > SNPLAB 은 도메인은 제공하지 않습니다. **1) docker-compose 파일 실행 및 config 파일 확인** TLS 인증서가 발급되기 전에는 443 포트에 대한 기술 없이 default.conf 를 사용해야 합니다. 먼저 nginx/initial.conf 를 열어 example.org 를 사용자의 domain name으로 변경합니다. <pre><code class="shell"> $ docker-compose -f docker-compose.yml up -d webserver $ vi nginx/initial.conf </code></pre> **nginx/initial.conf** <pre><code class="shell"> server { listen 80; listen [::]:80; server_name shuai1593.xyz www.shuai1593.xyz; server_tokens off; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://shuai1593.xyz$request_uri; } } </code></pre> 변경 이후에는 initial.conf 파일로 default.conf를 덮어써 주십시오. <pre><code class="shell"> $ cp nginx/initial.conf nginx/conf/default.conf $ docker-compose -f docker-compose.yml up -d webserver </code></pre> 이제 nginx가 제대로 동작하는지 확인합니다. <pre><code class="shell"> $ curl -i http://shuai1593.xyz HTTP/1.1 301 Moved Permanently Server: nginx Date: Thu, 06 Jul 2023 04:46:15 GMT Content-Type: text/html Content-Length: 162 Connection: keep-alive Location: http://example.org/page <html> <head><title>301 Moved Permanently</title></head> <body> <center><h1>301 Moved Permanently</h1></center> <hr><center>nginx</center> </body> </html> </code></pre> 위와 같은 메시지가 출력 되는지 확인 해주십시오. **2) certbot 실행 및 인증서 발급** <pre><code class="shell"> $ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ --dry-run -d {yourserver} </code></pre> nginx 가 정상적으로 구동 되었다면, 위 명령어를 통해 domain 이 nginx로 제대로 포워딩 되었는지 확인합니다. 정상적이라면 "The dry run was successful" 메세지가 출력 되어야 합니다. 이제 아래 명령어를 통해 실제 인증서를 발급 받아 주십시오. <pre><code class="shell"> $ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d {yourserver} </code></pre> 이제 인증서와 키가 모두 생성 되었습니다. (fullchain.pem, privkey.pem) 인증서가 준비된 후에는 /nginx/conf/full.conf 에서 example.org 로 표기된 부분을 모두 사용자의 도메인으로 변경해 주십시오. <pre><code class="shell"> $ vi nginx/full.conf </code></pre> **nginx/full.conf** <pre><code class="shell"> server { listen 80; listen [::]:80; server_name example.org www.example.org; server_tokens off; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://example.org$request_uri; } } server { listen 443 default_server ssl http2; listen [::]:443 ssl http2; server_name example.org; ssl_certificate /etc/nginx/ssl/live/example.org/fullchain.pem; ssl_certificate_key /etc/nginx/ssl/live/example.org/privkey.pem; location / { proxy_pass http://{WAS 서버 IP 주소}:17070/; } } </code></pre> 변경이 완료된 파일로 /nginx/conf/default.conf 을 덮어써 주십시오. <pre><code class="shell"> $ cp nginx/full.conf nginx/conf/default.conf Overwrite default.conf file? Y $ docker rm -f b2b.on-premise.web $ docker-compose -f docker-compose.nginx.yml up -d webserver </code></pre> **주의사항** opKey.jck 는 data encrypt key 입니다. 해당 파일이 없다면 암,복호화가 되지 못하니 꼭 /store 폴더 내에 있는지 확인 부탁 드립니다. h3. 인증서 재발급 및 확인 인증서 재발급 명령어는 하기와 같습니다. <pre><code class="shell"> $ docker compose run --rm certbot renew </code></pre> 인증서 확인 명령어는 하기와 같습니다. <pre><code class="shell"> $ docker compose run --rm certbot certificates </code></pre> h2. 6. Backup 및 Restore | 항목 | 내용 | 비고 | | Backup | myd-data-server 에 Repository 내에 data 폴더에 있는 /store/* 와 /mysql/* 파일들을 저장해야 합니다. | | | Restore | 위에서 저장해둔 파일들을 data 폴더 내에 붙여넣습니다. | | h2. 6. Trouble Shooting h3. 6.1 Capturing log **Docker log 를 log file 로 뽑아오기** <pre><code class="shell"> $ docker logs b2b.on-premise > log1.txt $ docker logs b2b.on-premise.db > log2.txt $ docker logs Data-Analysis > log3.txt $ ls -al </code></pre> 이렇게 진행하시면 log1.txt, log2.txt, log3.txt 파일이 생긴 것을 확인하실 수 있습니다. 문제가 있는 경우엔 해당 파일을 SNPLAB로 보내주시면 되겠습니다. h3. 6.3 Application Error h3. 5.4 Terminal Error