| 일수 | 일자 | 교과목 | 내용 | 편성시간 |
|---|---|---|---|---|
| 3 | 24/11/22 | 기반기술 | 소프트웨어공학 | 8 |
[소프트웨어 공학에서 배우는 것]
1. 프로젝트 진행하는 법
2. 프로그램을 잘 만드는 법
- TDD
- 코딩 컨벤션
- Git & Github
3. 아키텍처
- SW 아키텍처
- 시스템 아키텍처 (V)오늘 배울 것
uri : 인터넷상의 리소스 "자원 자체"를 식별하는 고유한 문자열 시퀀스
url : 네트워크상에서 통합자원(리소스)의 위치(locate) - 자원 식별자와 위치를 동시에

출처: https://www.elancer.co.kr/blog/detail/74
고가용성 = Hight Availability(HA)
무결성
기밀성
WEB
: 달라는 것만 줌 (코드 실행 x) => 프론트 엔드
Worker Node ( WAS )
: 코드를 실행시키고 그 결과값을 줌 => 백 엔드
프론트엔드와 백엔드를 나누는 기준은 누구의 컴퓨터에서 실행되는 코드인가의 차이이다.
로드 밸런싱 기능 제공
간단하게 말하면 서버 앞단에 존재해 서버로 오는 요청을 대신 받아 뒷단의 서버에 전달하고 결과를 리턴받아 요청한 곳에 다시 전달

출처: https://dev-youngjun.tistory.com/97
network:
renderer: networkd
ethernets:
ens33:
addresses:
- 10.10.10.100/24
nameservers:
addresses: [8.8.8.8]
routes:
- to: default
via: 10.10.10.2
version: 2

bind *:9000 #접속 포트 지정
mode http
option dontlog-normal
stats enable
stats realm Haproxy\ Statistics #브라우저 타이틀
stats uri /stats #stat를 제공할 uri


apt install -y net-tools
netstat -anlp | grep :9000

frontend webserver
bind *:80 #포트번호 주의
mode http
default_backend nginx-server
backend nginx-server
mode http
balance roundrobin
option httpchk GET /
server nginx1 10.10.10.10:80 check
server nginx2 10.10.10.20:80 check
여기서 만약 현재 서버 리눅스에 만약 ngix가 설치되어있거나 80번 포트를 다른 프로그램이 사용하고 있다면 haproxy가 적용될 수 없으므로 (하나의 프로그램이 여러 포트 번호를 사용하는 것은 가능하나, 이미 사용중인 포트번호를 다른 컴퓨터가 사용하는 건 불가능) 다른 포트 번호로 바꿔준다

여기서부터는 조퇴로 인해 실습 내용을 보고 집에서 혼자 연습

위와 같은 창이 뜬다면 그냥 엔터를 눌러 넘어가면 된다

bind-address = 0.0.0.0 #지정된 주소 없음 (모든 IP 허용)
[DB 서버]
(DB 서버가 될 새로운 가상 컴퓨터를 하나 더 생성 후 진행)
CREATE USER '이니셜'@'%' IDENTIFIED BY 'qwer1234'; #계정 생성
SELECT user, host FROM mysql.user; #생성 확인

GRANT ALL PRIVILEGES ON 3tier.* TO '이니셜'@'%'; #계정에 권한 부여
FLUSH PRIVILEGES; #권한 적용
[was 서버]
(was서버가 될 새로운 가상 컴퓨터를 하나 더 생성 후 진행)
export DB_URL=jdbc:mariadb://10.10.10.30:3306/3tier #DB 서버의 IP
export DB_USERNAME=이니셜 #DB에서 생성했던 이름
export DB_PASSWORD=qwer1234
[다시 DB 서버로]
[오늘 최종 확인]
윈도우에서 웹 브라우저로 was 서버의 IP에 8080 포트의 /student/list로 접속
http://[was의 IP]:8080/student/list

web 서버
upstream backend_servers {
server 10.10.10.40:8080;
server 10.10.10.60:8080;
}
location / { ~ } 아래 쪽에 다음 내용 추가
location /api/ {
rewrite ^/api(/.*)$ $1 break; # /api 제거
proxy_pass http://backend_servers; # 백엔드 서버 주소와 포트
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
systemctl status nginx
apt install -y net-tools
netstat -anlp | grep :80
윈도우에서 웹 브라우저로 nginx 서버의 IP에 80 포트의 /로 접속
http://10.10.10.100:80/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch Student List</title>
</head>
<body>
<button id="fetchButton">학생 리스트 가져오기</button>
<ul id="studentList"></ul>
<script>
document.getElementById('fetchButton').addEventListener('click', async () => {
try {
const response = await fetch('/api/student/list', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json(); // 서버로부터 받은 데이터
displayStudentList(data); // 데이터를 화면에 표시
} catch (error) {
console.error('Error fetching student list:', error);
}
});
function displayStudentList(studentList) {
const listElement = document.getElementById('studentList');
listElement.innerHTML = '';
studentList.forEach(student => {
const listItem = document.createElement('li');
listItem.textContent = `학생 번호: ${student.idx}, 학생 이름: ${student.name}, 학생 나이: ${student.age}`;
listElement.appendChild(listItem);
});
}
</script>
</body>
</html>