• minishift 部署postgresql


    启动minishit之后

    1.登陆openshift

    oc login -u system:admin

    2.创建项目

    oc new-project pg-demo

    ---------------------------------------------------------------------------------------------

    Now using project "pg-demo" on server "https://192.168.42.106:8443".

    You can add applications to this project with the 'new-app' command. For example, try:

        oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git
    3.创建应用

    oc new-app -e POSTGRESQL_USER=caihemm -e POSTGRESQL_PASSWORD=caihemm -e POSTGRESQL_DATABASE=caihemm postgresql

    --------------------------------------------------------------------------------------------------

    --> Found image a83d523 (9 days old) in image stream "openshift/postgresql" under tag "10" for "postgresql"

        PostgreSQL 10
        -------------
        PostgreSQL is an advanced Object-Relational database management system (DBMS). The image contains the client and server programs that you'll need to create, run, maintain and access a PostgreSQL DBMS server.

        Tags: database, postgresql, postgresql10, rh-postgresql10

        * This image will be deployed in deployment config "postgresql"
        * Port 5432/tcp will be load balanced by service "postgresql"
          * Other containers can access this service through the hostname "postgresql"

    --> Creating resources ...
        imagestreamtag.image.openshift.io "postgresql:10" created
        deploymentconfig.apps.openshift.io "postgresql" created
        service "postgresql" created
    --> Success
        Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
         'oc expose svc/postgresql'
        Run 'oc status' to view your app.

    4.查看app

    oc status

    5.查看pod

    oc get pod

    ------------------------------------------

    NAME                 READY     STATUS    RESTARTS   AGE
    postgresql-1-6dkmq   1/1       Running   0          2m

    6.查看日志

    oc logs postgresql-1-6dkmq

    7.进入容器

    oc rsh postgresql-1-6dkmq

    8.查看数据库

    psql -c "l"

    sh-4.2$ psql -c "l"
                                     List of databases
       Name    |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
    -----------+----------+----------+------------+------------+-----------------------
     caihemm   | caihemm  | UTF8     | en_US.utf8 | en_US.utf8 |
     postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |
     template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
               |          |          |            |            | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
               |          |          |            |            | postgres=CTc/postgres
    9.  退出来,作个端口映射

    oc port-forward postgresql-1-6dkmq 5432

    Forwarding from 127.0.0.1:5432 -> 5432
    Forwarding from [::1]:5432 -> 5432
    10.用dbeaver登陆数据库

     10.也可以作成服务

    oc expose dc postgresql --type=LoadBalancer --name=mpostgresql-ingress

    oc get svc

    -------------------------------------------

    NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP                 PORT(S)          AGE
    mpostgresql-ingress   LoadBalancer   172.30.61.236   172.29.93.17,172.29.93.17   5432:31841/TCP   32s
    postgresql            ClusterIP      172.30.16.26    <none>                      5432/TCP         15m
    11.获取minishit ip

    minishit ip

    192.168.42.106
    12. 登陆数据库

  • 相关阅读:
    面经-新浪
    面经-中兴
    面经-趋势科技
    面经-酷家乐
    面经-大华
    面经-明略科技
    面经-小米
    面经-虹软
    coroutine
    Coroutine 终止协程和异常处理
  • 原文地址:https://www.cnblogs.com/caihemm/p/13332899.html
Copyright © 2020-2023  润新知