๊ฐ์
ํผ๋ธ๋ฆญ ํด๋ผ์ฐ๋์์ ์ ๊ณตํ๋ ํ๋ฆฌํฐ์ด ํํ์ด ๊ฐ์ฅ ํฐ ๊ณณ์ Oracle Cloud ์ ๋๋ค!
๋ค๋ง, ํ๋ฆฌํฐ์ด ํํ์ด ์ข์ ๋งํผ ํด๋น ๋ฆฌ์ ์ ๋ํ ๊ฐ์ฉ๋์ด ๊ฝ ์ฐจ๋ฉด ์ธ์คํด์ค ์์ฑ์ด ๋์ง ์์ต๋๋ค.
์ธ์ ๊ฐ์ฉ๋์ด ํ๋ณด๋ ์ง๋ ๋ชจ๋ฅด๊ธฐ ๋๋ฌธ์ ์ธ์คํด์ค๋ฅผ ์๋์ผ๋ก ์์ฑํ๋ ์ค์ผ์ฅด๋ฌ๋ฅผ ๊ฐ๋ฐํ์๊ณ ์ด๋ฅผ ๊ณต์ ํ๊ณ ์ ํฌ์คํธ๋ฅผ ์์ฑํ๊ฒ ๋์์ต๋๋ค.
์ด๋ฏธ ํด๋ฆฌ์์ theb1ue ๋์ด php๋ก ๋ง๋ ์๋ ์คํฌ๋ฆฝํธ๊ฐ ์๊ธฐ ๋๋ฌธ์ php์ ์ต์ํ์ ๋ถ์ ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์!
https://svrforum.com/cloud/319909
๊ฐ๋ฐ ํ๊ฒฝ
- Spring Boot 2.7.15
- Spring Batch
- JDK 11
- IntelliJ Ulimate
- FileZilla
- Putty, Mobaxterm
๐ Spring Boot 3 ๋ฒ์ ์ด ์๋ 2 ๋ฒ์ ์ผ๋ก ์งํํ์์ต๋๋ค.
๐ ์ด๋ Oracle Cloud SDK ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ฌ์ฉํ๋ ์ผ๋ถ ์์กด์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ด javax ํจํค์ง๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
API Key ์ถ๊ฐ ๋ฐ Key ๋ค์ด๋ก๋
๐ ์ค๋ผํด ํด๋ผ์ฐ๋ ์ ์ํ์ฌ ๋ก๊ทธ์ธํ ๋ค์ ์ฐ์๋จ์ ํ๋กํ ์ด๋ฏธ์ง ํด๋ฆญ ํ ๋ด ํ๋กํ์ผ ๋ฉ๋ด๋ก ๋ค์ด๊ฐ์ฃผ์ธ์!
https://www.oracle.com/kr/cloud/
๐ ์ขํ๋จ์ API ํค ๋ฉ๋ด๋ฅผ ๋๋ฅธ ๋ค์ API ํค ์ถ๊ฐ ๋ฒํผ์ ํด๋ฆญํด์ฃผ์ธ์.
๐ ๋ค์์ผ๋ก ํ๋ผ์ด๋น ํค ๋ฐ ํผ๋ธ๋ฆญ ํค ๋ชจ๋ ๋ค์ด๋ก๋ํ ๋ค์ ์ถ๊ฐ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์!
Private ํค๋ API ํธ์ถ์ ํ์ํ ์ธ์ฆ ํค๋ก ์ฌ์ฉ๋๊ธฐ ๋๋ฌธ์ ์ ์ค๋์ง ์๋๋ก ์ ์ํด์ผ ํฉ๋๋ค!
๐ ์ถ๊ฐ ๋ฒํผ์ ๋๋ฅด๊ฒ ๋๋ฉด ๋ค์๊ณผ ๊ฐ์ ์ฐฝ์ด ๋จ๊ฒ ๋ฉ๋๋ค.
๐ ํด๋น ๋ด์ฉ์ ๋ชจ๋ ๋ณต์ฌํ์ฌ ๋ฉ๋ชจ์ฅ or ๋ ธํธํจ๋์ ๋ถ์ฌ๋ฃ๊ธฐ ํด์ค๋๋ค!
API ํธ์ถ์ ํ์ํ ํ๋ผ๋ฏธํฐ ์ถ์ถ
์ธ์คํด์ค๋ฅผ ์์ฑํ๋ API๋ฅผ ํธ์ถํ๊ธฐ ์ํด์๋ ํด๋น ์ธ์คํด์ค์ ์ด๋ฏธ์ง, ์๋ธ๋ท ๋ฑ์ ํ๋ผ๋ฏธํฐ๊ฐ ํ์ํฉ๋๋ค!
๋ฐ๋ผ์, F12 ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ํ์ฉํ์ฌ ์ค๋ผํด ํด๋ผ์ฐ๋์์ ์ธ์คํด์ค ์์ฑ ๋ฒํผ์ ๋๋ฌ API ์์ฒญ์ด ์ด๋ ํ ํํ๋ก ๋๊ฐ๋ ์ง ํ์ธํด๋ด ์๋ค!
๐ SSH ํค ์ถ๊ฐ์์ "๊ณต์ฉ ํค ์ ์ฅ"์ ์ถํ API ํธ์ถ์์ ์ฌ์ฉํ๋ฏ๋ก ๊ผญ ์ ์ฅํด์ฃผ์ธ์.
๐ ์ฌ๊ธฐ๊น์ง ๋ชจ๋ ์ค์ ํ์๋ค๋ฉด F12 ๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ์ด๊ณ ์์ฑ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์!
๐ ์ ๊ทธ๋ฆผ์ฒ๋ผ ๋นจ๊ฐ์ instances ํญ๋ชฉ์์ ์ฐํด๋ฆญ ํ Copy as cuRL (bash) ๋ฒํผ์ ๋๋ฌ์ค๋๋ค!
curl 'https://iaas.ap-singapore-1.oraclecloud.com/20160918/instances/' \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Origin: https://cloud.oracle.com' \
-H 'Referer: https://cloud.oracle.com/' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: cross-site' \
-H 'User-Agent: xxxxxx' \
-H 'accept-language: ko' \
-H 'authorization: Signature keyId="xxxxxxxxxxxxxxxxxx"' \
-H 'opc-request-id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'sec-ch-ua: "Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'x-content-sha256: /xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'x-date: Tue, 18 Jun 2024 17:17:43 GMT' \
--data-raw
{
"metadata": {
"ssh_authorized_keys": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"shape": "VM.Standard.A1.Flex",
"compartmentId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"displayName": "SRV1",
"availabilityDomain": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"sourceDetails": {
"sourceType": "image",
"imageId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"bootVolumeSizeInGBs": 50,
"bootVolumeVpusPerGB": 10
},
"isPvEncryptionInTransitEnabled": true,
"createVnicDetails": {
"assignPublicIp": true,
"subnetId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"assignPrivateDnsRecord": true,
"assignIpv6Ip": false
},
"agentConfig": {
"pluginsConfig": [
{ "name": "Vulnerability Scanning", "desiredState": "DISABLED" },
{ "name": "Oracle Java Management Service", "desiredState": "DISABLED" },
{ "name": "OS Management Service Agent", "desiredState": "DISABLED" },
{ "name": "OS Management Hub Agent", "desiredState": "DISABLED" },
{ "name": "Management Agent", "desiredState": "DISABLED" },
{ "name": "Custom Logs Monitoring", "desiredState": "ENABLED" },
{ "name": "Compute RDMA GPU Monitoring", "desiredState": "DISABLED" },
{ "name": "Compute Instance Run Command", "desiredState": "ENABLED" },
{ "name": "Compute Instance Monitoring", "desiredState": "ENABLED" },
{ "name": "Compute HPC RDMA Auto-Configuration", "desiredState": "DISABLED" },
{ "name": "Compute HPC RDMA Authentication", "desiredState": "DISABLED" },
{ "name": "Cloud Guard Workload Protection", "desiredState": "ENABLED" },
{ "name": "Block Volume Management", "desiredState": "DISABLED" },
{ "name": "Bastion", "desiredState": "DISABLED" }
],
"isMonitoringDisabled": false,
"isManagementDisabled": false
},
"definedTags": {},
"freeformTags": {},
"instanceOptions": {
"areLegacyImdsEndpointsDisabled": false
},
"availabilityConfig": {
"recoveryAction": "RESTORE_INSTANCE"
},
"shapeConfig": {
"ocpus": 4,
"memoryInGBs": 24
}
}
๐ ๋ถ์ฌ๋ฃ๊ธฐ ํ๊ฒ ๋๋ฉด ์์ ๊ฐ์ ๋ด์ฉ์ด ๋ณด์ผํ ๋ฐ ์ฌ๊ธฐ์ ํ์ํ ํ๋ผ๋ฏธํฐ๋ง์ ์ถ์ถํด์ผ ํฉ๋๋ค!
๐ imageId, compartmentId, subnetId, availabilityDomain ์ด 4๊ฐ์ง ํ๋ผ๋ฏธํฐ์ ๊ฐ์ ๋ฝ์์ ๋ฉ๋ชจ์ฅ์ ๋ณต์ฌํด์ฃผ์ธ์!
GitHub ํ๋ก์ ํธ Clone
์๋ URL๋ก ๋ค์ด๊ฐ ํ๋ก์ ํธ๋ฅผ Clone ํด์ฃผ์ธ์!
https://github.com/dev-toyproject/oracle-cloud-auto-create-vm
Application.yml ์์
oracle:
cloud:
apiKey:
profile: DEFAULT
user: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
fingerprint: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tenancy: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
region: ap-singapore-1
privKey:
path: /root/test123@gmail.com_2024-05-24T13_12_12.293Z.pem
pubKey:
path: /root/ssh-key-2024-05-24.key.pub
instance:
x86:
# x86 ์ธ์คํด์ค ์์ฑํ์ง ์์ --> displayName : null
# x86 ์ธ์คํด์ค 1๊ฐ ์์ฑ --> displayName : srv1
# x86 ์ธ์คํด์ค 2๊ฐ ์์ฑ --> displayName : srv1,srv2 (์ฝค๋ง๋ก ๊ตฌ๋ถ)
displayName: null
imageId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shape: VM.Standard.E2.1.Micro
volume: 50
availabilityDomain: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
compartmentId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
subnetId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
arm:
# arm ์ธ์คํด์ค ์์ฑํ์ง ์์ --> displayName : null
# arm ์ธ์คํด์ค 1๊ฐ ์์ฑ --> displayName : srv1
# arm ์ธ์คํด์ค 2๊ฐ ์์ฑ --> displayName : srv1,srv2 (์ฝค๋ง๋ก ๊ตฌ๋ถ)
# ์ถ๊ฐ์ ์ผ๋ก arm ์ธ์คํด์ค๋ 1๊ฐ ์์ฑํ ๋๋ vcpu: 4, memory: 24, volume: 100 (ํ๋ฆฌํฐ์ด ์ต๋ ํ๋) ๋ก ๋ณ๊ฒฝํด์ฃผ์ธ์.
displayName: srv3,srv4
imageId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shape: VM.Standard.A1.Flex
vcpu: 2
memory: 12
volume: 50
availabilityDomain: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
compartmentId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
subnetId: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
๐ oracle.cloud.apiKey ํ์ ํญ๋ชฉ๋ค ์ค user, fingerprint, tenancy ํญ๋ชฉ์ "API ํค ์ถ๊ฐ ๋ฐ Key ๋ค์ด๋ก๋" ๋ถ๋ถ์์ ๋ณต์ฌํด๋๋ ๊ฐ์ผ๋ก ๋ฐ๊ฟ์ค๋๋ค!
๐ oracle.cloud.apiKey.privKey.path ํญ๋ชฉ์ "API ํค ์ถ๊ฐ ๋ฐ Key ๋ค์ด๋ก๋" ๋ถ๋ถ์์ ์ ์ฅํ๋ Private Key ํ์ผ์ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์!
๐ oracle.cloud.apiKey.pubKey.path ํญ๋ชฉ์ ์ธ์คํด์ค ์์ฑํ ๋ SSH ํค ์ถ๊ฐ ๋ถ๋ถ์์ ์ ์ฅํ๋ ๊ณต์ฉ ํค ํ์ผ์ ์ ๋ ๊ฒฝ๋ก๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์!
๐ oracle.cloud.instance ํ์ ํญ๋ชฉ๋ค ์ค imageId, subnetId, .. ๋ฑ์ "API ํธ์ถ์ ํ์ํ ํ๋ผ๋ฏธํฐ ๋ถ๋ถ"์์ ์ถ์ถํ๋ ๊ฐ๋ค๋ก ๋ฐ๊ฟ์ค๋๋ค!
๐ oracle.cloud.instance.x86 or arm.displayName ํญ๋ชฉ ๊ฐ์ด "null" ๋ฌธ์์ด์ด๋ฉด ์์ฑํ์ง ์๊ณ ์์๋ ์ฃผ์์ ๋ฌ์๋จ์ผ๋ ์ฐธ๊ณ ํด์ฃผ์ธ์!
x86 ์ธ์คํด์ค์ ๊ฒฝ์ฐ์ vcpu, memory ๊ฐ์ ์ค์ ํ์ง ์์ ์ด์ ๋ ํ๋ฆฌํฐ์ด ์ธ์คํด์ค๋ vcpu, memory๊ฐ ๊ณ ์ ๋์ด ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
ํ๋ก์ ํธ ๋น๋ ๋ฐ ๋ฐฐํฌ
ํ๋ก์ ํธ ๋น๋ํ๊ธฐ์ ์์, ๋ฐฐํฌํ๊ณ ์ ํ๋ ์๋ฒ์ ๋ฏธ๋ฆฌ PrivKey, PubKey๋ฅผ ์ ๋ก๋ํ ๋ค์ ํด๋น Key ํ์ผ๋ค์ ์ ๋ ๊ฒฝ๋ก๋ฅผ ๋ณต์ฌํ ๋ค์ ๊ผญ application.yml์ ๋ฐ์ํด์ฃผ์ด์ผ ํฉ๋๋ค!!
๋ํ, ํท๊ฐ๋ฆด ์์ง๊ฐ ์์ด ๋ง์๋๋ฆฌ์ง๋ง PrivKey๋ "API ํค ์ถ๊ฐ ๋ฐ ๋ค์ด๋ก๋" ๋ถ๋ถ์์ ๋ค์ด๋ก๋ ํ๋ ํ๋ผ์ด๋น ํค์ด๊ณ PubKey๋ ์ธ์คํด์ค ์์ฑํ ๋, ๋ค์ด๋ก๋ ํ๋ ๊ณต์ฉ ํค ์ ๋๋ค!
"API ํค ์ถ๊ฐ ๋ฐ ๋ค์ด๋ก๋" ๋ถ๋ถ์์ ๋ค์ด๋ก๋ ํ๋ ํผ๋ธ๋ฆญ ํค๊ฐ ์๋๋๋ค!!
# [๋ก์ปฌ] ํ๋ก์ ํธ ๋น๋
./gradlew build -x test
# [์๋ฒ] ํจํค์ง ์ค์น
dnf install -y java-11-openjdk
# [์๋ฒ] ๋ฐฐํฌ
nohup java -jar oci-vm-0.0.1-SNAPSHOT.jar
๐ ์ฝ์ ๋ก๊ทธ๋ ๋ณ๋์ ๋ก๊น ํ์ผ๋ก ์์ฑ๋๋ฉฐ ๋ ์ง๋ณ๋ก ๋ถ๋ฆฌ๋๋๋ก ์ค์ ํด๋์์ต๋๋ค!
์ถ๊ฐ์ ์ผ๋ก ๊ถ๊ธํ์ ์ฌํญ์ด๋ ์๋ชป๋ ๋ถ๋ถ์ด ์๋ค๋ฉด ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค!
'๐ฎ Toy Project' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
HTML, CSS ํด๋ก ์ฝ๋ฉ - ๋ผ์ธํ๋ฌ์ค ํํ์ด์ง (0) | 2023.08.08 |
---|