Myd data server » 이력 » 버전 3
이름없음, 2023/07/11 06:47
1 | 1 | 이름없음 | h1. Getting Started On-Premise! |
---|---|---|---|
2 | |||
3 | <pre> |
||
4 | 2 | 이름없음 | Category: Guide Document |
5 | 3 | 이름없음 | Last updated on: Jul 11, 2023 |
6 | 1 | 이름없음 | </pre> |
7 | |||
8 | --- |
||
9 | |||
10 | > **Requirement and Supported OS** |
||
11 | > - Intel Celeron J4025 @ 2.00 GHz, 2.9 (burst) GHz or later |
||
12 | > - Memory 6GB or more |
||
13 | > - Ubuntu 20.04.6 version x86_64 |
||
14 | |||
15 | 3 | 이름없음 | > **Test Environment** |
16 | > - VMware 17.0.2 |
||
17 | > - Ubuntu |
||
18 | > - CentOS 7.9 |
||
19 | 1 | 이름없음 | --- |
20 | |||
21 | h2. 1. Introduction MyD-Data-Center |
||
22 | |||
23 | | 구성 요소 | Docker container name | 설명 | |
||
24 | | Server | b2b.on-premise | openjdk:11.0.10-slim 기반의 web application server 로써 유일 하게 외부에 노출되는 서버 (17070 port), 암호화 및 복호화 및 데이터 수신 검증을 담당함 | |
||
25 | | DB | b2b.on-premise.db | mariadb:10.1.34 기반의 database | |
||
26 | 3 | 이름없음 | | CsvConverter | Data-Analysis | tiangolo/uwsgi-nginx-flask:python3.9 기반의 Web application 으로써 JSON 형식 데이터를 csv로 변환하는 역할을 담당 | |
27 | 1 | 이름없음 | |
28 | --- |
||
29 | |||
30 | h2. 2. Git repository 접근 권한 부여받기 |
||
31 | |||
32 | gitlab을 통해 MyD-Data-Center를 다운로드 받아 설치 할 수 있습니다. |
||
33 | SNPLAB측에 gitlab 계정을 전달해 주시면, 접근 권한을 부여해 드립니다. |
||
34 | |||
35 | --- |
||
36 | |||
37 | h2. 3. Ubuntu에 MyD-Data-Server 설치 준비 하기 |
||
38 | |||
39 | 해당 솔루션은 Linux 기반의 Docker 구동 가능한 환경에서 동작할 수 있습니다. |
||
40 | 3 | 이름없음 | 해당 솔루션은 Ubuntu 20.04 기준으로 테스트 되었으며 Server, Desktop 관계 없이 사용할 수 있습니다. |
41 | 1 | 이름없음 | 설치 준비할 요소는 다음과 같습니다. |
42 | |||
43 | h3. Git 설치 |
||
44 | |||
45 | 3 | 이름없음 | Git repository로부터 서버 구성 요소를 다운로드 받기 위해 git을 설치해야 합니다. |
46 | 1 | 이름없음 | |
47 | 2 | 이름없음 | |
48 | <pre><code class="shell"> |
||
49 | 1 | 이름없음 | sudo apt install git |
50 | 2 | 이름없음 | </code></pre> |
51 | 1 | 이름없음 | |
52 | 2 | 이름없음 | |
53 | |||
54 | 1 | 이름없음 | h3. Docker 설치 |
55 | |||
56 | Linux 상에서 docker container 를 구동하기 위해 docker engine 을 설치해야 합니다. |
||
57 | Ubuntu 기준으로는 아래와 같이 진행할 수 있습니다. |
||
58 | |||
59 | 2 | 이름없음 | |
60 | <pre><code class="shell"> |
||
61 | 1 | 이름없음 | sudo apt-get update |
62 | sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
||
63 | 2 | 이름없음 | </code></pre> |
64 | |||
65 | |||
66 | |||
67 | 1 | 이름없음 | Ref: https://docs.docker.com/engine/install/ubuntu/ |
68 | |||
69 | h3. docker-compose 설치 |
||
70 | |||
71 | Linux 내에 container 배포를 위해서는 docker-compose 설치가 필요합니다. |
||
72 | |||
73 | 2 | 이름없음 | |
74 | <pre><code class="shell"> |
||
75 | 1 | 이름없음 | $ 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 |
76 | ... |
||
77 | $ sudo chmod +x /usr/local/bin/docker-compose |
||
78 | $ docker-compose --version |
||
79 | docker-compose version 1.29.2, build 5becea4c |
||
80 | 2 | 이름없음 | </code></pre> |
81 | 1 | 이름없음 | |
82 | 2 | 이름없음 | |
83 | |||
84 | 1 | 이름없음 | Ref: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-20-04 |
85 | |||
86 | --- |
||
87 | |||
88 | h2. 4. MyD-Data-Server 설치하기 |
||
89 | |||
90 | |||
91 | h3. Git 을 통해 파일 받기 |
||
92 | |||
93 | 3 | 이름없음 | **1) git clone으로 repository 설치하기** |
94 | 2 | 이름없음 | |
95 | <pre><code class="shell"> |
||
96 | 1 | 이름없음 | $ git clone https://gitlab.com/snplab1/myd-data-server.git |
97 | 2 | 이름없음 | $ cd myd-data-server |
98 | 1 | 이름없음 | </code></pre> |
99 | 2 | 이름없음 | |
100 | |||
101 | 1 | 이름없음 | **2) Setting database password** |
102 | |||
103 | Database 는 사용자의 자산이므로, password역시 사용자가 설정해야 합니다. |
||
104 | |||
105 | 3 | 이름없음 | > 중요*** : 한번 설정된 password 는 변경할 때, database 내부의 데이터를 읽지 못하게 될 수 있으므로 신중히 기억하거나, 안전하게 보관해야 합니다 |
106 | 1 | 이름없음 | |
107 | 아래와 같이 .env.prod.hostmode 파일에서 PASSWORD 항목 2개를 찾아 변경합니다. |
||
108 | |||
109 | 2 | 이름없음 | |
110 | <pre><code class="shell"> |
||
111 | 1 | 이름없음 | $ vi .env.prod.hostmode |
112 | |||
113 | MYSQL_ROOT_PASSWORD=inputyourrootpassword // replace this |
||
114 | MYSQL_USER=cranberry |
||
115 | MYSQL_PASSWORD=inputyourpassword // replace this |
||
116 | 2 | 이름없음 | </code></pre> |
117 | 1 | 이름없음 | |
118 | 2 | 이름없음 | |
119 | |||
120 | 1 | 이름없음 | **3) Docker container 시작하기** |
121 | |||
122 | 아래 명령어를 통해 간단하게 서버를 시작할 수 있습니다. |
||
123 | 최초 구동에는 python package 설치에 시간이 소요되어 네트워크 상태에 따라 3분가량 소요될 수 있습니다. |
||
124 | |||
125 | 2 | 이름없음 | |
126 | <pre><code class="shell"> |
||
127 | 1 | 이름없음 | $ docker-compose up -d |
128 | Creating Data-Analysis ... done |
||
129 | Creating b2b.on-premise ... done |
||
130 | Creating b2b.on-premise.db ... done |
||
131 | 2 | 이름없음 | </code></pre> |
132 | 1 | 이름없음 | |
133 | |||
134 | 2 | 이름없음 | |
135 | h2. 4. MyD-Data-Server 설치 검증 |
||
136 | |||
137 | 3 | 이름없음 | 설치 후 동작 확인을 위해 아래 주소를 web browser 로 접근 하여 동작을 확인합니다. |
138 | 1 | 이름없음 | |
139 | 2 | 이름없음 | |
140 | <pre><code class="shell"> |
||
141 | 1 | 이름없음 | http://{your-ip-address}:17070 |
142 | 2 | 이름없음 | </code></pre> |
143 | 1 | 이름없음 | |
144 | 2 | 이름없음 | |
145 | |||
146 | 1 | 이름없음 | 정상 설치 되었다면 아래와 같이 표시됩니다. |
147 | |||
148 | 2 | 이름없음 | |
149 | <pre><code class="shell"> |
||
150 | 1 | 이름없음 | MyD data server status |
151 | |||
152 | Server version "1.0.0 (2023.06.30)" |
||
153 | CsvConverter "1.0.0 (2023.06.05)" |
||
154 | |||
155 | URL location http://{your-ip-address}:17070 |
||
156 | </code></pre> |
||
157 | 2 | 이름없음 | |
158 | 1 | 이름없음 | |
159 | 2 | 이름없음 | |
160 | 1 | 이름없음 | h2. 5. 외부 IP 및 HTTPS 설정 |
161 | |||
162 | 3 | 이름없음 | 웹 애플리케이션 구동에 필요한 HTTPS 제공이 필요한 경우와, 불필요한 경우를 나누어 설명합니다. |
163 | 1 | 이름없음 | |
164 | h3. 자체 HTTPS 제공이 가능한 경우 |
||
165 | |||
166 | 사용자가 사내에 이미 domain 과 연결된 HTTPS 제공이 가능하다면, MyD data server 가 17070 port 를 열어두고 있으므로 사용자의 도메인에 17070 포트를 reverse proxy로 연결하면 안전하게 사용하실 수 있습니다. |
||
167 | |||
168 | 3 | 이름없음 | h3. 외부 IP 나 domain은 있지만, HTTPS 제공이 불가능한 경우 |
169 | 1 | 이름없음 | |
170 | nginx 와 letsencrypt를 통해서 HTTPS 를 제공할 수 있습니다. |
||
171 | |||
172 | **NginX 설정 및 도메인 연결 방법** |
||
173 | |||
174 | 3 | 이름없음 | > 참고 문서: https://mindsers.blog/post/https-using-nginx-certbot-docker |
175 | > Nginx 설정 이전에 사용자의 domain 의 IP 가, 현재 설치 중인 서버이거나, 현재 설치 중인 서버의 80 포트로 포워딩 되는지 확인해 주십시오. |
||
176 | > SNPLAB 은 도메인은 제공하지 않습니다. |
||
177 | |||
178 | 1 | 이름없음 | **1) docker-compose 파일 실행 및 config 파일 확인** |
179 | 2 | 이름없음 | |
180 | 3 | 이름없음 | TLS 인증서가 발급되기 전에는 443 포트에 대한 기술 없이 default.conf 를 사용해야 합니다. |
181 | 먼저 nginx/initial.conf 를 열어 example.org 를 사용자의 domain name으로 변경합니다. |
||
182 | |||
183 | 2 | 이름없음 | <pre><code class="shell"> |
184 | $ docker-compose -f docker-compose.yml up -d webserver |
||
185 | 3 | 이름없음 | $ vi nginx/initial.conf |
186 | 2 | 이름없음 | </code></pre> |
187 | |||
188 | 3 | 이름없음 | **nginx/initial.conf** |
189 | 2 | 이름없음 | |
190 | <pre><code class="shell"> |
||
191 | server { |
||
192 | listen 80; |
||
193 | 1 | 이름없음 | listen [::]:80; |
194 | 2 | 이름없음 | |
195 | server_name shuai1593.xyz www.shuai1593.xyz; |
||
196 | 1 | 이름없음 | server_tokens off; |
197 | |||
198 | location /.well-known/acme-challenge/ { |
||
199 | root /var/www/certbot; |
||
200 | } |
||
201 | |||
202 | location / { |
||
203 | return 301 https://shuai1593.xyz$request_uri; |
||
204 | } |
||
205 | } |
||
206 | </code></pre> |
||
207 | |||
208 | 3 | 이름없음 | 변경 이후에는 initial.conf 파일로 default.conf를 덮어써 주십시오. |
209 | 1 | 이름없음 | |
210 | <pre><code class="shell"> |
||
211 | 3 | 이름없음 | $ cp nginx/initial.conf nginx/conf/default.conf |
212 | $ docker-compose -f docker-compose.yml up -d webserver |
||
213 | </code></pre> |
||
214 | |||
215 | 이제 nginx가 제대로 동작하는지 확인합니다. |
||
216 | |||
217 | <pre><code class="shell"> |
||
218 | $ curl -i http://shuai1593.xyz |
||
219 | HTTP/1.1 301 Moved Permanently |
||
220 | Server: nginx |
||
221 | Date: Thu, 06 Jul 2023 04:46:15 GMT |
||
222 | Content-Type: text/html |
||
223 | Content-Length: 162 |
||
224 | Connection: keep-alive |
||
225 | Location: http://example.org/page |
||
226 | <html> |
||
227 | <head><title>301 Moved Permanently</title></head> |
||
228 | <body> |
||
229 | <center><h1>301 Moved Permanently</h1></center> |
||
230 | <hr><center>nginx</center> |
||
231 | </body> |
||
232 | </html> |
||
233 | </code></pre> |
||
234 | |||
235 | 위와 같은 메시지가 출력 되는지 확인 해주십시오. |
||
236 | |||
237 | **2) certbot 실행 및 인증서 발급** |
||
238 | |||
239 | <pre><code class="shell"> |
||
240 | $ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ --dry-run -d {yourserver} |
||
241 | </code></pre> |
||
242 | |||
243 | nginx 가 정상적으로 구동 되었다면, 위 명령어를 통해 domain 이 nginx로 제대로 포워딩 되었는지 확인합니다. |
||
244 | 정상적이라면 "The dry run was successful" 메세지가 출력 되어야 합니다. |
||
245 | |||
246 | 이제 아래 명령어를 통해 실제 인증서를 발급 받아 주십시오. |
||
247 | |||
248 | <pre><code class="shell"> |
||
249 | $ docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d {yourserver} |
||
250 | </code></pre> |
||
251 | |||
252 | 이제 인증서와 키가 모두 생성 되었습니다. (fullchain.pem, privkey.pem) |
||
253 | 인증서가 준비된 후에는 /nginx/conf/full.conf 에서 example.org 로 표기된 부분을 모두 사용자의 도메인으로 변경해 주십시오. |
||
254 | |||
255 | <pre><code class="shell"> |
||
256 | $ vi nginx/full.conf |
||
257 | </code></pre> |
||
258 | |||
259 | **nginx/full.conf** |
||
260 | |||
261 | <pre><code class="shell"> |
||
262 | 2 | 이름없음 | server { |
263 | listen 80; |
||
264 | 1 | 이름없음 | listen [::]:80; |
265 | |||
266 | 3 | 이름없음 | server_name example.org www.example.org; |
267 | 1 | 이름없음 | server_tokens off; |
268 | 2 | 이름없음 | |
269 | location /.well-known/acme-challenge/ { |
||
270 | root /var/www/certbot; |
||
271 | 1 | 이름없음 | } |
272 | |||
273 | location / { |
||
274 | 3 | 이름없음 | return 301 https://example.org$request_uri; |
275 | 1 | 이름없음 | } |
276 | 3 | 이름없음 | |
277 | 1 | 이름없음 | } |
278 | 2 | 이름없음 | |
279 | server { |
||
280 | listen 443 default_server ssl http2; |
||
281 | listen [::]:443 ssl http2; |
||
282 | |||
283 | server_name example.org; |
||
284 | |||
285 | 3 | 이름없음 | ssl_certificate /etc/nginx/ssl/live/example.org/fullchain.pem; |
286 | ssl_certificate_key /etc/nginx/ssl/live/example.org/privkey.pem; |
||
287 | 2 | 이름없음 | |
288 | location / { |
||
289 | 3 | 이름없음 | proxy_pass http://{WAS 서버 IP 주소}:17070/; |
290 | 2 | 이름없음 | } |
291 | } |
||
292 | </code></pre> |
||
293 | 1 | 이름없음 | |
294 | 3 | 이름없음 | 변경이 완료된 파일로 /nginx/conf/default.conf 을 덮어써 주십시오. |
295 | 2 | 이름없음 | |
296 | <pre><code class="shell"> |
||
297 | 3 | 이름없음 | $ cp nginx/full.conf nginx/conf/default.conf |
298 | Overwrite default.conf file? Y |
||
299 | $ docker rm -f b2b.on-premise.web |
||
300 | $ docker-compose -f docker-compose.nginx.yml up -d webserver |
||
301 | 2 | 이름없음 | </code></pre> |
302 | |||
303 | 3 | 이름없음 | **주의사항** |
304 | opKey.jck 는 data encrypt key 입니다. |
||
305 | 해당 파일이 없다면 암,복호화가 되지 못하니 꼭 /store 폴더 내에 있는지 확인 부탁 드립니다. |
||
306 | 2 | 이름없음 | |
307 | h3. 인증서 재발급 및 확인 |
||
308 | |||
309 | 인증서 재발급 명령어는 하기와 같습니다. |
||
310 | |||
311 | <pre><code class="shell"> |
||
312 | $ docker compose run --rm certbot renew |
||
313 | </code></pre> |
||
314 | |||
315 | |||
316 | 인증서 확인 명령어는 하기와 같습니다. |
||
317 | <pre><code class="shell"> |
||
318 | $ docker compose run --rm certbot certificates |
||
319 | </code></pre> |
||
320 | |||
321 | h2. 6. Backup 및 Restore |
||
322 | 1 | 이름없음 | |
323 | | 항목 | 내용 | 비고 | |
||
324 | 3 | 이름없음 | | Backup | myd-data-server Repository 내에 data 폴더에 있는 /store/* 와 /mysql/* 파일들을 저장해야 합니다. | | |
325 | 1 | 이름없음 | | Restore | 위에서 저장해둔 파일들을 data 폴더 내에 붙여넣습니다. | | |
326 | |||
327 | h2. 6. Trouble Shooting |
||
328 | |||
329 | h3. 6.1 Capturing log |
||
330 | |||
331 | 2 | 이름없음 | **Docker log 를 log file 로 뽑아오기** |
332 | |||
333 | 1 | 이름없음 | <pre><code class="shell"> |
334 | $ docker logs b2b.on-premise > log1.txt |
||
335 | $ docker logs b2b.on-premise.db > log2.txt |
||
336 | $ docker logs Data-Analysis > log3.txt |
||
337 | 2 | 이름없음 | $ ls -al |
338 | 1 | 이름없음 | </code></pre> |
339 | 2 | 이름없음 | |
340 | 1 | 이름없음 | |
341 | 이렇게 진행하시면 log1.txt, log2.txt, log3.txt 파일이 생긴 것을 확인하실 수 있습니다. |
||
342 | 문제가 있는 경우엔 해당 파일을 SNPLAB로 보내주시면 되겠습니다. |
||
343 | |||
344 | h3. 6.3 Application Error |
||
345 | |||
346 | h3. 5.4 Terminal Error |