2017년 1월 24일 화요일

MySQL or MariaDB FederatedX Storage Engine

MySQL 계열에서 DB Link 기능 같은걸 찾아 보다 찾은 Storage Engine 이다.
MySQL 은 Federated Engine 이 기본적으로 탑재 되어 있다. 그리고 X 는 MariaDB에서 사용하는 확장 판이다.
또한 타겟에서 끌고 올때 소스의 버퍼에 올리기 때문에 통으로나 데이터량이 많으면 소스에 스와핑이 생기거나 OOM 이 생길 수 있다.


/**
    MySQL or MariaDB FederatedX Storage Engine 
    ( like dblink of oracle)
*/

--
-- 01. Plugin Install
--

INSTALL PLUGIN federated SONAME 'ha_federatedx.so';

# my.cnf
federated # 이부분 추가

--
-- 02. Configure
--

connection=scheme://username:password@hostname:port/database/tablename
connection=scheme://username@hostname/database/tablename
connection=scheme://username:password@hostname/database/tablename
connection=scheme://username:password@hostname/database/tablename
ex)
connection=mysql://username:password@hostname:port/database/tablename



onnection="connection_one"
connection="connection_one/table_foo"

ex)
# 사용시 table name change 안됨 
create server 'server_one' foreign data wrapper 'mysql' options
  (HOST '127.0.0.1',
  DATABASE 'db1',
  USER 'root',
  PASSWORD '',
  PORT 3306,
  SOCKET '',
  OWNER 'root');

ex)

CREATE TABLE federatedx.t1 (
  `id` int(20) NOT NULL,
  `name` varchar(64) NOT NULL default ''
  )
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='server_one';

# table name change 가능
CREATE TABLE test_table ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:9306/federatedx/test_federatedx';

--
-- 03. explain
-- ( 원격 테이블도 인덱스를 사용할수 있다.)

+------+-------------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| id   | select_type | table      | type  | possible_keys | key     | key_len | ref   | rows | filtered | Extra |
+------+-------------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
|    1 | SIMPLE      | ox_clients | const | PRIMARY       | PRIMARY | 3       | const |    1 |   100.00 |       |
+------+-------------+------------+-------+---------------+---------+---------+-------+------+----------+-------+

--
-- 99. 작업 절차
--

INSTALL PLUGIN federated SONAME 'ha_federatedx.so';

create database if not exists dblink;

grant all on dblink.* to `root`@`localhost`;

use dblink;

create server 'server_one' foreign data wrapper 'mysql' options
(
    HOST '127.0.0.1',
    DATABASE 'db1',
    USER 'root',
    PASSWORD '',
    PORT 3306,
    SOCKET '',
    OWNER 'root'
);

create table if not exists dblink.tbl_link_01
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='server_one';

create table if not exists dblink.tbl_link_02
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root:aaaa@127.0.0.1:9306/federatedx/test_federatedx';

CREATE TABLE dblink.tbl_link_03
(
  id     int(20) NOT NULL auto_increment,
  name   varchar(32) NOT NULL default '',
  other  int(20) NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY name (name),
  KEY other_key (other)
)
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:9306/federatedx/test_federatedx';


2017년 1월 23일 월요일

SQL 레벨업 DB 성능 최적화를 위한 SQL 실전 가이드









SQL 레벨업 DB 성능 최적화를 위한 SQL 실전 가이드

미크 지음 | 윤인성 옮김 | 한빛미디어 | 2016년 01월 30일 출간 

서평:
  가끔은 그럴때가 있다. 어려운 문제를 어떻게 SQL 로 풀어 낼까 하고 그런 고민에 대한 해답을 주는 책이다. 이책도 일본 엔지니어가 쓴 책인데...
 

2017년 1월 18일 수요일

Netflix Billing Migration to AWS

