1. Oracle VirtualBox 설치
VirtualBox-7.2.4-170995-Win.exe
Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack
확장 - 설치 : Oracle_VirtualBox_Extension_Pack-7.2.4.vbox-extpack
2. Oracle VirtualBox 관리자 - 새로만들기
- Virtual machine name and operating system
VM Name : ZX1(10.10.0.100)
VM Folder : C:\VMs\VBOX
ISO Image : C:\VMs\Setup\ubuntu-24.04.4-live-server-amd64.iso
(체크안함) Proceed with Unattended Installation : 무인설치건너뛰기
- Specify virtual hardware
Base Memory : 4096 MB
Number of CPUs : 2
- specify virtual hard disk
Create a New Virtual Hard Dsik
D:\VMs\VBOX\ZX1(10.10.0.100)\ZX1(10.10.0.100).vdi
25.00GB
--완료
- 네트워크
어댑터1 : (체크)네트워크 어댑터 활성화
Attached to : NAT
포트포워딩
apache2 TCP 80 80
apache2_ssl TCP 443 443
어댑터2 : (체크)네트워크 어댑터 활성화
Attached to : 호스트전용어댑터
--시작
--ubuntu 설치
# 1. root 계정 비밀번호 활성화
sudo passwd root
# 현재 비밀번호(@서버암호), 새 UNIX 비밀번호(@서버암호) 입력
# 2. root 계정으로 전환
su -
# 3. netplan 고정 IP 설정 파일 정돈 (/etc/netplan/01-netcfg.yaml)
rm -f /etc/netplan/50-cloud-init.yaml
vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
enp0s3:
dhcp4: yes
enp0s8:
dhcp4: no
addresses: [10.10.0.100/24]
:wq
netplan apply
# 4. OpenSSH 보안 설정
vi /etc/ssh/sshd_config
PermitRootLogin yes
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256
MACs hmac-sha2-256,hmac-sha2-512
:wq
systemctl restart ssh
# 5. 공유폴더 설정
# 기존 wwwroot 디렉터리 백업 및 정리
# 기존 폴더 백업
mv /storage/wwwroot /storage/wwwroot_backup
# 마운트 포인트 새 디렉터리 생성
mkdir -p /storage/wwwroot
ls -ld /storage/wwwroot
# VirtualBox 게스트 확장(Guest Additions) 설치
sudo apt update
sudo apt install -y build-essential dkms linux-headers-$(uname -r)
sudo apt install -y virtualbox-guest-utils
modinfo vboxsf
# VirtualBox 공유 폴더 설정
# VBox콘솔메뉴 : 장치 - 공유폴더 - 머신폴더 하위에 추가 - 폴더선택
폴더경로 : D:\VMs\antigravity_wwwroot
폴더이름 : wwwroot
(체크해제) 읽기전용
(체크해제) 자동마운트 --부팅 시 자동 마운트 설정 (/etc/fstab)
(체크) Make Machine-permanent
(체크해제) Make Global
# 수동 마운트 테스트 및 웹 서버 권한 부여
sudo usermod -aG vboxsf $USER
sudo usermod -aG vboxsf www-data
sudo mount -t vboxsf -o rw,uid=$(id -u www-data),gid=$(id -g www-data),dmode=775,fmode=664 wwwroot /storage/wwwroot
# 부팅 시 자동 마운트 설정 (/etc/fstab)
vi /etc/fstab
wwwroot /storage/wwwroot vboxsf rw,uid=www-data,gid=www-data,dmode=775,fmode=664,_netdev 0 0
:wq
umount /storage/wwwroot
mount -a
(권한)chmod +x /storage/wwwroot/*.sh
(실행)bash /storage/wwwroot/server.sh
#######################################################
Proxmox 서버 부팅시간 5분
#######################################################
--Proxmox 설치(10분소요)
Dell R420 (vCPU x32, RAM x64GB, SSD 250GB, HDD 1TB x3)
Install Proxmox VE (Graphical)
1) END USER LICENSE AGREEMENT (EULA) - [I agree]
2) Proxmox Virtual Environment (PVE)
Filesystem : ext4
Target Harddisk : /dev/sda (232.83Gib)
[Next]
3) Location and Time Zone selection
Country : South Korea
Time zone : Asia/Seoul
Keyboard Layout : U.S.English
4) Administration Password and Email Address
Password : @서버암호
Confirm : @서버암호
Email : name@compnay
5) Management Network Configuration
Management Interface : nic0 - 3x:07:54:05:b3:a9 (tg3)
Hostname (FQDN) : node1.local --node(서버물리번호).local
IP Address (CIDR) : 192.168.0.5 / 24
Gateway : 192.168.0.1
DNS Server : 8.8.8.8
(체크)Pin network interface names
6) Summary
(체크)Automatically reboot after successful installation
[Install]
(10분소요)
#######################################################
--Proxmox 접속
https://192.168.0.5:8006/
root@pam - Language : 한국어 - Korean
(체크)사용자이름저장 - 로그인
데이터센터 - 노드 (node1) - Proxmox 쉘(Shell) 실행
--우분투의 모든패키지를 최신버전으로 업그레이드
# apt update && apt upgrade -y
# apt install -y vim net-tools parted
--Subscription 경고제거 완전 제거 (JavaScript 수정)
cp /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.bak
sed -i '/data\.status/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
systemctl restart pveproxy.service
--고정크기 디스크
데이터센터 - 스토리지 - 추가 - 디렉토리
ID : local-storage
디렉토리 : /storage
(체크)사용
내용 : 디스크이미지, 백업, ISO이미지
--ISO이미지 업로드
데이터센터 - 노드 (node1) - local-storage(node1) - ISO 이미지 - 업로드 - ubuntu-24.04.4-live-server-amd64.iso
starting file import from: /var/tmp/pveupload-215c434cca27452c7492d3a3288cf2ee
target node: node1
target file: /var/lib/vz/template/iso/ubuntu-24.04.4-live-server-amd64.iso
file size is: 3405469696
command: cp -- /var/tmp/pveupload-215c434cca27452c7492d3a3288cf2ee /var/lib/vz/template/iso/ubuntu-24.04.4-live-server-amd64.iso
finished file import successfully
TASK OK
--------------------------------------------------------------------------
(백업)가상머신 - 4분
데이터센터 - 노드(node1) - 100(ZX1) - 백업
스토리지 : local-storage
압축 : ZSTD(빠르고좋음)
모드 : 스냅샷
통지 : 글로벌 설정 사용
(복원)가상머신 - 3분
데이터센터 - 노드(node1) - local-storage(node1) - 백업 - 복원
스토리지 : local-storage
VM : 101(VM번호)
대역폭 제한 : 기본값 0(제한없음)
대역폭 제한 : 야간,빠른복원일경우 0 (제한없음)
대역폭 제한 : 업무시간일경우 30-50 (MiB/s) 가용성확보
(복제)가상머신 - 4분
데이터센터 - 노드(node1) - 100(ZX1) - 복제
대상모드 : node1
대상스토리지 : 소스와동일
VM ID: 101
이름 : DX1
리소스풀: (없음)
--우분투의 모든패키지를 최신버전으로 업그레이드
# apt update && apt upgrade -y
--MobaXterm에서 vi 또는 vim 편집기를 사용하다가 화면 하단에 -- VISUAL -- (비주얼 모드)
:set mouse-=a
#######################################################
Proxmox 서버
--네크워크추가 (내부네트워크-포트포워딩)
데이터센터 - 노드(node1) - 네크워크 - 생성 - Linux Bridge
이름 : vmbr1
IPv4/CIDR : 10.10.0.1/24
(체크)자동시작
[구성적용]
데이터센터 - 노드 (node1) - Proxmox 쉘(Shell) 실행
--호스트 패킷 포워딩 활성화
# cat /proc/sys/net/ipv4/ip_forward
1이 나오면 이미 활성화된 상태입니다
0이 나온다면 아래 단계를 진행하세요
# vi /etc/sysctl.conf
net.ipv4.ip_forward=1
:wq
--설정을 즉시 적용
# sysctl -p
--마스커레이드(NAT Outbound) 설정 확인
# vi /etc/network/interfaces
auto lo
iface lo inet loopback
iface nic0 inet manual
auto vmbr0
iface vmbr0 inet static
address 192.168.0.5/24
gateway 192.168.0.1
bridge-ports nic0
bridge-stp off
bridge-fd 0
auto vmbr1
iface vmbr1 inet static
address 10.10.0.1/24
bridge-ports none
bridge-stp off
bridge-fd 0
#포트포워딩활성화(NAT)
post-up iptables -t nat -A POSTROUTING -s 10.10.0.0/24 -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s 10.10.0.0/24 -o vmbr0 -j MASQUERADE
#포트포워딩(WEB)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to-destination 10.10.0.101:80
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 80 -j DNAT --to-destination 10.10.0.101:80
#포트포워딩(SSL)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to-destination 10.10.0.101:443
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 443 -j DNAT --to-destination 10.10.0.101:443
#포트포워딩(CHAT)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 9100 -j DNAT --to-destination 10.10.0.101:9100
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 9100 -j DNAT --to-destination 10.10.0.101:9100
#포트포워딩(MYSQL)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 33210 -j DNAT --to-destination 10.10.0.201:3306
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 33210 -j DNAT --to-destination 10.10.0.201:3306
#포트포워딩(SAMBA)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 44101 -j DNAT --to-destination 10.10.0.101:445
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 44101 -j DNAT --to-destination 10.10.0.101:445
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 44210 -j DNAT --to-destination 10.10.0.210:445
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 44210 -j DNAT --to-destination 10.10.0.210:445
#포트포워딩(TELNET)
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22101 -j DNAT --to-destination 10.10.0.101:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22101 -j DNAT --to-destination 10.10.0.101:22
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22201 -j DNAT --to-destination 10.10.0.201:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22201 -j DNAT --to-destination 10.10.0.201:22
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22210 -j DNAT --to-destination 10.10.0.210:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22210 -j DNAT --to-destination 10.10.0.210:22
post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 22254 -j DNAT --to-destination 10.10.0.254:22
post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 22254 -j DNAT --to-destination 10.10.0.254:22
:wq
# ifreload -a
--NAT 규칙 확인
# iptables -t nat -L -n -v
Forward 규칙 확인
# iptables -L FORWARD -n -v
--IP Forward 확인
# cat /proc/sys/net/ipv4/ip_forward
#######################################################
Proxmox 서버 - ZX1
--우분투설치(Ubuntu24.04 + php8.3)
--STEP1 : Ubuntu24.04 운영체제설치(10분소요)
--STEP1-1 : Ubuntu24.04 운영체제설치
*Try or Install Ubuntu Server
1) Welcome:Use Up,Down and ENTER keys to select your language. : [English](엔터)
2) Intaller update available : [Continue without updating](엔터)
3) Keyboard configuration
Layout: [English]
Variant: [English] : [Done](엔터)
Choose the type of installation
**[X] Ubuntu Server
4) Network connections : [Done](엔터)
5) Configure proxy
Proxy address: (공백) : [Done](엔터)
Configure ubuntu archive mirror
Mirror address : http://kr.archive.unbutu.com/ubuntu
[Done](엔터)
6) Guided storage configuration
(X)Use an entire disk
[X]Set up this disk as an LVM group : [Done](엔터)
7) Storage configuration
FILE SYSTEM SUMMARY : [Done](엔터)
**7) Confirm destructive action : [Continue](엔터)
**8) Profile configuration
Your name : ubuntu
Your server's name : ubuntu
Pick a ubsername : ubuntu
Choose a password : @서버암호
Confirm your a password : @서버암호
[Done](엔터)
9) SSH Setup : [Done](엔터)
10) Featured Server Snaps : [Done](엔터)
[Reboot Now]
Rebooting...
(10분소요)
--OS버전확인
login : ubuntu
password : @서버암호
$ lsb_release -a :버전확인
--root암호설정
$ sudo passwd root
passwd for ubuntu:[현재로그인계정암호]
Enter new UNIX password:[root계정암호]
Retry new UNIX password:[root계정암호]
$ exit
--root로그인
# ifconfig
# ip link show
# ls /sys/class/net
ens18 lo
# rm -f /etc/netplan/50-cloud-init.yaml
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [10.10.0.101/24]
routes:
- to: default
via: 10.10.0.1
nameservers:
addresses: [8.8.8.8, 168.126.63.1]
:wq
# netplan apply
--우분투의 모든패키지를 최신버전으로 업그레이드
# apt update && apt upgrade -y
--시간설정
# apt install timedatectl
# timedatectl set-timezone Asia/Seoul
# timedatectl
--STEP1-2 : 네트워크설정
--네트워크도구설치
# apt install -y vim net-tools
--STEP1-3 : telnet설정
--텔넷서버 설치
# apt install -y xinetd telnetd vsftpd openssh-server
--텔넷서버 환경설정 추가
# vi /etc/xinetd.conf
defaults{...}
(추가:13)
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure = USERID
}
:wq
--텔넷서버 재시작
# systemctl restart xinetd
--OpenSSH설정
--SSH 환경설정수정:root접속
# vi /etc/ssh/sshd_config
# PermitRootLogin prohibit-password
(추가:43)
PermitRootLogin yes
Ciphers aes128-ctr,aes192-ctr,aes256-ctr
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group14-sha256
MACs hmac-sha2-256,hmac-sha2-512
:wq
# systemctl restart ssh
# systemctl status ssh
Active: active (running)
# ss -nlt
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
--방화벽 포트추가
(활성화)# ufw enable
# ufw status
Status: active
# ufw allow ssh
[SSH] MobaXterm 접속
--Proxmox 호스트가 10.10.0.254라는 가상머신 SSH접속
# ssh root@10.10.0.254
--------------------------------------------------------------------------
--STEP1-4 : vsftp설정
--vsftp환경설정수정
# vi /etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES
(수정:31-주석제거)write_enable=YES
(수정:114-주석제거)chroot_local_user=YES
(추가:115)
allow_writeable_chroot=YES
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40100
:wq
# systemctl restart vsftpd
--FTP 환경설정수정:root접속
# vi /etc/ftpusers
(수정:3)#root
:wq
#######################################################
--STEP2 : APACHE2+PHP 설치
--STEP2-1 : APACHE2+PHP 설치
# apt update && apt upgrade -y
# apt install -y software-properties-common
# add-apt-repository ppa:ondrej/php -y
# ls /etc/apt/sources.list.d/
ondrej-ubuntu-php-noble.sources ubuntu.sources ubuntu.sources.curtin.orig
# apt install -y apache2 php8.3 libapache2-mod-php8.3 php8.3-cli php8.3-common php8.3-fpm php8.3-mysql php8.3-gd php8.3-curl php8.3-mbstring php8.3-xml php8.3-zip php8.3-bcmath php8.3-intl php8.3-imap php8.3-imagick php-pear php8.3-dev
--php버전확인
# php -v
PHP 8.3.31 (cli) (built: May 7 2026 18:51:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.31, Copyright (c) Zend Technologies
with Zend OPcache v8.3.31, Copyright (c), by Zend Technologies
--STEP2-2 : PHP설정
# vi /etc/apache2/mods-available/php8.3.conf
(추가:6)
SetHandler application/x-httpd-php
:wq
--PHP디버깅
# vi /etc/php/8.3/apache2/php.ini
(수정:208)short_open_tag = On #PHP 시작 태그를 표준 형태인 > ~/.bashrc
echo 'export PATH=/var/www/.npm-global/bin:$PATH' >> ~/.profile
--설치 경로 확인
www-data@ubuntu:~$ which pm2
/var/www/.npm-global/bin/pm2
www-data@ubuntu:~$ exit
--관리자계정에서 PM2 list 보기
# vi ~/.bashrc
(추가:100)
alias pm2-www='sudo -u www-data -i pm2'
:wq
# source ~/.bashrc
# pm2-www list
--STEP2-5 : MySQL 설치
# apt update && apt upgrade -y
# apt install -y mysql-server mysql-client php-mysql
# mysql -V
mysql Ver 8.0.45-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))
--MySQL 접속 권한 및 계정 설정(@서버암호)
# mysql -uroot -p@서버암호
-- 유저 정보 확인
mysql> SELECT HOST, USER, PLUGIN FROM mysql.user;
-- 모든 IP(%)에서 접속 가능한 root 계정 생성 및 권한 부여
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
-- 로컬 접속 플러그인 및 비밀번호 업데이트
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '@서버암호';
-- root 계정을 모든 호스트(%)에서 접속 가능
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '@서버암호';
-- 설정 반영 및 종료
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
--MySQL 서비스 중지
# systemctl stop mysql
--STEP2-6 : NFS, SAMBA 설치
# apt update && apt upgrade -y
# apt install -y nfs-kernel-server nfs-common samba
(백업)ZX1_apache2_php_nodejs_pm2_mysql_nfs_samba
--백업 : 가상머신
데이터센터 - 노드(node1) - 100(ZX1) - 백업
스토리지 : local-storage
압축 : ZSTD(빠르고좋음)
모드 : 스냅샷
통지 : 글로벌 설정 사용
(복원)가상머신
데이터센터 - 노드(node1) - local-storage(node1) - 백업 - 복원
스토리지 : local-storage
VM : 101(VM번호)
대역폭 제한 : 기본값 0(제한없음)
대역폭 제한 : 야간,빠른복원일경우 0 (제한없음)
대역폭 제한 : 업무시간일경우 30-50 (MiB/s) 가용성확보
(복원)백업파일경로
/storage/dump/vzdump-qemu-100-2026_07_05-16_47_53.vma.zst (백업 본체)
vzdump-qemu-100-2026_07_05-16_47_53.log (작업 로그)
vzdump-qemu-100-2026_07_05-16_47_53.vma.zst.notes (백업 메모)
[SSH] MobaXterm 접속
# ssh root@10.10.0.254
--apache2_before
#######################################################
--STEP3 : APACHE + PHP 환경설정
--STEP3-1 : APACHE2환경설정
# vi /etc/apache2/apache2.conf
(수정:170-주석처리)
#
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#
(추가:175)
Options FollowSymLinks
AllowOverride None
Require all granted
:wq
--STEP3-2 : Apache logrotate 로그설정
# cp /etc/logrotate.d/apache2 /etc/logrotate.d/apache2.old
# vi /etc/logrotate.d/apache2
(전체삭제)/var/log/apache2/*.log {..}
/storage/logs/apache2/*.log {
daily
rotate 14
size 100M
compress
delaycompress
missingok
notifempty
create 640 root adm
sharedscripts
postrotate
systemctl reload apache2 > /dev/null
endscript
}
:wq
# vi /etc/apache2/sites-available/000-default.conf
(수정:12)
DocumentRoot /storage/wwwroot
(추가:14)오류페이지처리
ErrorDocument 400 /core/error.html
ErrorDocument 401 /core/error.html
ErrorDocument 403 /core/error.html
ErrorDocument 404 /core/error.html
ErrorDocument 500 /core/error.html
ErrorDocument 502 /core/error.html
ErrorDocument 503 /core/error.html
(수정:27)
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog /storage/logs/apache2/localhost-80-error.log
CustomLog /storage/logs/apache2/localhost-80-access.log combined
:wq
mkdir -p /storage/wwwroot
mkdir -p /storage/logs/apache2
chown -R www-data:www-data /storage/logs/apache2
chmod 750 /storage/logs/apache2
apache2ctl configtest
a2enmod rewrite
a2ensite 000-default.conf
systemctl restart apache2
--HTTPS 포트(80)가 열려 있는지 확인하고 허용합니다.
ufw delete allow 'Apache'
ufw allow 'Apache Full'
ufw allow 9100/tcp
ufw status
Status: active
To Action From
-- ------ ----
22/tcp ALLOW Anywhere
Apache Full ALLOW Anywhere
9100/tcp ALLOW Anywhere
22/tcp (v6) ALLOW Anywhere (v6)
Apache Full (v6) ALLOW Anywhere (v6)
9100/tcp (v6) ALLOW Anywhere (v6)
--접속경로(/storage/wwwroot)
# vi /storage/wwwroot/phpinfo.html
(접속)http://192.168.0.5/phpinfo.html
#######################################################
Proxmox 서버 - DX1
메모리 : 4096, 프로세서 2(1 socket, 2 cores)
# ifconfig
# ip link show
# ls /sys/class/net
ens18 lo
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [10.10.0.201/24]
routes:
- to: default
via: 10.10.0.1
nameservers:
addresses: [8.8.8.8, 168.126.63.1]
:wq
# netplan apply
-- MySQL 설정 업데이트
# vi /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
(추가:15)
datadir = /storage/mysql/data
bind-address = 0.0.0.0
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4'
innodb_file_per_table = 1
log_error = /storage/mysql/logs/mysql.log
slow_query_log = 1
slow_query_log_file = /storage/mysql/logs/mysql-slow.log
# InnoDB 메모리 (RAM 8GB 6G 4,RAM 4GB 3G, 2)
innodb_buffer_pool_size = 3G
innodb_buffer_pool_instances = 2
# InnoDB 로그 (버퍼 풀 사이즈 8GB 1G, 64M, 4GB 512M 32M)
innodb_log_file_size = 512M
innodb_log_buffer_size = 32M
# InnoDB I/O (CPU 2Core 2, 4Core 4)
innodb_read_io_threads = 2
innodb_write_io_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
# 임시 테이블 (메모리 부족 방지를 위해 축소)
tmp_table_size = 128M
max_heap_table_size = 128M
# 정렬 / 조인 버퍼
join_buffer_size = 2M
sort_buffer_size = 2M
# 연결 (싱크 서버 목적에 맞춰 축소)
thread_cache_size = 16
max_connections = 150
(주석:62)
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
(주석:93)
#log_error = /var/log/mysql/error.log
:wq
--MySQL 서비스 재시작
# systemctl restart mysql
/storage/wwwroot 폴더삭제
/storage/mysql_backup 폴더생성
/storage/mysql_backup/20260804 백업파일복사
http://192.168.0.5/master/data_tools.html
#######################################################
Proxmox 서버 - NX1
메모리 : 2048, 프로세서 1(1 socket, 1 cores)
# ifconfig
# ip link show
# ls /sys/class/net
ens18 lo
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [10.10.0.101/24]
routes:
- to: default
via: 10.10.0.1
nameservers:
addresses: [8.8.8.8, 168.126.63.1]
:wq
# netplan apply
# ufw status
--STEP6-1 : NFS 서버(10.10.0.210) 설정
--공유할 폴더 생성
# mkdir -p /storage/wwwroot/files
# chmod 777 /storage/wwwroot/files
--exports 설정(핵심)
--10.10.0.x 대역 허용, 읽기/쓰기 가능
# vi /etc/exports
/storage/wwwroot/files 10.10.0.0/24(rw,sync,no_subtree_check,no_root_squash)
:wq
# exportfs -rav
# systemctl restart nfs-kernel-server
--방화벽
# ufw allow from 10.10.0.0/24 to any port nfs
--STEP6-2 : NFS 클라이언트(10.10.0.101) 설정
--NFS 클라이언트 마운트
# apt install -y nfs-common
# mkdir -p /storage/wwwroot/files
# mount -t nfs 10.10.0.210:/storage/wwwroot/files /storage/wwwroot/files
--자동 마운트
# vi /etc/fstab
10.10.0.210:/storage/wwwroot/files /storage/wwwroot/files nfs defaults,_netdev,nofail 0 0
:wq
# mount -a
--소유권 변경 : 해당 디렉토리에 대한 쓰기 권한을 가지고 있어야 합니다.
# chown -R www-data:www-data /storage/wwwroot
# chmod -R 755 /storage/wwwroot
(오류)# mv /storage/wwwroot/files1/* /storage/wwwroot/files/
--rsync 명령어로 files1의 내용을 files로 안전하게 복사 (동기화)
# rsync -av --progress /storage/wwwroot/files1/ /storage/wwwroot/files/
--복사가 완벽하게 끝났는지 확인
# ls -la /storage/wwwroot/files/
--데이터가 잘 들어간 것을 확인한 후, 기존 원본 폴더 삭제 (선택 사항)
# rm -rf /storage/wwwroot/files1
--현재 디렉토리 용량
# du -sh .
--현재 디렉토리 용량
# du -sh /storage/wwwroot/files
--하위 디렉토리 용량
# du -sh /storage/wwwroot/files/*
# du -sh /storage/wwwroot/files/* | sort -h
--전체 디스크 사용량
# df -h
#######################################################
Proxmox 서버 - AX1
메모리 : 2048, 프로세서 1(1 socket, 1 cores)
# ifconfig
# ip link show
# ls /sys/class/net
ens18 lo
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [10.10.0.101/24]
routes:
- to: default
via: 10.10.0.1
nameservers:
addresses: [8.8.8.8, 168.126.63.1]
:wq
# netplan apply
# systemctl restart apache2
--wwwroot (libs, core, cube, master) 폴더복사
/core/api/_setup.do
$auth_server = [ 'host' => '10.10.0.201', ..] // 인증서버,의약품표준코드 IP
$data_server
$trace_server
$switch_server
/master/data_tools.html
var server_ip = {
'http' : '10.10.0.101',
'auth' : '10.10.0.200',
'data' : '10.10.0.201',
'sync' : '10.10.0.202',
'switch' : '10.10.0.203'
};
--/storage/wwwroot/master/*.sh 권한설정
chmod +x /storage/wwwroot/master/*.sh
--SAMBA
# vi /etc/samba/smb.conf
(추가:1)
[wwwroot]
comment = wwwroot
path = /storage/wwwroot
read only = no
writable = yes
browsable = yes
valid users = root
create mask = 0777
directory mask = 0777
:wq
[wwwroot]
comment = wwwroot #공유폴더설명
path = /storage/wwwroot #공유할폴더경로
read only = no #읽기전용아님
writable = yes #쓰기가능
browsable = yes #폴더내용탐색가능
valid users = root #접속가능사용자계정
create mask = 0777 #파일권한
directory mask = 0777 #디렉토리권한
# smbpasswd -a root
New SMB password: @서버암호
Retype new SMB password: @서버암호
Added user root.
# systemctl restart smbd
# ufw allow 139,445/tcp
# systemctl status smbd
--윈도우탐색기
\\192.168.0.5\wwwroot
계정 : root
암호 : @서버암호
(체크)내자격증명기억
--윈도우설정
서버관리자-역할및기능추가-기능선택-SMB1.0/CIFS File Sharing Support
네트워크 폴더 자격 증명 삭제(오류일경우 액세스가 거부되었습니다)
> net use \\192.168.0.5\wwwroot /delete
--소유권 변경 : 해당 디렉토리에 대한 쓰기 권한을 가지고 있어야 합니다.
# sudo mkdir -p /storage/wwwroot/files
# sudo chown -R www-data:www-data /storage/wwwroot
# sudo chmod -R 755 /storage/wwwroot
--바인드 마운트(리눅스 마운트 방식)
--데이터이동
# sudo mkdir -p /storage/wwwroot/files
# sudo mv /storage/wwwroot/files/* /mnt/storage/wwwroot/files/
--바인드 마운트
# sudo mount --bind /storage/wwwroot/files /mnt/storage/wwwroot/files
# sudo chown -R www-data:www-data /storage/wwwroot/files
--자동마운트
# vi /etc/fstab
(추가:14)
/storage/wwwroot/files /mnt/storage/wwwroot/files none bind 0 0
--마운트확인
# sudo mount -a
--(선택)마운트해제
# sudo umount /mnt/storage/wwwroot/files
#######################################################
(initramfs) fsck /dev/mapper/ubuntu--vg-ubuntu--lv -y
(initramfs) reboot
--APACHE2 SSL서버인증서 설치
--mkcert 설치
20260802
1.Proxmox 접속(192.168.0.5:8006)
포트포워드 설정
DX : ip설정, mysql 실행, 데이터베이스 복원
AX : mkcert 설치, ssl접속
--Certbot 설치
--Let's Encrypt 인증서를 자동으로 발급하고 관리해주는 Certbot 패키지를 설치합니다.
# apt update && apt upgrade -y
# apt install certbot python3-certbot-apache -y
--인증서가 Certbot에 등록상태 확인
# certbot certificates
--웹루트경로 확인1
# grep -R "DocumentRoot" /etc/apache2/
--웹루트경로 확인2
# vi /etc/apache2/sites-available/000-default.conf
DocumentRoot /storage/wwwroot
--인증서만 재발급 - 인증서가 Certbot에 등록되어 있음
# certbot certonly --webroot -w /storage/wwwroot -d waitbook.co.kr -d www.waitbook.co.kr --email dkjang@naver.com --agree-tos
# certbot certonly --webroot -w /storage/wwwroot -d cube2005.co.kr -d www.cube2005.co.kr --email dkjang@naver.com --agree-tos
--별도의 독립된 인증서 발급
# certbot certonly --webroot -w /storage/wwwroot -d dev.cube2005.co.kr --email dkjang@naver.com --agree-tos
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Keep the existing certificate for now
2: Renew & replace the certificate (may be subject to CA rate limits)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate for cube2005.co.kr and www.cube2005.co.kr
--인증서만 발급 - 인증서가 Certbot에 등록되어 있지않음
# certbot certonly --webroot -w /storage/wwwroot -d cube2005.co.kr -d www.cube2005.co.kr
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
--1: 이메일 입력
(Enter 'c' to cancel): dkjang@naver.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.6-August-18-2025.pdf. You must agree
in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--2: 서비스 약관 동의
(Y)es/(N)o: y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--3: EFF 뉴스레터 구독 여부
(Y)es/(N)o: n
Account registered.
Requesting a certificate for cube2005.co.kr and www.cube2005.co.kr
Unable to change owner and uid of webroot directory
Unable to change owner and uid of webroot directory
--4: 도메인 소유권 확인 및 인증서 발급
도메인 선택: 목록에서 방금 설정한 도메인 번호 선택 (엔터)
Which names would you like to activate HTTPS for?
1: cube2005.co.kr
blank to select all options shown (Enter 'c' to cancel): 1
--5: HTTP 리다이렉트 설정 (HTTPS 전환)
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
--Congratulations! You have successfully enabled https://cube2005.co.kr
--인증서가 /etc/letsencrypt/live/cube2005.co.kr/ 경로에 저장되었다는 안내가 나옵니다.
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem
Key is saved at: /etc/letsencrypt/live/cube2005.co.kr/privkey.pem
This certificate expires on 2026-08-07.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
root@ubuntu:~#
--(해결)Some challenges have failed.
윈도우방화벽(고급보안이포함된WindowsDefender방화벽)-인바운드규칙 : 80
AX1-설정-네트워크-포트포워딩 : apache2(80)
ufw allow 'Apache Full'
# ls /etc/letsencrypt/live/
--Let's Encrypt 인증서는 90일간 유효합니다. Certbot은 자동으로 갱신 타이머를 등록합니다.
# certbot renew --dry-run --post-hook "systemctl reload apache2"
Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/cube2005.co.kr.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Account registered.
Simulating renewal of an existing certificate for cube2005.co.kr and www.cube2005.co.kr
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/cube2005.co.kr/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# vi /etc/apache2/sites-available/default-ssl.conf
(주석:4)
#DocumentRoot /var/www/html
(추가:5)
ServerName cube2005.co.kr
ServerAlias www.cube2005.co.kr
DocumentRoot /storage/wwwroot
ErrorDocument 400 /core/error.html
ErrorDocument 401 /core/error.html
ErrorDocument 403 /core/error.html
ErrorDocument 404 /core/error.html
ErrorDocument 500 /core/error.html
ErrorDocument 502 /core/error.html
ErrorDocument 503 /core/error.html
(추가:22)
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog /storage/logs/apache2/cube2005.co.kr-error.log
CustomLog /storage/logs/apache2/cube2005.co.kr-access.log combined
(추가:44)
#SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
#SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
SSLCertificateFile /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cube2005.co.kr/privkey.pem
:wq
--mod_ssl 모듈활성화
a2enmod ssl
a2ensite default-ssl.conf
apache2ctl configtest
systemctl restart apache2
(안함)# ufw allow 80,443,9100/tcp
--기존 인증서에 도메인 추가 (확장)
--기존에 발급받은 도메인들을 모두 포함하고 새로운 도메인을 추가하여 명령어를 실행합니다.
# certbot --apache --expand -d cube2005.co.kr -d www.cube2005.co.kr -d new-domain.com
--특정 인증서 이름으로 도메인 리스트 교체
--인증서의 이름을 확인한 후 해당 인증서에 연결된 도메인들을 완전히 새로 고침합니다.
# certbot certificates
--해당 이름을 지정하여 도메인 리스트 업데이트
# certbot --apache --cert-name cube2005.co.kr -d new-domain.com -d www.new-domain.com
--도메인을 변경한 후에는 Apache 가상 호스트 설정 파일의 ServerName과 ServerAlias도
새 도메인에 맞게 수정되었는지 확인해야 합니다.
--------------------------------------------------------------------------
--STEP3-5 : Node.js WSS 서버 연동
--WSS(Secure WebSocket) 적용 절차
--SSL 인증서 준비
--chat_server_wss_cube2005.sh 스크립트로 생성된 파일이 이 파일과 같은 경로에 있어야 합니다.
mkdir -p /storage/wwwroot/chat
cd /storage/wwwroot/chat
npm install ws
cp -L /etc/letsencrypt/live/cube2005.co.kr/privkey.pem /storage/wwwroot/chat/cube2005.co.kr_privkey.pem
cp -L /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem /storage/wwwroot/chat/cube2005.co.kr_fullchain.pem
chown www-data:www-data /storage/wwwroot/chat/cube2005.co.kr_privkey.pem
chown www-data:www-data /storage/wwwroot/chat/cube2005.co.kr_fullchain.pem
chmod 600 /storage/wwwroot/chat/cube2005.co.kr_privkey.pem
chmod 644 /storage/wwwroot/chat/cube2005.co.kr_fullchain.pem
sudo -u www-data -i pm2 restart chat_server_wss_cube2005
pm2-www list
ls -l /etc/letsencrypt/live/cube2005.co.kr/
ls -l /storage/wwwroot/chat/
root@ubuntu:~# ls -l /etc/letsencrypt/live/cube2005.co.kr/
total 4
lrwxrwxrwx 1 root root 38 Apr 12 09:45 cert.pem -> ../../archive/cube2005.co.kr/cert2.pem
lrwxrwxrwx 1 root root 39 Apr 12 09:45 chain.pem -> ../../archive/cube2005.co.kr/chain2.pem
lrwxrwxrwx 1 root root 43 Apr 12 09:45 fullchain.pem -> ../../archive/cube2005.co.kr/fullchain2.pem
lrwxrwxrwx 1 root root 41 Apr 12 09:45 privkey.pem -> ../../archive/cube2005.co.kr/privkey2.pem
-rw-r--r-- 1 root root 692 Feb 10 14:40 README
root@ubuntu:~# ls -l /storage/wwwroot/chat/
total 32
-rwxr--r-- 1 root root 8531 Apr 11 21:24 chat_server_wss_cube2005.js
-rw-r--r-- 1 www-data www-data 3610 May 11 15:39 cube2005.co.kr_fullchain.pem
-rw------- 1 www-data www-data 1704 May 11 15:39 cube2005.co.kr_privkey.pem
drwxr-xr-x 3 root root 4096 Feb 10 14:51 node_modules
-rw-r--r-- 1 root root 48 Feb 10 14:51 package.json
-rw-r--r-- 1 root root 753 Feb 10 14:57 package-lock.json
root@ubuntu:~#
--------------------------------------------------------------------------
--STEP3-6 : 채팅서버 - MX1_Apache_MySQL(192.168.56.200)
# /storage/wwwroot/master/chat_server_wss_keycopy.sh
도메인을 입력하세요 (기본: cube2005.co.kr): (엔터)
대상 경로를 입력하세요 (기본: /storage/wwwroot/chat): (엔터)
--www-data 사용자로 전환
# sudo -u www-data -i
--설치 경로 확인
www-data@ubuntu:~$ which pm2
/var/www/.npm-global/bin/pm2
www-data@ubuntu:~$
cd /storage/wwwroot/chat/
pm2 start chat_server_wss_cube2005.js --name chat_server_wss_cube2005
pm2 save --force
pm2 startup
exit
# pm2-www list
# pm2-www restart chat_server_wss_cube2005
--서비스삭제(강제갱신)
# pm2-www delete all
# pm2-www save --force
--PM 명령어
# pm2 start npm --name "" -- start
# pm2 start
# pm2 list
# pm2 save
# pm2 resurrect
# pm2 startup
# pm2 delete all
# pm2 kill
# pm2 start
# pm2 stop
# pm2 restart
# pm2 restart 5 -n rename
# pm2 delete
--PM2 삭제
# pm2 stop all
# pm2 delete all
# pm2 save --force
# npm uninstall -g pm2
# which pm2
# rm -rf /root/.pm2
--AX1_pm2_chatserver
--------------------------------------------------------------------------
--STEP4 : MySQL설정
--STEP4-1 : MySQL 설치(STEP2-5 : MySQL 설치)
# apt update && apt upgrade -y
# apt install -y mysql-server mysql-client php-mysql
# mysql -V
mysql Ver 8.0.45-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))
--MySQL 접속 권한 및 계정 설정(@서버암호)
# mysql -uroot -p@서버암호
-- 유저 정보 확인
mysql> SELECT HOST, USER, PLUGIN FROM mysql.user;
-- 모든 IP(%)에서 접속 가능한 root 계정 생성 및 권한 부여
mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'root';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
-- 로컬 접속 플러그인 및 비밀번호 업데이트
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '@서버암호';
-- root 계정을 모든 호스트(%)에서 접속 가능
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '@서버암호';
-- 설정 반영 및 종료
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
#######################################################
--STEP4-2 : 데이터 저장경로 (/var/lib/mysql -> /storage/mysql/data)
--STEP4-3 : 로그파일 저장경로 (/var/log/mysql -> /storage/mysql/logs)
-- 서비스 중지
# systemctl stop mysql
# systemctl status mysql
--디렉토리 생성
mkdir -p /storage/mysql/data/
mkdir -p /storage/mysql/logs/
chown -R mysql:mysql /storage/mysql/data
chown -R mysql:mysql /storage/mysql/logs
chmod 750 /storage/mysql/data
chmod 750 /storage/mysql/logs
rsync -av /var/lib/mysql/ /storage/mysql/data/
-- MySQL 설정 업데이트
---DX1일경우---
# vi /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
(추가:15)
datadir = /storage/mysql/data
bind-address = 0.0.0.0
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4'
innodb_file_per_table = 1
log_error = /storage/mysql/logs/mysql.log
slow_query_log = 1
slow_query_log_file = /storage/mysql/logs/mysql-slow.log
# InnoDB 메모리
innodb_buffer_pool_size = 12G
innodb_buffer_pool_instances = 8
# InnoDB 로그
innodb_log_file_size = 2G
innodb_log_buffer_size = 128M
# InnoDB I/O
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
# 임시 테이블
tmp_table_size = 512M
max_heap_table_size = 512M
# 정렬 / 조인 버퍼
join_buffer_size = 4M
sort_buffer_size = 4M
# 연결
thread_cache_size = 32
max_connections = 300
(주석:62)
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
(주석:93)
#log_error = /var/log/mysql/error.log
---DX2일경우---
# vi /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld]
(추가:15)
datadir = /storage/mysql/data
bind-address = 0.0.0.0
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect = 'SET NAMES utf8mb4'
innodb_file_per_table = 1
log_error = /storage/mysql/logs/mysql.log
slow_query_log = 1
slow_query_log_file = /storage/mysql/logs/mysql-slow.log
# InnoDB 메모리 (RAM 4GB 기준 약 50% 할당)
innodb_buffer_pool_size = 2G
innodb_buffer_pool_instances = 2
# InnoDB 로그 (버퍼 풀 사이즈에 비례하여 축소)
innodb_log_file_size = 512M
innodb_log_buffer_size = 32M
# InnoDB I/O (CPU 4Core 기준)
innodb_read_io_threads = 4
innodb_write_io_threads = 4
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
# 임시 테이블 (메모리 부족 방지를 위해 축소)
tmp_table_size = 128M
max_heap_table_size = 128M
# 정렬 / 조인 버퍼
join_buffer_size = 2M
sort_buffer_size = 2M
# 연결 (싱크 서버 목적에 맞춰 축소)
thread_cache_size = 16
max_connections = 150
(주석:62)
#bind-address = 127.0.0.1
#mysqlx-bind-address = 127.0.0.1
(주석:93)
#log_error = /var/log/mysql/error.log
:wq
--로그 파일 생성
touch /storage/mysql/logs/mysql.log
touch /storage/mysql/logs/mysql-slow.log
chown mysql:mysql /storage/mysql/logs/mysql.log
chown mysql:mysql /storage/mysql/logs/mysql-slow.log
chmod 640 /storage/mysql/logs/mysql.log
chmod 640 /storage/mysql/logs/mysql-slow.log
--Mysql logrotate 로그설정
# cp /etc/logrotate.d/mysql-server /etc/logrotate.d/mysql-server.old
# vi /etc/logrotate.d/mysql-server
(전체삭제)
/storage/mysql/logs/mysql.log
/storage/mysql/logs/mysql-slow.log {
daily
rotate 7
size 50M
missingok
notifempty
create 640 mysql adm
compress
sharedscripts
postrotate
test -x /usr/bin/mysqladmin || exit 0
mysqladmin --defaults-file=/etc/mysql/debian.cnf flush-logs
endscript
}
:wq
--로그용량관리
# df -h /storage
/dev/sdb1 118G 107G 5.5G 96% /storage/mysql
# du -sh /storage/mysql
107G /storage/mysql
-- MySQL에 root 계정으로 접속 후 실행합니다.
# mysql -uroot -p@서버암호
-- 특정 날짜(예: 2026년 7월 1일) 이전의 모든 바이너리 로그를 안전하게 삭제합니다.
mysql> PURGE BINARY LOGS BEFORE '2026-07-01 00:00:00';
mysql> PURGE BINARY LOGS TO 'binlog.00xxxx';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
--MySQL 서비스 재시작
# systemctl restart mysql
--STEP4-4 : AppArmor 보안 설정 (필수)
# vi /etc/apparmor.d/usr.sbin.mysqld
(수정:60)
# Allow data dir access
# /var/lib/mysql/ r,
# /var/lib/mysql/** rwk,
/storage/mysql/data/ r,
/storage/mysql/data/** rwk,
(수정:73)
# Allow log file access
# /var/log/mysql.err rw,
# /var/log/mysql.log rw,
# /var/log/mysql/ r,
# /var/log/mysql/** rw,
/storage/mysql/logs/mysql.log rw,
/storage/mysql/logs/mysql-slow.log rw,
/storage/mysql/logs/ r,
/storage/mysql/logs/** rwk,
:wq
-- Alias 설정 (권장)
# vi /etc/apparmor.d/tunables/alias
(추가:17)
alias /var/lib/mysql/ -> /storage/mysql/data//,
:wq
# systemctl reload apparmor
# systemctl restart mysql
--외부 접속허용
# ufw allow 3306/tcp
(안함)특정 IP만 허용하는 경우 :
# ufw allow from 183.111.185.242 to any port 3306
-- 데이터 경로 확인
# mysql -uroot -p@서버암호 -e"SELECT @@datadir"
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------------+
| @@datadir |
+-----------------+
| /storage/mysql/data/|
+-----------------+
-- 로그 경로 확인
# mysql -u root -p@서버암호 -e "SHOW VARIABLES LIKE '%log_error%';"
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------------+----------------------------------------+
| Variable_name | Value |
+----------------------------+----------------------------------------+
| binlog_error_action | ABORT_SERVER |
| log_error | /storage/mysql/logs/mysql.log |
| log_error_services | log_filter_internal; log_sink_internal |
| log_error_suppression_list | |
| log_error_verbosity | 2 |
+----------------------------+----------------------------------------+
--------------------------------------------------------------------------
--데이터베이스최적화
--DB전체최적화
# mysqlcheck -uroot -p@서버암호 -o --all-databases
---DB지정최적화
# mysqlcheck -uroot -p@서버암호 -o {DATABASE_NAME}
---TABLE최적화
mysql> OPTIMIZE TABLE {DATABASE_NAME}.{TABLE_NAME};
--데이터베이스복원
# mysql -uroot -p@서버암호
mysql> CREATE DATABASE {DATABASE_NAME} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# mysql -uroot -p@서버암호 {DATABASE_NAME} < /storage/mysql_backup/20260205/{DATABASE_NAME}.sql
# mysql -uroot -p@서버암호
mysql> CREATE DATABASE YELLOW DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# mysql -uroot -p@서버암호 YELLOW < /storage/mysql_backup/20260205/YELLOW.sql
--데이터베이스백업
# mysqldump -uroot -p@서버암호 {DATABASE_NAME} > /storage/mysql_backup/20260205/{DATABASE_NAME}.sql
# mysqldump -uroot -p@서버암호 YELLOW > /storage/mysql_backup/20260205/YELLOW.sql
--데이터베이스자동백업:파일생성
# vi /storage/mysql_backup/mysql_backup.sh
#!/bin/bash
DATE=$(date +%Y%m%d)
BACKUP_DIR=/storage/mysql_backup/$DATE/
mysqldump -uroot -p@서버암호 --databases {DATABASE_NAME} > $BACKUP_DIR"{DATABASE_NAME}".sql
:wq
#3일지난 백업은 삭제한다
#-ctime n 옵션은 파일의 퍼미션을 마지막으로 변경시킨 날짜를 기준으로 파일을 찾아낸다.
#+n : n일 또는 n일 이전에 퍼미션이 변경된 파일
#-n : 오늘 부터 n일 전 사이에 퍼미션이 변경된 파일
#n : 정확히 n일 전에 퍼미션이 변경된 파일
find $BACKUP_DIR"*.sql -ctime +3 -exec rm -f {} \;
# chmod 755 mysql_backup.sh
# ./mysql_backup.sh
# bash mysql_backup.sh
--데이터베이스자동백업:스케줄등록
# crontab -e
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano
3. /usr/bin/vim.basic <---- vi
4. /usr/bin/vim.tiny
Choose 1-4 [2]: 4 --vi
(추가)0 1 * * * /storage/wwwroot/master/data_tools_master.sh
# date
# systemctl restart cron
# crontab -r //삭제
# 분(0-59) 시(0-23) 일(1-31) 월(1-12) 요일(0-6:0일요일-6토요일) 수행명령어
--0,10,20,30,40,50분 실행
0,10,20,30,40,50 * * * * bash /storage/wwwroot/master/data_tools_master.sh
--1-10일 실행
0 0 1-10 * * bash /storage/wwwroot/master/data_tools_master.sh
--MySQL 재설치
--MySQL 삭제
# apt remove --purge mysql*
# systemctl status mysql
# systemctl restart mysql
# 디렉토리 내부 새 파일 자동 권한 설정
sudo apt install acl
setfacl -d -m u::rwx /storage/wwwroot/master/
# 파일업데이트후 처리하기
chmod +x /storage/wwwroot/master/*.sh
--------------------------------------------------------------------------
--20210109:데이터베이스 경로변경 절대안됨(/storage/mysql/data)
--20240327:윈도우공유폴더일경우(오류발생:chown권한)
root@ubuntu:~# systemctl restart mysql
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
root@ubuntu:~# systemctl restart mysql
root@ubuntu:/# mysql -uroot -p@서버암호 -e"SELECT @@datadir"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@ubuntu:~# systemctl restart mysql
--20260111:부팅 초기에 아직 mount 안 된 상태
Apache 프로세스가 I/O 대기 상태(D 상태) 에 빠짐
INFO: task apache2:1599 blocked for more than 120 seconds
Apache DocumentRoot, ErrorLog, CustomLog가 그 경로를 사용
부팅 초기에 아직 mount 안 된 상태
--보안 유지 (히스토리 삭제)
cat /dev/null > ~/.bash_history && history -c
(백업)ZX1_apache2_php_nodejs_pm2_mysql_nfs_samba
--백업 : 가상머신
데이터센터 - 노드(node1) - 100(ZX1) - 백업
스토리지 : local-storage
압축 : ZSTD(빠르고좋음)
모드 : 스냅샷
통지 : 글로벌 설정 사용
#######################################################
--STEP5 : 시스템 복제
--STEP5-1 : 가상머신복제하기(60분)
머신 - 복제
이름: AX1_Apache, DX1_MySQL, DX2_MySQL, DX3_MySQL, MX1_Apache_MySQL
경로: D:\VMs\VBOX
(체크)하드웨어 UUID 유지
--완료
AX1_Apache(192.168.56.101) RAM : 6GB, CPU 4개, Storage1(240GB)
--네트워크-어댑터1 : NAT-포트포워딩
apache2 TCP (호스트포트)80 (게스트포트)80 #certbot 인증서포트 열려있어야 한다
apache2_ssl TCP (호스트포트)443 (게스트포트)443
DX1_MySQL(192.168.56.201) RAM : 12GB, CPU 6개, Storage1(120GB)
DX2_MySQL(192.168.56.202) RAM : 4GB, CPU 4개, Storage1(120GB)
DX3_MySQL(192.168.56.203) RAM : 4GB, CPU 1개, Storage1(25GB)
MX1_Apache_MySQL(192.168.56.200) RAM : 4GB, CPU 2개, Storage1(120GB)
--네트워크-어댑터1 : NAT-포트포워딩
webchat TCP (호스트포트)9100 (게스트포트)9100
--------------------------------------------------------------------------
--STEP5-2 : APACHE2 개발서버 환경설정일경우:20260207
--STEP5-2-1.웹서버설정
# vi /etc/php/8.3/apache2/php.ini
(수정:508)display_errors = On #PHP 실행 중 발생하는 에러, 경고, 알림 등을 브라우저 화면출력
:wq
# vi /etc/apache2/apache2.conf
(수정:175)
# vi /etc/apache2/sites-available/000-default.conf
(수정:13)DocumentRoot /storage/wwwroot
# vi /etc/apache2/sites-available/default-ssl.conf
(수정:7)DocumentRoot /storage/wwwroot
(수정:26)
ErrorLog /storage/logs/apache2/cube2005.co.kr-error.log
CustomLog /storage/logs/apache2/cube2005.co.kr-access.log combined
(수정:47)
SSLCertificateFile /etc/letsencrypt/live/cube2005.co.kr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cube2005.co.kr/privkey.pem
-- 인증서만 재발급 (Apache DocumentRoot 경로확인)
# certbot certonly --webroot -w /storage/wwwroot -d cube2005.co.kr -d www.cube2005.co.kr
--채팅서버_인증서복사 - AX1_Apache(192.168.56.101)
# /storage/wwwroot/master/chat_server_wss_keycopy.sh
도메인을 입력하세요 (기본: cube2005.co.kr): cube2005.co.kr
대상 경로를 입력하세요 (기본: /storage/wwwroot/chat): /storage/wwwroot/chat
--STEP5-2-2.채팅서버설정
--채팅서버_실행 - MX1_Apache_MySQL(192.168.56.200)
--www-data 사용자로 전환
# sudo -u www-data -i
www-data@ubuntu:~$ which pm2
/var/www/.npm-global/bin/pm2
www-data@ubuntu:~$
cd /storage/wwwroot/chat/
pm2 start chat_server_wss_cube2005.js --name chat_server_wss_cube2005
pm2 save --force
pm2 startup
exit
--부팅 시 자동 실행 스크립트 생성
# sudo env PATH=$PATH:/usr/bin /var/www/.npm-global/lib/node_modules/pm2/bin/pm2 startup systemd -u www-data --hp /var/www
# pm2-www list
# pm2-www restart chat_server_wss_cube2005
--소유권 변경 : 해당 디렉토리에 대한 쓰기 권한을 가지고 있어야 합니다.
# mkdir -p /storage/wwwroot/files
# sudo chown -R www-data:www-data /storage/wwwroot
# sudo chmod -R 755 /storage/wwwroot
# crontab -e
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano
3. /usr/bin/vim.basic <---- vi
4. /usr/bin/vim.tiny
Choose 1-4 [2]: 4 --vi
(추가)00 01 * * * sudo -u www-data -i pm2 restart chat_server_wss_cube2005
00 10 * * * sudo -u www-data -i pm2 restart chat_server_wss_cube2005
# systemctl restart cron
#######################################################
--STEP6 : NFS 설치
# apt update && apt upgrade -y
# apt install -y nfs-kernel-server nfs-common samba
--STEP6-1 : NFS 서버 설치
---NX1 (vmbr1 : 10.10.0.210)
# ls /sys/class/net
ens18 lo
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [10.10.0.210/24]
:wq
# netplan apply
--공유할 폴더 생성
# mkdir -p /storage
# chmod 777 /storage
--exports 설정(핵심)
--10.10.0.x 대역 허용, 읽기/쓰기 가능
# vi /etc/exports
/storage 10.10.0.0/24(rw,sync,no_subtree_check,no_root_squash)
:wq
# exportfs -rav
# systemctl restart nfs-kernel-server
--방화벽
# ufw allow from 10.10.0.0/24 to any port nfs
--STEP6-2 : NFS 클라이언트 설치
---AX1 (vmbr0 : 192.168.0.103, vmbr1 : 10.10.0.101)
# ls /sys/class/net
ens18 ens19 lo
# vi /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
ens18:
dhcp4: no
addresses: [192.168.0.103/24]
routes:
- to: default
via: 192.168.0.1
nameservers:
addresses: [8.8.8.8, 168.126.63.1]
ens19:
dhcp4: no
addresses: [10.10.0.101/24]
:wq
# netplan apply
--NFS 클라이언트 마운트
# apt install -y nfs-common
# mkdir /mnt/storage
# mount -t nfs 10.10.0.210:/storage/ /mnt/storage
--자동 마운트
# vi /etc/fstab
10.10.0.210:/storage /mnt/storage nfs defaults,_netdev,nofail 0 0
:wq
--현재 디렉토리 용량
# du -sh .
--현재 디렉토리 용량
# du -sh /mnt/storage
--하위 디렉토리 용량
# du -sh /mnt/storage/*
# du -sh /mnt/storage/* | sort -h
--전체 디스크 사용량
# df -h
--STEP5-3 : SAMBA 설정
# apt update && apt upgrade -y
# apt install -y samba
# vi /etc/samba/smb.conf
(추가:1)
[storage]
comment = storage
path = /mnt/storage
read only = no
writable = yes
browsable = yes
valid users = root
create mask = 0777
directory mask = 0777
:wq
--설명
[storage]
comment = storage #공유폴더설명
path = /mnt/storage #공유할폴더경로
read only = no #읽기전용아님
writable = yes #쓰기가능
browsable = yes #폴더내용탐색가능
valid users = root #접속가능사용자계정
create mask = 0777 #파일권한
directory mask = 0777 #디렉토리권한
# smbpasswd -a root
New SMB password: @서버암호
Retype new SMB password: @서버암호
Added user root.
# systemctl restart smbd
# ufw allow 139,445/tcp
--윈도우설정
1. 서버관리자-역할및기능추가-기능선택-SMB1.0/CIFS File Sharing Support
2. gpedit.msc(로컬그룹정책편집기)
컴퓨터구성-관리템플릿-네트워크-Lanman워크스테이션-보안되지않은게스트로그온사용:사용
3. 네트워크 폴더 자격 증명 삭제(오류일경우 액세스가 거부되었습니다)
> net use \\10.10.0.101\storage /delete
--윈도우탐색기
계정 : root
암호 : @서버암호
(체크)내자격증명기억
--우분투에서 윈도우 폴더 공유하기
# apt install -y cifs-utils
# vi /etc/fstab
//10.10.0.10x/storage /mnt/storage cifs username=administrator,password=@서버암호 0 0
# mount -a