项目作者: rudibroekhuizen

项目描述 :
PostgreSQL with Kibana dashboard running on Docker
高级语言: Shell
项目地址: git://github.com/rudibroekhuizen/docker-postgresplus.git
创建时间: 2017-06-27T20:21:50Z
项目社区:https://github.com/rudibroekhuizen/docker-postgresplus

开源协议:Apache License 2.0

下载


docker-postgresplus

Overview

PostgreSQL playground running on Docker with logs presented in Kibana dashboard and Pgadmin webinterface.

Usage

Install docker and docker-compose. Clone this repo to your local machine. Than start the containers:

  1. docker-compose up

Open pgAdmin webinterface

  1. [pgadmin]: http://pgadmin.docker.localhost/

Database, username and password: postgres

Connect to Postgres container

  1. docker exec -it dockerpostgresplus_postgres_1 sh (or docker-compose exec postgres sh)
  2. su
  3. docker-compose exec postgres psql -U postgres

Download and unzip test database (in the container)

  1. wget https://s3.amazonaws.com/assets.datacamp.com/course/sql/dvdrental.zip; unzip dvdrental.zip

Create database (psql)

  1. su postgres
  2. psql
  3. CREATE DATABASE sakila;
  4. exit

Load database using pg_restore

  1. pg_restore -U postgres -d sakila dvdrental.tar

Collect logs

  1. docker-compose exec postgres bash /scripts/pglog.sh

Run 1000 queries

  1. yes "select * from public.film_actor;" | head -n 1000 | parallel "psql -U postgres -d sakila -c {1}"

Pgbench

  1. psql> CREATE DATABASE pgbenchdb;
  2. pgbench -i -s 50 pgbenchdb
  3. pgbench -c 10 -j 2 -t 1000 pgbenchdb

Import dashboard

To make sure all fields exist prior to importing the Kibana dashboard, run pgbench first.

Grafana

URL: http://elasticsearch:9200
Access: proxy
Index name: logstash- (daily pattern)
Version: 5.x

Useful commands

  1. # Check CPU consumption
  2. $ docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -q))
  3. # Remove containers plus volumes
  4. $ docker-compose down -v --remove-orphans --rmi all
  5. # docker-compose Elasticsearch
  6. Elasticsearch uses a hybrid mmapfs / niofs directory by default to store its indices. The default operating system limits on mmap counts is likely to be too low, which may result in out of memory exceptions. On Linux, you can increase the limits by running the following command as root:
  7. One time:
  8. $ sysctl -w vm.max_map_count=262144
  9. Persistant:
  10. $ echo 'vm.max_map_count=262144' >> /etc/sysctl.conf

postgres

postgres

postgres

postgres