Netflix Billing Migration 관련 Tech Blog 자료를 보다 간략하게 정리를 했음 기존 Oracle 에서 AWS 의 MySQL 로 넘어 가는 과정을 정리 했는데 느끼는 점이 많음

IDC (ORACLE) -> AWS(EC2+MySQL5.6) -> AWS Auroa

Master Replication -> DBDC

Read Slave -> Async Replication

http://techblog.netflix.com/2016/06/netflix-billing-migration-to-aws.html http://techblog.netflix.com/2016/07/netflix-billing-migration-to-aws-part-ii.html http://techblog.netflix.com/2016/08/netflix-billing-migration-to-aws-part.html


###
# Netflix MySQL Billing Database
# MySQL 5.6 + Linux 
###

--
-- 01. Bluk Insert
--

innodb_log_file_size = 2048M
innodb_lru_scan_depth = 128
innodb_adaptive_hash_index = off
innodb_flush_neighbors = off
transaction_isolation = READ-COMMITTED
query_cache_size = 0
query_cache_type = 0
innodb_doublewrite = off


--
-- 02. High Transction
-- 

innodb_log_file_size = 2048M
innodb_lru_scan_depth = 128
innodb_adaptive_hash_index = off
innodb_flush_neighbors = off
transaction_isolation = READ-COMMITTED
query_cache_size = 0
query_cache_type = 0
innodb_doublewrite = off

innodb_max_dirty_pages_pct = 80
innodb_buffer_pool_instances = 8
innodb_log_buffer_size = 64<


--
-- 03 os kernel
--

kernel.numa_balancing = 0 # instead of numactl

vm.dirty_ratio = 40
vm.dirty_background_ratio = 5
vm.swappiness = 0
vm.aio-max-nr = 65535
vm.rq_affinity = 2
vm.scheduler = cfq

2017년 1월 13일 금요일

전문가를 위한 트러블슈팅 오라클 퍼포먼스








전문가를 위한 트러블슈팅 오라클 퍼포먼스

2판
크리스티안 안토니니 지음 | (주)위즈베이스 옮김 | 제이펍 | 2016년 05월 03일 출간 

서평:
  해당 책은 국내 오라클 컨설팅 회사인 위즈베이스에서 번역을 한 오라클 관련 책이다. 
책의 내용도 심도 깊은 흥미 있는 이야기들도 씌여 있고 또한 번역도 읽기에 불편함이 없이  편하다.

2017년 1월 9일 월요일

MySQL류의 RDBMS 에서의 Slow Query Log 방법및 3th party Tools

-- logging stop

set global slow_query_log = OFF;

--
-- Log file move 이 후 
--
FLUSH LOGS;


-- 수집 조건 설정

set global long_query_time = 1; --  전체 적으로 성능 부분을 볼려면 0초로 설정 하여 모든 쿼리를 로깅함
set global log_queries_not_using_indexes = ON;

-- logging start
set global slow_query_log = ON;

--
-- 분석 Tools
-- ( Percona Toolkit )
--  https://www.github.com/percona/percona-toolkit

pt-query-digest 
Usage: pt-query-digest [OPTIONS] [FILES] [DSN]

2017년 1월 3일 화요일

오라클 레벨업 최고의 전문가 그룹이 알려주는 오라클 실전 100가지 기술



 


오라클 레벨업 최고의 전문가 그룹이 알려주는 오라클 실전 100가지 기술

스즈키 겐고 , 다마오키 다케히로, 시오바라 고타, 고바야시 오사무, 오모리 신지, 우치무라 도모아키 지음 | 윤인성, / 옮김 | 한빛미디어 | 2016년 12월 20일 출간 

서평:
 일본 엔지니어들의 기술력에 대해서 다시 한번 생각해 보게 하는 책이다. 오라클의 핵심적인 100가지의 팁을 예제와 같이 설명을 하여 이해 하기 쉽게 쓰여졌다. 나도 나중에 이런 책을 내보고 싶다.