ubuntu 설치.
https://ubuntu.com/download/server
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-94-generic x86_64)
python 설치.
ubuntu@ubuntu:/usr/bin$ sudo apt update && sudo apt upgrade
ubuntu@ubuntu:/usr/bin$ sudo apt install software-properties-common
ubuntu@ubuntu:/usr/bin$ sudo add-apt-repository ppa:deadsnakes/ppa
ubuntu@ubuntu:/usr/bin$ sudo apt-cache policy python3.8
ubuntu@ubuntu:/usr/bin$ ls -al /usr/bin/python*
lrwxrwxrwx 1 root root 10 Aug 18 2022 /usr/bin/python3 -> python3.10
-rwxr-xr-x 1 root root 5904904 Nov 20 15:14 /usr/bin/python3.10
ubuntu@ubuntu:/usr/bin$ sudo apt install python3.8
ubuntu@ubuntu:/usr/bin$ sudo apt install python3.9
ubuntu@ubuntu:/usr/bin$ ls -al /usr/bin/python*
lrwxrwxrwx 1 root root 10 Aug 18 2022 /usr/bin/python3 -> python3.10
-rwxr-xr-x 1 root root 5904904 Nov 20 15:14 /usr/bin/python3.10
-rwxr-xr-x 1 root root 5146696 Aug 25 13:20 /usr/bin/python3.8
-rwxr-xr-x 1 root root 5294896 Aug 25 13:20 /usr/bin/python3.9
ubuntu@ubuntu:/usr/bin$
ubuntu@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
ubuntu@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2
ubuntu@ubuntu:/usr/bin$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 3
ubuntu@ubuntu:/usr/bin$ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.10 3 auto mode
1 /usr/bin/python3.10 3 manual mode
* 2 /usr/bin/python3.8 1 manual mode
3 /usr/bin/python3.9 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
ubuntu@ubuntu:/usr/bin$ python -V
Python 3.8.18
ubuntu@ubuntu:/usr/bin$ sudo rm -rf /usr/bin/python3
ubuntu@ubuntu:/usr/bin$ sudo ln -s python3.8 python3
ubuntu@ubuntu:/usr/bin$ ls -al /usr/bin/python*
lrwxrwxrwx 1 root root 24 Feb 19 11:45 /usr/bin/python -> /etc/alternatives/python
lrwxrwxrwx 1 root root 9 Feb 19 11:48 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5904904 Nov 20 15:14 /usr/bin/python3.10
-rwxr-xr-x 1 root root 5146696 Aug 25 13:20 /usr/bin/python3.8
-rwxr-xr-x 1 root root 5294896 Aug 25 13:20 /usr/bin/python3.9
ubuntu@ubuntu:/usr/bin$
파이썬 삭제
패키지 삭제
sudo apt-get remove python3.10
파이선 구성, 데이터 파일과 종속성 모두 삭제.
sudo apt-get purge --auto-remove python3.10
pip 설치
sudo apt-get install python3-pip
sudo apt-get install python3.8-dev
에러
python3 -m virtualenv venv -p $(which python3)
/usr/bin/python3: No module named virtualenv
->
pip3 install virtualenv
yarn
sudo apt update
curl --version
sudo apt install curl
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt install yarn
yarn --version
0.32+git
sudo apt install npm
sudo curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
yarn
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
sudo apt update
sudo apt install nodejs npm
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
$ nodejs -v
v12.22.9
$ npm -v
8.5.1
## yarn 설치
sudo apt update
sudo apt install curl
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt install yarn -y
yarn --version
# 결과
0.32+git
## 최신버전 설치.
sudo apt install npm -y
sudo curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
yarn
# 결과
yarn install v1.22.19
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.09s.
## node npm update
sudo apt update
sudo apt-get upgrade
sudo npm cache clean -f
sudo n lts
$ node -v
v20.11.1
$ npm -v
10.2.4
swap 파일 추가
$ free -h
total used free shared buff/cache available
Mem: 1.9Gi 352Mi 1.0Gi 0.0Ki 547Mi 1.3Gi
Swap: 0B 0B 0B
$ sudo dd if=/dev/zero of=/swapfile bs=128M count=16
16+0 records in
16+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 13.6477 s, 157 MB/s
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=4664fe70-58d8-4c87-815b-7bde1e35dcf4
Filename Type Size Used Priority
/swapfile file 2097148 0 -2
$ sudo vi /etc/fstab
/swapfile swap swap defaults 0 0
$ free -h
total used free shared buff/cache available
Mem: 1.9Gi 360Mi 171Mi 0.0Ki 1.4Gi 1.3Gi
Swap: 2.0Gi 0B 2.0Gi
$
docker , docker-compose 설치
참고 : https://docs.docker.com/engine/install/ubuntu/
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
mysql 설치
## mysqld 8.0.36-0ubuntu0.22.04.1
sudo apt install mysql-server
## root 패스워드 변경
sudo mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY '비밀번호';
FLUSH PRIVILEGES;
## 유저 생성.
mysql -u root -p
CREATE USER 'userid'@'localhost' IDENTIFIED BY 'user_password';
GRANT ALL PRIVILEGES ON *.* TO 'userid'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
## 정지, 시작, 재시작
sudo systemctl status mysql.service
sudo systemctl start mysql
sudo systemctl restart mysql
sudo systemctl stop mysql
## ufw
sudo ufw allow mysql
## query log (주석 해제)
vi /etc/mysql/mysql.conf.d/mysqld.cnf
general_log_file = /var/log/mysql/query.log
general_log = 1
## query log 쿼리
show variables like 'general%';
set global general_log = ON;
set global general_log_file = '/home/ubuntu/mysql/query.log';
JAVA 설치
sudo apt-get update
sudo apt-get upgrade
## JAVA11 설치
sudo apt-get install openjdk-11-jdk
## 확인
java -version
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
which java
/usr/bin/java
ls -al /usr/lib/jvm
## 삭제
sudo apt-get purge openjdk*
npm 설치
sudo apt install npm
** react port 변경
명령어 : PORT=3900 npm run dev
package.json 변경 : "scripts": { "dev": "export PORT=3900 && next dev",
DynamoDB 설치
** 참고
로컬 엔드포인트 값을 주어서 로컬에서 작업.
개발 또는 테스트용도에서 사용.
$ aws configure
AWS Access Key ID [****************1]: 1
AWS Secret Access Key [****************1]: 1
Default region name [us-west-2]: us-west-2
Default output format [1]: json
$ aws dynamodb list-tables --endpoint-url http://localhost:8100
{
"TableNames": []
}
$
## 참조 : https://docs.aws.amazon.com/ko_kr/amazondynamodb/latest/developerguide/DynamoDBLocal.html
wget https://s3.ap-south-1.amazonaws.com/dynamodb-local-mumbai/dynamodb_local_latest.tar.gz
tar xvf dynamodb_local_latest.tar.gz
## 실행
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
## - 포트 변경.
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8100 &
## dynamodb gui 설치.
npm -g install dynamodb-admin
## dynamodb gui 실행.
DYNAMO_ENDPOINT=http://localhost:8000 dynamodb-admin
## - 포트 변경.
DYNAMO_ENDPOINT=http://localhost:8100 dynamodb-admin -p 8101 &
## test
http://10.30.0.166:8101/
## cli 설치.
sudo snap install aws-cli # version 1.15.58, or
sudo apt install awscli # version 1.22.34-1
sudo apt install awscli
## cli 명령어 참조
## https://docs.aws.amazon.com/ko_kr/amazondynamodb/latest/developerguide/Tools.CLI.html#Tools.CLI.UsingWithDDBLocal
aws dynamodb list-tables --endpoint-url http://localhost:8100
python 3.9 설치
## https://www.python.org/downloads/release/python-3915/
## https://www.linuxcapable.com/how-to-install-python-3-9-on-ubuntu-linux/
apt list --installed | grep python
sudo apt install python3-virtualenv
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
Airflow 설치
mkdir airflow
cd airflow
sudo apt install python3.10-venv
## 가상 환경 생성 (-m mod : run library module as a script (terminates option list))
python3 -m venv .venv
## 가상 환경 활성
source .venv/bin/activate
## deactivate
## 참조 : https://airflow.apache.org/docs/apache-airflow/stable/start.html
export AIRFLOW_HOME=/home/ubuntu/airflow
pip3 install "apache-airflow==2.3.4" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.3.4/constraints-3.8.txt"
## 포트 수정 및 예제 비활성.
## airflow.cfg 수정 : base_url, web_server_port, endpoint_url, load_examples
airflow standalone
## 데이터베이스 초기화
airflow db init
## 실행
airflow webserver -p 8180
## 실행 - 백그라운드
airflow webserver -p 8180 -D
## 확인
http://10.0.0.1:8180/login/
## 유저 생성
airflow users create \
--username admin \
--firstname FIRST_NAME \
--lastname LAST_NAME \
--role Admin \
--password admin \
--email admin@ad.min
## sqlite -> mysql 변경
https://airflow.apache.org/docs/apache-airflow/2.3.4/howto/set-up-database.html
PostgreSQL
## 참고
https://ubuntu.com/server/docs/databases-postgresql
## update
sudo apt-get update
sudo apt-get upgrade
## 저장소 등록
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get upgrade
## 설치
sudo apt-get install -y postgresql-13 postgresql-contrib
## 확인
service postgresql status
## 정지/시작/재시작/리로그
sudo systemctl stop postgresql
sudo systemctl start postgresql
sudo systemctl restart postgresql
sudo systemctl reload postgresql
## 패스워드/유저생성 변경
sudo su - postgres
psql
create user tuser password 'tuser' superuser;
\du
sudo su - postgres
psql
\password
Redis 설치
## 설치
sudo apt-get update
sudo apt-get install redis-server
## 포트 변경 6379 -> 6390
sudo vim /etc/redis/redis.conf
## 설치 확인
redis-server --version
netstat -nlpt | grep 6379
netstat -nlpt | grep 6390
## 재시작.
sudo systemctl restart redis-server.service
## nginx 설치
sudo apt update
sudo apt install nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
sudo ufw status
systemctl status nginx
sudo systemctl stop nginx
sudo systemctl start nginx
sudo systemctl restart nginx
node apps/frontend/server.js
python manage.py runserver
'System' 카테고리의 다른 글
AWS EC2에 제니퍼 설치 (APM) (0) | 2024.03.13 |
---|---|
aws 권한 (계정 추가) (0) | 2024.03.12 |
AWS DynamoDB 설치 사용. (1) | 2024.02.15 |
docker-compose (0) | 2024.02.14 |
airflow 설치 / 설정 (0) | 2024.02.06 |