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