관리형 노트북에서 Apache Spark용 서버리스 사용

이 페이지에서는 Apache Spark용Google Cloud 서버리스를 사용하여 Vertex AI Workbench 관리형 노트북 인스턴스에 있는 서버리스 Spark에서 노트북 파일을 실행하는 방법을 보여줍니다.

관리형 노트북 인스턴스는 Apache Spark용 서버리스 서비스에서 실행할 노트북 파일 코드를 제출할 수 있습니다. 이 서비스는 필요에 따라 리소스를 자동으로 확장하는 관리형 컴퓨팅 인프라에서 코드를 실행합니다. 따라서 자체 클러스터를 프로비저닝하고 관리할 필요가 없습니다.

Serverless for Apache Spark 요금은 워크로드가 실행될 때만 적용됩니다.

요구사항

Serverless for Apache Spark에서 노트북 파일을 실행하려면 다음 요구사항을 참고하세요.

  • Apache Spark용 Serverless 세션은 관리형 노트북 인스턴스와 동일한 리전에서 실행되어야 합니다.

  • OS 로그인 필요(constraints/compute.requireOsLogin) 제약조건은 프로젝트에 대해 사용 설정되지 않아야 합니다. 조직의 OS 로그인 관리를 참조하세요.

  • Serverless for Apache Spark에서 노트북 파일을 실행하려면 특정 권한이 있는 서비스 계정을 제공해야 합니다. 이러한 권한을 기본 서비스 계정에 부여하거나 커스텀 서비스 계정을 제공할 수 있습니다. 이 페이지의 권한 섹션을 참조하세요.

  • Apache Spark용 서버리스 세션은 Virtual Private Cloud (VPC) 네트워크를 사용하여 워크로드를 실행합니다. VPC 서브네트워크는 특정 요구사항을 충족해야 합니다. Google Cloud Spark 네트워크 구성을 위한 Apache Spark용 서버리스의 요구사항을 참고하세요.

권한

서비스 계정에 Apache Spark용 서버리스에서 노트북 파일을 실행하는 데 필요한 권한이 있는지 확인하려면 관리자에게 프로젝트에 대한 Dataproc 편집자 (roles/dataproc.editor) IAM 역할을 서비스 계정에 부여해 달라고 요청하세요.

역할 부여에 대한 자세한 내용은 프로젝트, 폴더, 조직에 대한 액세스 관리를 참조하세요.

이 사전 정의된 역할에는 Serverless for Apache Spark에서 노트북 파일을 실행하는 데 필요한 권한이 포함되어 있습니다. 필요한 정확한 권한을 보려면 필수 권한 섹션을 펼치세요.

필수 권한

Serverless for Apache Spark에서 노트북 파일을 실행하려면 다음 권한이 필요합니다.

  • dataproc.agents.create
  • dataproc.agents.delete
  • dataproc.agents.get
  • dataproc.agents.update
  • dataproc.session.create
  • dataproc.sessions.get
  • dataproc.sessions.list
  • dataproc.sessions.terminate
  • dataproc.sessions.delete
  • dataproc.tasks.lease
  • dataproc.tasks.listInvalidatedLeases
  • dataproc.tasks.reportStatus

관리자는 커스텀 역할이나 다른 사전 정의된 역할을 사용하여 서비스 계정에 이러한 권한을 부여할 수도 있습니다.

시작하기 전에

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Notebooks, Vertex AI, and Dataproc APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Notebooks, Vertex AI, and Dataproc APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the APIs

  8. 아직 구성 전이라면 Apache Spark용 서버리스 네트워크 구성에 나열된 요구사항을 충족하는 VPC 네트워크를 구성합니다.Google Cloud
  9. JupyterLab 열기

    1. Google Cloud 콘솔에서 관리형 노트북 페이지로 이동합니다.

      관리형 노트북으로 이동

    2. 관리형 노트북 인스턴스 이름 옆에 있는 JupyterLab 열기를 클릭합니다.

    Apache Spark용 서버리스 세션 시작

    Apache Spark용 서버리스 세션을 시작하려면 다음 단계를 완료합니다.

    1. 관리형 노트북 인스턴스의 JupyterLab 인터페이스에서 런처 탭을 선택한 후 서버리스 Spark를 선택합니다. 런처 탭이 열려 있지 않으면 파일 > 새 런처를 선택하여 엽니다.

      서버리스 Spark 세션 만들기 대화상자가 나타납니다.

    2. 세션 이름 필드에 세션 이름을 입력합니다.

    3. 실행 구성 섹션에서 사용하려는 서비스 계정을 입력합니다. 서비스 계정을 입력하지 않으면 세션에서 Compute Engine 기본 서비스 계정이 사용됩니다.

    4. 네트워크 구성 섹션에서 Apache Spark용 서버리스 Dataproc 네트워크 구성에 나열된 요구사항을 충족하는 네트워크 및 네트워크의 서브네트워크를 선택합니다.Google Cloud

    5. 만들기를 클릭합니다.

      새 노트북 파일이 열립니다. 생성한 Apache Spark용 서버리스 세션은 노트북 파일 코드를 실행하는 커널입니다.

    Apache Spark용 서버리스 및 기타 커널에서 코드 실행

    1. 새 노트북 파일에 코드를 추가하고 코드를 실행합니다.

    2. 다른 커널에서 코드를 실행하려면 커널을 변경합니다.

    3. Apache Spark용 서버리스 세션에서 코드를 다시 실행하려면 커널을 다시 Apache Spark용 서버리스 커널로 변경합니다.

    Apache Spark용 서버리스 세션 종료

    JupyterLab 인터페이스나 Google Cloud 콘솔에서 Apache Spark용 서버리스 세션을 종료할 수 있습니다. 노트북 파일의 코드는 보존됩니다.

    JupyterLab

    1. JupyterLab에서 Apache Spark용 서버리스 세션을 만들 때 생성된 노트북 파일을 닫습니다.

    2. 대화상자가 나타나면 세션 종료를 클릭합니다.

    Google Cloud 콘솔

    1. Google Cloud 콘솔에서 Dataproc 세션 페이지로 이동합니다.

      Dataproc 세션으로 이동

    2. 종료하려는 세션을 선택한 후 종료를 클릭합니다.

    Apache Spark용 서버리스 세션 삭제

    Google Cloud 콘솔을 사용하여 Apache Spark용 서버리스 세션을 삭제할 수 있습니다. 노트북 파일의 코드는 보존됩니다.

    1. Google Cloud 콘솔에서 Dataproc 세션 페이지로 이동합니다.

      Dataproc 세션으로 이동

    2. 삭제할 세션을 선택한 후 삭제를 클릭합니다.

    다음 단계