Quickstarts > 7.스토리지 생성 및 연결
이번 학습 모듈에서는 NHN Cloud 콘솔을 통해 스토리지 서비스를 활성화하고 사용하는 방법을 안내합니다. NHN Cloud의 스토리지 서비스는 데이터 저장과 관리에 필요한 안정적이고 확장 가능한 솔루션을 제공합니다.
이번 학습 모듈에서 배울 내용은 다음과 같습니다.
최종 구성도
NHN Cloud를 시작하기 위해서는 다음 사항을 준비해야 합니다.
본 가이드는 6. 데이터베이스 생성 및 연결 이후 단계부터 시작됩니다.
블록 스토리지를 생성해 리눅스 인스턴스에 연결한 뒤 블록 스토리지의 데이터를 조회합니다.
모듈 3에서 생성한 리눅스 인스턴스
linux-server-basic
에 블록 스토리지 리소스를 연결합니다.
MyBS
HDD
10 GB
linux-server-basic의 /dev/vda
인 블록 스토리지와 동일한 가용성 영역MyBS
를 선택 후 위에 연결 관리를 클릭합니다.linux-server-basic
linux-server-basic
에 원격 접속한 상태에서 아래 명령어를 실행해 단계 1에서 생성한 블록 스토리지 MyBS
에 파티션을 생성한 뒤 포맷과 마운트를 실행합니다.#bash
echo -e "n\np\n1\n\n\nw" | sudo fdisk /dev/vdb
알아두기
n
: 새 파티션 생성 (옵션: n
)p
: 파티션 유형 선택 (기본값: Primary)1
: 파티션 번호 (기본값: 1번)w
: 변경 내용을 저장하고 종료sudo mkfs -t xfs /dev/vdb1
sudo mkdir /mnt/vdb
sudo sh -c 'echo "UUID=$(sudo blkid -s UUID -o value /dev/vdb1) /mnt/vdb xfs defaults,nodev,noatime,nofail 1 2" >> /etc/fstab'
sudo mount -a
sudo chmod 777 /mnt/vdb
df /dev/vdb1
해당 Filesystem과 용량, Mount 경로가 조회되는 것을 확인합니다.
[참고]
결과 화면 보기
![]()
linux-server-basic
에 원격 접속한 상태에서 아래 명령어를 실행하여 블록 스토리지를 생성합니다.export MYSQL_PWD=nhnpassword
mysql-db-basic
데이터 조회 자료를 생성합니다.mysql --host=(mysql-db-basic 인스턴스의 가상 IP 주소) --user=nhncloud -e "SELECT * FROM employees.employees LIMIT 30;" -B --batch > /mnt/vdb/employees.csv
cat /mnt/vdb/employees.csv
[참고]
결과 화면 보기
![]()
오브젝트 스토리지 서비스를 활성화해 컨테이너를 생성한 뒤 객체를 업로드합니다. 해당 객체를 리눅스 인스턴스에 저장한 뒤 접속해 데이터가 출력되는 지 확인합니다.
MyPRJ
프로젝트 오른쪽에 위치한 "서비스 선택" 탭을 클릭합니다.myobs
PUBLIC
Standard
사용 안 함
사용 안 함
#PowerShell
mkdir /web-sample
echo '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>::: Welcome to NHN Cloud :::</title>
<script>
let countdownTimer;
function fetchServerIP() {
fetch("/server-info")
.then(response => response.json())
.then(data => {
const serverIP = data.serverIP;
document.getElementById("server-ip").innerText = "Server IP Address: " + serverIP;
})
.catch(error => {
document.getElementById("server-ip").innerText = "Unable to fetch server IP address";
});
}
function startStressTest() {
const button = document.getElementById("start-btn");
button.innerText = "Starting...";
let timeLeft = 120;
const countdownDisplay = document.getElementById("countdown");
countdownDisplay.innerText = "Time left: " + timeLeft + " seconds";
countdownTimer = setInterval(() => {
timeLeft--;
countdownDisplay.innerText = "Time left: " + timeLeft + " seconds";
if (timeLeft <= 0) {
clearInterval(countdownTimer);
countdownDisplay.innerText = "Stress test complete!";
}
}, 1000);
fetch("/start-stress")
.then(response => response.text())
.then(data => {
console.log(data);
})
.catch(error => {
console.error("Error starting stress test:", error);
});
}
window.onload = fetchServerIP;
</script>
</head>
<body>
<h1>Welcome to NHN Cloud Web Server</h1>
<p id="server-ip">Fetching server IP address...</p>
<button id="start-btn" onclick="startStressTest()">Start Stress Test</button>
<p id="countdown">Time left: 120 seconds</p>
</body>
</html>' > /web-sample/index.html
myobs
를 클릭하여 컨테이너 상세 페이지 화면으로 이동합니다.myobs
화면에서 객체 업로드를 클릭합니다.index.html
파일을 선택 후 확인을 클릭합니다.index.html
파일 업로드 상태가 성공인 것을 확인 후 확인을 클릭합니다.index.html
객체 오른쪽에 Public URL 항목에 있는 URL 복사를 클릭해 index.html 파일의 Public URL 주소를 복사합니다.linux-server-basic
에 원격 접속을 합니다.[참고]
linux-server-basic
에 원격 접속 방법
- 해당 원격 접속 방법은 4. 네트워크 설정과 인스턴스 생성 - 단계 1. SSH 원격 접속하기를 참고바랍니다.
linux-server-basic
원격 접속 후 아래 명령어를 실행해 index.html을 다운로드한 후 저장합니다.sudo curl -o /var/www/html/index.html (myobs에 업로드한 index.html 파일의 Public URL)
알아두기
/var/www/html
입니다. http://복사한 linux-server-basic 플로팅 IP 주소
에 접속 시 출력되는 웹 페이지 문서는 /var/www/html/index.html
입니다.curl -s https://kr2-api-object-storage.nhncloudservice.com/v1/AUTH_cd41d4b57c1346b99641cc4092f2842d/onboarding/service-setting.sh | sed 's/\r$//' > /home/ubuntu/service-setting.sh
chmod +x /home/ubuntu/service-setting.sh
/home/ubuntu/service-setting.sh
http://복사한 linux-server-basic 플로팅 IP 주소
를 입력하여 변경된 웹 페이지를 확인합니다.
알아두기
Ctrl + F5
또는 Shift + F5
Cmd + Shift + R