| [도서] PostgreSQL 성능 최적화 |
| 저자 그레고리 스미스 | 출판사 지앤선 |
서평:
번역이 엉망이다. 무슨 번역기 돌린듯한 느낌 그래서 내용에 집중을 못하겠다.
/**
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';
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
-- 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]