EC2 Ubuntu 초기설정

# linux
sudo yum update -y
sudo yum install git -y

# ubuntu 
sudo apt-get update
sudo apt-get upgrade

git version
git clone <https://github.com/TeamSparta-Inc/etl.git>
vi .env

python3 --version
sudo apt install python3-pip
pip3 --version
pip3 install -r "requirements.txt"
- sudo apt-get install libpq-dev (for psycopg2)
pip3 list

nohup python3 etl/main.py > output.log
ps aux | grep main # kill {pid}
tail -f output.log

EC2 TimeZone 변경

// 현재 시간 (Timezone 확인)
sudo date

// localtime 삭제
sudo rm /etc/localtime

// timezone Aisa/Seoul 로 변경
sudo ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime

// 변경된 시간 (Timezone) 확인 후 마무리
sudo date

EC2 Status Check

sudo cat /var/log/syslog

ubuntu@ip-172-31-20-29:~$ top
top - 17:00:55 up 12 days,  2:38,  2 users,  load average: 0.01, 0.01, 0.10
Tasks: 101 total,   1 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.3 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    949.7 total,    370.2 free,    215.4 used,    364.2 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    579.2 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
32648 root      20   0 1337284  35684  19328 S   0.3   3.7   4:46.17 amazon-cloudwat
    1 root      20   0  167440  11008   6400 S   0.0   1.1   0:20.19 systemd
    2 root      20   0       0      0      0 S   0.0   0.0   0:00.02 kthreadd
    3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp
    4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp
    5 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 slub_flushwq
    6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 netns
    8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-events_highpri
   10 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq
   11 root      20   0       0      0      0 I   0.0   0.0   0:00.00 rcu_tasks_rude_kthread
   12 root      20   0       0      0      0 I   0.0   0.0   0:00.00 rcu_tasks_trace_kthread
   13 root      20   0       0      0      0 S   0.0   0.0   0:04.55 ksoftirqd/0
   14 root      20   0       0      0      0 I   0.0   0.0   0:07.21 rcu_sched
   15 root      rt   0       0      0      0 S   0.0   0.0   0:06.61 migration/0
   16 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0
   18 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0
   19 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kdevtmpfs
   20 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 inet_frag_wq
   21 root      20   0       0      0      0 S   0.0   0.0   0:00.01 kauditd
   22 root      20   0       0      0      0 S   0.0   0.0   0:00.24 khungtaskd

The output from the top command provides real-time information about the system's resource usage. Let's break down what each part of the line %Cpu(s): 41.1 us, 1.7 sy, 0.0 ni, 48.8 id, 0.2 wa, 0.0 hi, 1.3 si, 6.9 st means:

The second line 14264 ubuntu 20 0 1346272 462364 13568 R 73.3 23.5 8:01.69 python3 provides details on a specific process:


CloudWatch Logs

https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_GettingStarted.html