Skip to content

Instantly share code, notes, and snippets.

View sebastianwebber's full-sized avatar
🏠
Working from home

Sebastian Webber sebastianwebber

🏠
Working from home
View GitHub Profile
@sebastianwebber
sebastianwebber / README.md
Last active April 6, 2019 01:30
Zabbix 3 Install on CEntOS 7 with PostgreSQL 9.5

Zabbix 3 Install on CEntOS 7 with PostgreSQL 9.5

Repo installation

Zabbix repo

yum install http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
@sebastianwebber
sebastianwebber / setup.sql
Created August 27, 2016 14:17
compare rows on different tables (with the same structure)
test=# \pset null UNKNOW
Null display is "UNKNOW".
test=# create table employee1(id serial primary key, name text);
CREATE TABLE
test=# create table employee2(id serial primary key, name text);
CREATE TABLE
test=# -- load the fake data on employee1
test=# insert into employee1 (name) SELECT '1: Person '|| generate_series(1,10);
INSERT 0 10
test=# -- load the fake data on employee2
@sebastianwebber
sebastianwebber / exemplo.sql
Created August 23, 2016 17:29
exemplo de retorno de multiplas linhas em PL/PGSQL
CREATE OR REPLACE FUNCTION fnc_intervalo()
RETURNS SETOF interval AS
$$
DECLARE
BEGIN
RETURN NEXT 1;
RETURN NEXT 2;
END;
$$ LANGUAGE 'plpgsql';
@sebastianwebber
sebastianwebber / README.md
Created August 11, 2016 11:19
Dojo sobre MySQL Enterprise executado na Constat LM2

MySQL DOJO -> Constat LM2

Dojo sobre MySQL Enterprise executado na Constat LM2 no dia 05/09/2016.

TODO List

  • Instalação no El7
  • Avaliar conceitos de tuning
  • Backup e Restore
  • Disaster Recovery issues
#!/bin/bash
ARCHIVEDIR='/var/lib/pgsql/wal_archive'
LAST_BACKUP=$(ls -lto ${ARCHIVEDIR})
FILE_LIST=$(pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}")
## TEST FIRST
pg_archivecleanup -n "${ARCHIVEDIR}" "${LAST_BACKUP}" | find -type f -mmin +30 | xargs ls -lh
@sebastianwebber
sebastianwebber / README.md
Last active February 19, 2024 11:44
Compilation of the Uber Facts on PostgreSQL to MySQL Migration

Uber facts

Original posts/information

Key points

  • ~50GB MySQL Application
  • Main motivation: PostGis
  • Migration made with a custom tool(xml2pgcopy) and mysqldump on 45min
-- criação da função
CREATE OR REPLACE FUNCTION fnc_roda_selects()
RETURNS SETOF RECORD
AS $$
DECLARE
rResult RECORD;
BEGIN
-- tenta buscar dados na tabela com um filtro especifico
PERFORM * FROM dw.dim_tempo;
@sebastianwebber
sebastianwebber / README.md
Last active August 1, 2016 22:39
SR replication howto

Setup do HOT Standby com Streamming replication

Antes de começar

Remoção dos diretórios de dados (PGDATA)

Antes de iniciar, remova o pare o banco de dados e remova o diretório de dados anterior e recrie-o novamente:

systemctl stop postgresql-9.5
rm -rf /var/lib/pgsql/9.5/data
/usr/pgsql-9.5/bin/postgresql95-setup initdb
@sebastianwebber
sebastianwebber / README.md
Last active July 30, 2016 01:35
Laborário sobre WARM Standby

Setup do Warm Standby

Antes de começar

Remoção dos diretórios de dados (PGDATA)

Antes de iniciar, remova o pare o banco de dados e remova o diretório de dados anterior e recrie-o novamente:

systemctl stop postgresql-9.5
rm -rf /var/lib/pgsql/9.5/data
/usr/pgsql-9.5/bin/postgresql95-setup initdb
@sebastianwebber
sebastianwebber / playbook.yml
Created July 28, 2016 11:41
[Ansible] PostgreSQL Installation on EL7 Systems
---
## PostgreSQL Installation on EL7 Systems
- hosts: all
vars:
pgdg_repo: "https://download.postgresql.org/pub/repos/yum"
pg_version: "9.5"
repo_file: "{{pgdg_repo}}/{{pg_version}}/redhat/rhel-7-x86_64/pgdg-centos{{pg_version | replace('.','')}}-{{pg_version}}-2.noarch.rpm"
pg_packages_base: "postgresql{{pg_version | replace('.','')}}"
tasks:
- name: Install needed repos