noxma forum

noxma forum description


    Postgressql

    Share

    Admin
    Admin

    จำนวนข้อความ : 33
    Join date : 09/12/2017

    Postgressql

    ตั้งหัวข้อ by Admin on Tue Feb 06, 2018 6:36 pm

    sudo su postgres
    su - ubuntu


    Service
    sudo systemctl start postgresql@9.6-main.service
    /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf

    Postgres Data
    /var/lib/postgresql/9.6/main


    sudo su postgres
    postgres-# \du

                                       List of roles
     Role name  |                         Attributes                         | Member of
    -------------+------------------------------------------------------------+-----------
    flectra     | Superuser, Create role, Create DB                          | {}
    noxma       | Create DB                                                  | {}
    odoo        | Create DB                                                  | {}
    odoo11      | Create DB                                                  | {}
    postgres    | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
    sentry_user |                                                            | {}


    postgres-# \list
                                      List of databases
      Name    |  Owner   | Encoding |   Collate   |    Ctype    |    Access privileges    
    -----------+----------+----------+-------------+-------------+--------------------------
    FlectraDB | flectra  | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    SWU       | odoo     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    noxmadb   | noxma    | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    odoo11CE  | odoo     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    sentry_db | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres            +
              |          |          |             |             | postgres=CTc/postgres   +
              |          |          |             |             | sentry_user=CTc/postgres
    template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres             +
              |          |          |             |             | postgres=CTc/postgres
    template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres             +
              |          |          |             |             | postgres=CTc/postgres

    Admin
    Admin

    จำนวนข้อความ : 33
    Join date : 09/12/2017

    Move Data directory

    ตั้งหัวข้อ by Admin on Wed Feb 07, 2018 4:12 pm

    sudo rsync -av /var/lib/postgresql /mnt/volume-nyc1-01
    sudo mv /var/lib/postgresql/9.5/main /var/lib/postgresql/9.5/main.bak
    sudo nano /etc/postgresql/9.5/main/postgresql.conf

    Code:
    /etc/postgresql/9.5/main/postgresql.conf
    . . .
    data_directory = '/mnt/volume-nyc1-01/postgresql/9.5/main'
    . . .

    postgres# SHOW data_directory;
         data_directory
    -----------------------------------------
    /mnt/volume-nyc1-01/postgresql/9.5/main
    (1 row)

    Admin
    Admin

    จำนวนข้อความ : 33
    Join date : 09/12/2017

    Docker for postgresql9.6

    ตั้งหัวข้อ by Admin on Sat Feb 10, 2018 12:30 pm

    Project path
    /data/projects/postgresql

    Code:
    sudo docker build -t postgresql9

    sudo docker volume create --name postgresql9-db-data
    sudo docker volume create --name postgresql9-db-config
    sudo docker volume create --name postgresql9-db-log

    sudo docker run \
     -e POSTGRES_USER='docker' \
     -e POSTGRES_PASSWORD='docker' \
     -v postgresql9-dev-data:/var/lib/postgresql \
     -v postgresql9-dev-config:/etc/postgresql \
     -v postgresql9-dev-log:/var/log/postgresql  \
     --rm -d --name postgresql9-db-host postgresql9:latest


    * Access
    #exec expression to docker’s container
    sudo docker exec -it <container id> bash
    sudo docker exec -it <name> ip addr


    * Status
    #list docker container
    sudo docker ps -a

    * Clear / stop
    #list all exited container
    sudo docker ps -aq -f status=exited
    #Remove stopped containers
    sudo docker ps -aq --no-trunc | xargs sudo docker rm
    sudo docker rm <name>


    * Image
    #list docker image
    sudo docker images -a

    #list docker image id
    sudo docker images -a|grep "<none>"|awk '$1=="<none>" {print $3}'

    #Clear all unused
    sudo docker image prune -a

    #Delete to untamed image
    sudo docker images -q —no-truc | xargs sudo docker rmi
    sudo docker rmi $(docker images --filter “dangling=true” -q --no-trunc)



    Remove dangling/untagged images
    docker images -q --filter dangling=true | xargs docker rmi
    Remove containers created after a specific container
    docker ps --since a1bz3768ez7g -q | xargs docker rm
    Remove containers created before a specific container
    docker ps --before a1bz3768ez7g -q | xargs docker rm


    $ psql -h localhost -p 49153 -d docker -U docker --password

    #### CASE upgrade
    docker pull mysql
    docker stop my-mysql-container
    docker rm my-mysql-container
    docker run --name=my-mysql-container --restart=always \
      -e MYSQL_ROOT_PASSWORD=mypwd -v /my/data/dir:/var/lib/mysql -d mysql

      เวลาขณะนี้ Mon May 21, 2018 1:44 pm