CLOUD/[P] 실시간 채팅 프로그램

[WebSocket/Django] 2계층 설계 + 템플릿 선정

alsruds 2023. 3. 22. 04:08

20230306

 

[ 2계층 아키텍처 ]

◎ 구성

▶ HAProxy : 200.200.200.140

Django + Apache 2대 : 200.200.200.141, 200.200.200.142

MySQL 2대 : 200.200.200.143, 200.200.200.144

 

 

● HAProxy

# 설치
yum install -y haproxy

# 파일 설정 : vi /etc/haproxy/haproxy.cfg
# 내용 추가
listen stats
    bind :9000
    stats enable
    stats realm Haproxy\ Statistics
    stats uri /haproxy_stats

listen httpd
      bind 0.0.0.0:80
      mode http
      balance roundrobin

      server web1 200.200.200.141:80 check	# django-apache server ip
      server web2 200.200.200.142:80 check

# 방화벽 해제
systemctl stop firewalld
systemctl disable firewalld
setenforce 0

# 실행
systmctl restart haproxy

 

Django + Apache

》 기본 설정

2023.03.06 - [분류 전체보기] - [Django] 웹페이지 배포하기

 

[Django] 웹페이지 배포하기

※ CentOS8 / PyCharm 사용 ※ 배포할 웹페이지는 만든 상태 [ PyCharm ] ● 라이브러리 목록 생성 pip freeze > requirements.txt 》 다른 운영체제에서도 깔아줘야 하는 목록 ● 서버로 프로젝트 파일 옮기기 》

alsrudalsrudalsrud.tistory.com

 

Channel Layer 이용 배포 참고

[Django] Django Channels 배포 서버에서 사용하기 (Apache) (tistory.com)

 

[Django] Django Channels 배포 서버에서 사용하기 (Apache)

정말 도움이 많이 된 블로그를 먼저 언급하겠다. 설명이 잘 되어있어서 뭘 해야할지 이해하기가 쉬웠다. victorydntmd.tistory.com/265 [Django] Django Channels 배포 ( Nginx + Daphne + SSL ) Daphne Django와 WebServer가

dodormitory.tistory.com

 

MySQL

CentOS 8 VMware

# 설치
yum install mysql-server

# 실행
systemctl start mysqld
systemctl enable mysqld
mysql -u root

# database 생성
create database data01;

# user 생성 + 권한 주기
create user 'user01'@'%' identified by 'qwer1234';
grant all privileges on data01.* to 'user01'@'%';

# 재시작
systemctl restart mysqld

# 방화벽 해제
systemctl stop firewalld
systemctl disable firewalld

 

pycharm project 연동 : settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'data01',
        'USER': 'user01',
        'PASSWORD': 'qwer1234',
        'HOST': '200.200.200.143',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': 'SET sql_mode="STRICT_TRANS_TABLES"'
        }
    }
}

 

[ Template ]

https://github.com/kindfamily/f-instagram

 

GitHub - kindfamily/f-instagram: 인스타그램 html,css,js파일

인스타그램 html,css,js파일. Contribute to kindfamily/f-instagram development by creating an account on GitHub.

github.com

인스타그램