IBMCloud에서 IBM Cloud Shell에서 Databases for PostgreSQL을 프로비저닝하고 연결해보기

13178 단어 PostgreSQLibmcloud

개요



명령행(ibmcloud 명령)에서 PostgreSQL 서비스 인스턴스를 배치하고 연결해 보십시오.
감상: 커맨드의 help를 출력하면서 실시했습니다만, 생각보다 간단하고 간단하게 설정할 수 있었습니다.

절차 개요


  • IBM Cloud Shell 시작
  • ibmcloud 명령에 자원 그룹 설정
  • 카탈로그 검색
  • 서비스 인스턴스 만들기
  • PostgreSQL admin 사용자의 암호 설정
  • admin 사용자로 연결

  • 1. IBM Cloud Shell 시작



    IBMCloud 콘솔의 오른쪽 상단에 있는 IBM Cloud 쉘 아이콘에서 IBM Cloud Shell을 시작하십시오.


    2. IBM Cloud Shell에 자원 그룹 설정



    IBM Cloud Shell을 시작한 직후에는 ibmcloud 명령에 자원 그룹 설정이 없으므로 설정하십시오.

    설정 확인
    TSOTA@cloudshell:~$ ibmcloud target 
    
    
    API endpoint:      https://cloud.ibm.com   
    Region:            jp-tok   
    User:              xxxx   
    Account:           xxxx 
    Resource group:    No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'   
    CF API endpoint:      
    Org:                  
    Space:
    

    리소스 그룹 확인
    TSOTA@cloudshell:~$ ibmcloud resource groups
    Retrieving all resource groups under account xxxx as xxxx...
    OK
    Name      ID                                 Default Group   State   
    Default   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   true            ACTIVE  
    

    리소스 그룹 설정
    TSOTA@cloudshell:~$ ibmcloud target -g Default
    Targeted resource group Default
    
    API endpoint:      https://cloud.ibm.com   
    Region:            jp-tok   
    User:              xxxx  
    Account:           xxxx
    Resource group:    Default   
    CF API endpoint:      
    Org:                  
    Space:
    

    카탈로그 검색



    서비스 인스턴스를 만들 때 서비스 ID와 계획 ID가 필요하므로 카탈로그를 검색하고 확인합니다.

    postgreSQL에서 카탈로그 검색
    TSOTA@cloudshell:~$ ibmcloud catalog search postgreSQL
    Getting offerings...
    OK
    Name                                                                      ID                                     Kind   
    Databases for EnterpriseDB                                                databases-for-enterprisedb-group       service   
    Databases for PostgreSQL                                                  databases-for-postgresql-group         service   
    Hyper Protect DBaaS for PostgreSQL                                        024d3260-5cf4-11e9-90a2-37a496589afc   service   
    OSS Record: Compose for PostgreSQL(compose-for-postgresql)                oss.compose-for-postgresql             oss   
    OSS Record: Databases for PostgreSQL(databases-for-postgresql)            oss.databases-for-postgresql           oss   
    OSS Record: Hyper Protect DBaaS for PostgreSQL(hyperp-dbaas-postgresql)   oss.hyperp-dbaas-postgresql            oss   
    TSOTA@cloudshell:~$ 
    

    서비스에 대해 자세히 알아보기
    TSOTA@cloudshell:~$ ibmcloud catalog service databases-for-postgresql-group  
    Getting catalog entry...
    OK
    
    ID                 databases-for-postgresql-group   
    Name               databases-for-postgresql-group   
    Kind               service   
    Provider           IBM   
    Tags               apidocs_enabled, big_data, data_management, database, eu_access, gc_migrate, group, hipaa, ibm_created, service_endpoint_supported   
    Active             true   
    Description        PostgreSQL is a powerful, open source object-relational database that is highly customizable.   
    Bindable           true   
    Original Name         
    RC Compatible      true   
    RC Provisionable   false   
    IAM Compatible     false   
    Children           Name                        Kind         ID                                           Location   Original Location   Target      
                       compose-for-postgresql      service      ComposePostgreSQL-P                                                               
                       |__enterprise               plan         ComposePostgresqlEnterprise                                                       
                       |  |__enterprise-au-syd     deployment   ComposePostgresqlEnterprise:au-syd           au-syd                         bluemix-au-syd      
                       |  |__enterprise-eu-de      deployment   ComposePostgresqlEnterprise:eu-de            eu-de                          bluemix-eu-de      
                       |  |__enterprise-eu-gb      deployment   ComposePostgresqlEnterprise:eu-gb            eu-gb                          bluemix-eu-gb      
                       |  |__enterprise-us-east    deployment   ComposePostgresqlEnterprise:us-east          us-east                        bluemix-us-east      
                       |  |__enterprise-us-south   deployment   ComposePostgresqlEnterprise:us-south         us-south                       bluemix-us-south      
                       |__standard                 plan         ComposePostgresqlStandard                                                         
                          |__standard-au-syd       deployment   ComposePostgresqlStandard:au-syd             au-syd                         bluemix-au-syd      
                          |__standard-eu-de        deployment   ComposePostgresqlStandard:eu-de              eu-de                          bluemix-eu-de      
                          |__standard-eu-gb        deployment   ComposePostgresqlStandard:eu-gb              eu-gb                          bluemix-eu-gb      
                          |__standard-us-east      deployment   ComposePostgresqlStandard:us-east            us-east                        bluemix-us-east      
                          |__standard-us-south     deployment   ComposePostgresqlStandard:us-south           us-south                       bluemix-us-south      
                       databases-for-postgresql    service      databases-for-postgresql                                                          
                       |__standard                 plan         databases-for-postgresql-standard                                                 
                          |__standard-au-syd       deployment   databases-for-postgresql-standard:au-syd     au-syd                         bluemix-au-syd      
                          |__standard-che01        deployment   databases-for-postgresql-standard:che01      che01                          bluemix-che01      
                          |__standard-eu-de        deployment   databases-for-postgresql-standard:eu-de      eu-de                          bluemix-eu-de      
                          |__standard-eu-gb        deployment   databases-for-postgresql-standard:eu-gb      eu-gb                          bluemix-eu-gb      
                          |__standard-jp-tok       deployment   databases-for-postgresql-standard:jp-tok     jp-tok                         bluemix-jp-tok      
                          |__standard-osl01        deployment   databases-for-postgresql-standard:osl01      osl01                          bluemix-osl01      
                          |__standard-seo01        deployment   databases-for-postgresql-standard:seo01      seo01                          bluemix-seo01      
                          |__standard-us-east      deployment   databases-for-postgresql-standard:us-east    us-east                        bluemix-us-east      
                          |__standard-us-south     deployment   databases-for-postgresql-standard:us-south   us-south                       bluemix-us-south      
    TSOTA@cloudshell:~$ 
    

    4. 서비스 인스턴스 만들기



    이전 단계에서 확인한 서비스 ID와 계획 ID를 지정하여 서비스 인스턴스를 만듭니다.
    postgreSQL2라는 서비스 인스턴스를 만듭니다.

    서비스 인스턴스 만들기
    TSOTA@cloudshell:~$ ibmcloud resource service-instance-create postgreSQL2 databases-for-postgresql standard jp-tok
    Creating service instance postgreSQL2 in resource group Default of account ibmj-cloud-freeusage-p035 as [email protected]...
    OK
    Service instance postgreSQL2 was created.
    
    Name:                postgreSQL2   
    ID:                  xxxx 
    GUID:                xxxx  
    Location:            jp-tok   
    State:               provisioning   
    Type:                service_instance   
    Sub Type:            Public   
    Service Endpoints:   public   
    Allow Cleanup:       false   
    Locked:              false   
    Created at:          2020-12-12T05:06:54Z   
    Updated at:          2020-12-12T05:06:54Z   
    Last Operation:                      
                         Status    create in progress      
                         Message   Started create instance operation      
    

    서비스 인스턴스를 나열하여 프로비저닝 상태를 확인합니다.
    상태가 Active가 될 때까지 기다립니다.

    서비스 인스턴스의 상태 확인
    TSOTA@cloudshell:~$ ibmcloud resource service-instances
    Retrieving instances with type service_instance in resource group Default in all locations under account xxxx as xxxx...
    OK
    Name                              Location   State          Type   
    ・・・・
    postgreSQL2                       jp-tok     provisioning   service_instance   
    Retrieving instances with type service_instance in resource group Default in all locations under account xxxx as xxxx
    OK
    Name                              Location   State    Type   
    ・・・・
    postgreSQL2                       jp-tok     active   service_instance   
    TSOTA@cloudshell:~$ ibmcloud cdb ls
    Retrieving instances for all database types in resource group Default in all locations under xxxx as xxxx...
    OK
    Name                          Location   State    
    postgreSQL2                   jp-tok     active   
    

    5. PostgreSQL admin 사용자의 비밀번호 설정



    admin 사용자의 암호를 설정합니다.

    비밀번호 설정
    TSOTA@cloudshell:~$ ibmcloud cdb user-password postgreSQL2 admin
    User Password>> 
    Confirm User Password>> 
    The user's password is being changed with this task:
    
    Key                   Value   
    ID                    xxxx   
    Deployment ID         xxxx 
    Description           Updating user.   
    Created At            2020-12-12T05:21:46Z   
    Status                running   
    Progress Percentage   0   
    
    Status                completed   
    Progress Percentage   100   
    Location              xxxx  
    OK
    

    6. admin 사용자로 연결



    ibmcloud 명령으로 데이터베이스에 연결하여 SQL 및 명령을 실행할 수 있습니다.

    데이터베이스에 연결
    TSOTA@cloudshell:~$ ibmcloud cdb deployment-connections postgreSQL2 --start
    Database Password>> 
    psql (10.15 (Ubuntu 10.15-0ubuntu0.18.04.1), server 12.5)
    WARNING: psql major version 10, server major version 12.
             Some psql features might not work.
    SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
    Type "help" for help.
    
    ibmclouddb=> select user;
     user  
    -------
     admin
    (1 row)
    
    ibmclouddb=> create user user1 password 'isepassword';
    CREATE ROLE
    ibmclouddb=> create table t1(c1 int);
    CREATE TABLE
    ibmclouddb=> insert into t1 values (1);
    INSERT 0 1
    ibmclouddb=> select * from t1;
     c1 
    ----
      1
    (1 row)
    
    ibmclouddb=> \dt
     public | t1   | table | admin
    ibmclouddb=> \q
    TSOTA@cloudshell:~$ 
    

    이상.

    좋은 웹페이지 즐겨찾기