Skip to content

Commit 8ec2c75

Browse files
committed
release v0.9.3
use php-mysql-replication v2.2.0 add once_binlog_collector add time monitor add docker test
1 parent 6608cdd commit 8ec2c75

File tree

82 files changed

+17823
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+17823
-0
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
composer:
2+
composer install --optimize-autoloader
3+
4+
update-composer:
5+
composer update --no-dev --optimize-autoloader

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "ridibooks/binlog-collector",
3+
"description": "Ridibooks Binlog Collector",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "오길원",
9+
"email": "kobi97@ridi.com"
10+
}
11+
],
12+
"require": {
13+
"illuminate/support": "^5.4",
14+
"krowinski/php-mysql-replication": "2.2.0",
15+
"monolog/monolog": "^1.18.0",
16+
"ridibooks/platform-gnfdb": "^0.1",
17+
"vlucas/phpdotenv": "^2.4",
18+
"sentry/sentry": "^1.5"
19+
},
20+
"require-dev": {
21+
"phpunit/phpunit": "^6.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Binlog\\": "src/Binlog"
26+
}
27+
}
28+
}

demo/Resources/all_execute.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/bash
2+
#php tools/generate_test_sql.php > mariadb/my.master.init_test.sql
3+
./init_environment.sh
4+
./test_execute.sh
5+
./php test_result_validate.php
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker rm -f db-master;docker rm -f db-slave;docker rm -f db-slave-slave
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker run -p 3306:3306 --name db-master -e MYSQL_ROOT_PASSWORD=1234 -v /Users/kobi/workspace/php-binlog-collector/demo/Resources/mariadb/my.master.cnf:/etc/mysql/my.cnf -v /Users/kobi/workspace/php-binlog-collector/demo/Resources/mariadb/:/temp -d mariadb:10.0.27
2+
docker run -p 3307:3306 --name db-slave --link db-master:master -e MYSQL_ROOT_PASSWORD=1234 -v /Users/kobi/workspace/php-binlog-collector/demo//Resources/mariadb/my.slave.cnf:/etc/mysql/my.cnf -v /Users/kobi/workspace/php-binlog-collector/demo/Resources/mariadb/:/temp -d mariadb:10.0.27
3+
docker run -p 3308:3306 --name db-slave-slave --link db-slave:slave -e MYSQL_ROOT_PASSWORD=1234 -v /Users/kobi/workspace/php-binlog-collector/demo//Resources/mariadb/my.slave-slave.cnf:/etc/mysql/my.cnf -v /Users/kobi/workspace/php-binlog-collector/demo/Resources/mariadb/:/temp -d mariadb:10.0.27

demo/Resources/init_environment.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
echo "1. remove all docker "
2+
./docker/all-docker-rm.sh
3+
echo "2. run all docker"
4+
./docker/all-docker-run.sh
5+
sleep 12;
6+
echo "3. start db-master";
7+
docker exec -it db-master bash -c "mysql -uroot -p1234 < temp/my.master.sql"
8+
sleep 4;
9+
echo "4. start db-slave";
10+
docker exec -it db-slave bash -c "mysql -uroot -p1234 < temp/my.slave.sql"
11+
sleep 4;
12+
echo "5. start db-slave-slave";
13+
docker exec -it db-slave-slave bash -c "mysql -uroot -p1234 < temp/my.slave-slave.sql"
14+
sleep 2;
15+
echo "6. start db-master init sql";
16+
docker exec -it db-master bash -c "mysql -uroot -p1234 < temp/my.master.init_test.sql"
17+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
kobiui-MacBook-Pro:Resources kobi$ ./binlog_execute.sh
2+
[2017-08-28 10:55:28] binlog_collector.INFO: Initialize! [] []
3+
[2017-08-28 10:55:28] binlog_collector.INFO: Limit Extra PartitionMaxCount: 1000 [] []
4+
[2017-08-28 10:55:29] binlog_collector.INFO: ~ 10 PartitionCount(mariadb-bin.000004/91045965) [] []
5+
[2017-08-28 10:55:29] binlog_collector.INFO: Previous ParentBinlogOffset: [/] [] []
6+
[2017-08-28 10:55:29] binlog_collector.INFO: Previous Child GtidOffsetRanges: [] []
7+
[2017-08-28 10:55:30] binlog_collector.INFO: Master BinlogOffset: [0-1-9558/mariadb-bin.000005/34268330] [] []
8+
[2017-08-28 10:55:30] binlog_collector.INFO: Existed PartitionCount: 15 [] []
9+
[2017-08-28 10:55:30] binlog_collector.INFO: Initialize! [] []
10+
[2017-08-28 10:55:30] binlog_collector.INFO: Current BinlogOffset: [0-1-9542/mariadb-bin.000005/33572001] [] []
11+
[2017-08-28 10:55:30] binlog_collector.INFO: Limit Extra PartitionMaxCount: 985 [] []
12+
[2017-08-28 10:55:30] binlog_collector.INFO: Master BinlogOffset: [0-1-9558/mariadb-bin.000005/34268330] [] []
13+
[2017-08-28 10:55:30] binlog_collector.INFO: Existed PartitionCount: 16 [] []
14+
[2017-08-28 10:55:30] binlog_collector.INFO: Initialize! [] []
15+
[2017-08-28 10:55:30] binlog_collector.INFO: Current BinlogOffset: [0-1-9557/mariadb-bin.000005/34224297] [] []
16+
[2017-08-28 10:55:30] binlog_collector.INFO: Limit Extra PartitionMaxCount: 984 [] []
17+
[2017-08-28 10:55:30] binlog_collector.INFO: Master BinlogOffset: [0-1-9558/mariadb-bin.000005/34268330] [] []
18+
[2017-08-28 10:55:30] binlog_collector.INFO: Existed PartitionCount: 16 [] []
19+
[2017-08-28 10:55:30] binlog_collector.INFO: TotalGtidPartitions's Count: 16 [] []
20+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7113): process started, [0-2-7130/mariadb-bin.000004/4] [] []
21+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7114): process started, [0-1-7346/mariadb-bin.000004/8184313] [] []
22+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7117): process started, [0-1-7964/mariadb-bin.000004/35319670] [] []
23+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7116): process started, [0-1-7761/mariadb-bin.000004/26231209] [] []
24+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7115): process started, [0-1-7554/mariadb-bin.000004/17229505] [] []
25+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7118): process started, [0-1-8071/mariadb-bin.000004/44621874] [] []
26+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7119): process started, [0-1-8177/mariadb-bin.000004/53837143] [] []
27+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7122): process started, [0-1-8498/mariadb-bin.000004/81743761] [] []
28+
[2017-08-28 10:55:30] binlog_collector.INFO: child_index(7120): process started, [0-1-8284/mariadb-bin.000004/63139350] [] []
29+
[2017-08-28 10:55:31] binlog_collector.INFO: child_index(7121): process started, [0-1-8391/mariadb-bin.000004/72441554] [] []
30+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7118): process finished([0-1-8071/mariadb-bin.000004/44621874]~[0-1-8177/mariadb-bin.000004/53837143]), processed(26s, gtidCount(106), eventCount(5300), rowCount(5300) [] []
31+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7117): process finished([0-1-7964/mariadb-bin.000004/35319670]~[0-1-8071/mariadb-bin.000004/44621874]), processed(26s, gtidCount(107), eventCount(5300), rowCount(5300) [] []
32+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7123): process started, [0-1-8605/mariadb-bin.000004/91045965] [] []
33+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7124): process started, [0-1-8711/mariadb-bin.000004/100261234] [] []
34+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7120): process finished([0-1-8284/mariadb-bin.000004/63139350]~[0-1-8391/mariadb-bin.000004/72441554]), processed(26s, gtidCount(107), eventCount(5300), rowCount(5300) [] []
35+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7125): process started, [0-1-8770/mariadb-bin.000005/423] [] []
36+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7122): process finished([0-1-8498/mariadb-bin.000004/81743761]~[0-1-8605/mariadb-bin.000004/91045965]), processed(26s, gtidCount(107), eventCount(5300), rowCount(5300) [] []
37+
[2017-08-28 10:55:56] binlog_collector.INFO: child_index(7121): process finished([0-1-8391/mariadb-bin.000004/72441554]~[0-1-8498/mariadb-bin.000004/81743761]), processed(25s, gtidCount(107), eventCount(5400), rowCount(5400) [] []
38+
[2017-08-28 10:55:57] binlog_collector.INFO: child_index(7126): process started, [0-1-9148/mariadb-bin.000005/16438320] [] []
39+
[2017-08-28 10:55:57] binlog_collector.INFO: child_index(7127): process started, [0-1-9355/mariadb-bin.000005/25440024] [] []
40+
[2017-08-28 10:55:57] binlog_collector.INFO: child_index(7119): process finished([0-1-8177/mariadb-bin.000004/53837143]~[0-1-8284/mariadb-bin.000004/63139350]), processed(27s, gtidCount(107), eventCount(5400), rowCount(5400) [] []
41+
[2017-08-28 10:55:57] binlog_collector.INFO: child_index(7128): process started, [0-1-9542/mariadb-bin.000005/33572001] [] []
42+
[2017-08-28 10:56:00] binlog_collector.INFO: child_index(7128): process finished([0-1-9542/mariadb-bin.000005/33572001]~[0-1-9557/mariadb-bin.000005/34224297]), processed(3s, gtidCount(15), eventCount(350), rowCount(700) [] []
43+
[2017-08-28 10:56:08] binlog_collector.INFO: child_index(7113): process finished([0-2-7130/mariadb-bin.000004/4]~[0-1-7346/mariadb-bin.000004/8184313]), processed(38s, gtidCount(217), eventCount(4750), rowCount(9500) [] []
44+
[2017-08-28 10:56:10] binlog_collector.INFO: child_index(7114): process finished([0-1-7346/mariadb-bin.000004/8184313]~[0-1-7554/mariadb-bin.000004/17229505]), processed(40s, gtidCount(208), eventCount(5200), rowCount(10400) [] []
45+
[2017-08-28 10:56:10] binlog_collector.INFO: child_index(7124): process finished([0-1-8711/mariadb-bin.000004/100261234]~[0-1-8770/mariadb-bin.000005/423]), processed(14s, gtidCount(59), eventCount(2650), rowCount(3000) [] []
46+
[2017-08-28 10:56:10] binlog_collector.INFO: child_index(7116): process finished([0-1-7761/mariadb-bin.000004/26231209]~[0-1-7964/mariadb-bin.000004/35319670]), processed(40s, gtidCount(203), eventCount(5300), rowCount(10200) [] []
47+
[2017-08-28 10:56:11] binlog_collector.INFO: child_index(7115): process finished([0-1-7554/mariadb-bin.000004/17229505]~[0-1-7761/mariadb-bin.000004/26231209]), processed(41s, gtidCount(207), eventCount(5150), rowCount(10300) [] []
48+
[2017-08-28 10:56:15] binlog_collector.INFO: child_index(7123): process finished([0-1-8605/mariadb-bin.000004/91045965]~[0-1-8711/mariadb-bin.000004/100261234]), processed(19s, gtidCount(106), eventCount(5300), rowCount(5300) [] []
49+
[2017-08-28 10:56:19] binlog_collector.INFO: child_index(7127): process finished([0-1-9355/mariadb-bin.000005/25440024]~[0-1-9542/mariadb-bin.000005/33572001]), processed(22s, gtidCount(187), eventCount(4700), rowCount(9400) [] []
50+
[2017-08-28 10:56:20] binlog_collector.INFO: child_index(7126): process finished([0-1-9148/mariadb-bin.000005/16438320]~[0-1-9355/mariadb-bin.000005/25440024]), processed(23s, gtidCount(207), eventCount(5150), rowCount(10300) [] []
51+
[2017-08-28 10:56:28] binlog_collector.INFO: child_index(7125): process finished([0-1-8770/mariadb-bin.000005/423]~[0-1-9148/mariadb-bin.000005/16438320]), processed(32s, gtidCount(378), eventCount(9450), rowCount(18900) [] []
52+
[2017-08-28 10:56:28] binlog_collector.INFO: TotalGtidPartitions's Count: 0 [] []
53+
[2017-08-28 10:56:28] binlog_collector.INFO: TotalGtidPartitions's Count: 0 [] []

demo/Resources/mariadb/change.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
my.cnf 변경 -> my.master.cnf
2+
server-id = 1
3+
log_bin = /var/log/mysql/mariadb-bin
4+
log_bin_index = /var/log/mysql/mariadb-bin.index
5+
binlog-format = row
6+
7+
my.cnf 변경 -> my.slave.cnf
8+
server-id = 2
9+
log_bin = /var/log/mysql/mariadb-bin
10+
log_bin_index = /var/log/mysql/mariadb-bin.index
11+
# slaves
12+
relay_log = /var/log/mysql/relay-bin
13+
relay_log_index = /var/log/mysql/relay-bin.index
14+
relay_log_info_file = /var/log/mysql/relay-bin.info
15+
log_slave_updates
16+
binlog-format = row
17+
18+
my.cnf 변경 -> my.slave-slave.cnf
19+
server-id = 3
20+
log_bin = /var/log/mysql/mariadb-bin
21+
log_bin_index = /var/log/mysql/mariadb-bin.index
22+
# slaves
23+
relay_log = /var/log/mysql/relay-bin
24+
relay_log_index = /var/log/mysql/relay-bin.index
25+
relay_log_info_file = /var/log/mysql/relay-bin.info
26+
log_slave_updates
27+
binlog-format = row
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# MariaDB database server configuration file.
2+
#
3+
# You can copy this file to one of:
4+
# - "/etc/mysql/my.cnf" to set global options,
5+
# - "~/.my.cnf" to set user-specific options.
6+
#
7+
# One can use all long options that the program supports.
8+
# Run program with --help to get a list of available options and with
9+
# --print-defaults to see which it would actually understand and use.
10+
#
11+
# For explanations see
12+
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
13+
14+
# This will be passed to all mysql clients
15+
# It has been reported that passwords should be enclosed with ticks/quotes
16+
# escpecially if they contain "#" chars...
17+
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
18+
[client]
19+
port = 3306
20+
socket = /var/run/mysqld/mysqld.sock
21+
22+
# Here is entries for some specific programs
23+
# The following values assume you have at least 32M ram
24+
25+
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
26+
[mysqld_safe]
27+
socket = /var/run/mysqld/mysqld.sock
28+
nice = 0
29+
30+
[mysqld]
31+
skip-host-cache
32+
skip-name-resolve
33+
#
34+
# * Basic Settings
35+
#
36+
#user = mysql
37+
pid-file = /var/run/mysqld/mysqld.pid
38+
socket = /var/run/mysqld/mysqld.sock
39+
port = 3306
40+
basedir = /usr
41+
datadir = /var/lib/mysql
42+
tmpdir = /tmp
43+
lc_messages_dir = /usr/share/mysql
44+
lc_messages = en_US
45+
skip-external-locking
46+
#
47+
# Instead of skip-networking the default is now to listen only on
48+
# localhost which is more compatible and is not less secure.
49+
#bind-address = 127.0.0.1
50+
#
51+
# * Fine Tuning
52+
#
53+
max_connections = 100
54+
connect_timeout = 5
55+
wait_timeout = 600
56+
max_allowed_packet = 16M
57+
thread_cache_size = 128
58+
sort_buffer_size = 4M
59+
bulk_insert_buffer_size = 16M
60+
tmp_table_size = 32M
61+
max_heap_table_size = 32M
62+
#
63+
# * MyISAM
64+
#
65+
# This replaces the startup script and checks MyISAM tables if needed
66+
# the first time they are touched. On error, make copy and try a repair.
67+
myisam_recover = BACKUP
68+
key_buffer_size = 128M
69+
#open-files-limit = 2000
70+
table_open_cache = 400
71+
myisam_sort_buffer_size = 512M
72+
concurrent_insert = 2
73+
read_buffer_size = 2M
74+
read_rnd_buffer_size = 1M
75+
#
76+
# * Query Cache Configuration
77+
#
78+
# Cache only tiny result sets, so we can fit more in the query cache.
79+
query_cache_limit = 128K
80+
query_cache_size = 64M
81+
# for more write intensive setups, set to DEMAND or OFF
82+
#query_cache_type = DEMAND
83+
#
84+
# * Logging and Replication
85+
#
86+
# Both location gets rotated by the cronjob.
87+
# Be aware that this log type is a performance killer.
88+
# As of 5.1 you can enable the log at runtime!
89+
#general_log_file = /var/log/mysql/mysql.log
90+
#general_log = 1
91+
#
92+
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
93+
#
94+
# we do want to know about network errors and such
95+
#log_warnings = 2
96+
#
97+
# Enable the slow query log to see queries with especially long duration
98+
#slow_query_log[={0|1}]
99+
slow_query_log_file = /var/log/mysql/mariadb-slow.log
100+
long_query_time = 10
101+
#log_slow_rate_limit = 1000
102+
#log_slow_verbosity = query_plan
103+
104+
#log-queries-not-using-indexes
105+
#log_slow_admin_statements
106+
#
107+
# The following can be used as easy to replay backup logs or for replication.
108+
# note: if you are setting up a replication slave, see README.Debian about
109+
# other settings you may need to change.
110+
#server-id = 1
111+
#report_host = master1
112+
#auto_increment_increment = 2
113+
#auto_increment_offset = 1
114+
#log_bin = /var/log/mysql/mariadb-bin
115+
#log_bin_index = /var/log/mysql/mariadb-bin.index
116+
# not fab for performance, but safer
117+
#sync_binlog = 1
118+
expire_logs_days = 10
119+
max_binlog_size = 100M
120+
# slaves
121+
#relay_log = /var/log/mysql/relay-bin
122+
#relay_log_index = /var/log/mysql/relay-bin.index
123+
#relay_log_info_file = /var/log/mysql/relay-bin.info
124+
#log_slave_updates
125+
#read_only
126+
#
127+
# If applications support it, this stricter sql_mode prevents some
128+
# mistakes like inserting invalid dates etc.
129+
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
130+
#
131+
# * InnoDB
132+
#
133+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
134+
# Read the manual for more InnoDB related options. There are many!
135+
default_storage_engine = InnoDB
136+
# you can't just change log file size, requires special procedure
137+
#innodb_log_file_size = 50M
138+
innodb_buffer_pool_size = 256M
139+
innodb_log_buffer_size = 8M
140+
innodb_file_per_table = 1
141+
innodb_open_files = 400
142+
innodb_io_capacity = 400
143+
innodb_flush_method = O_DIRECT
144+
#
145+
# * Security Features
146+
#
147+
# Read the manual, too, if you want chroot!
148+
# chroot = /var/lib/mysql/
149+
#
150+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
151+
#
152+
# ssl-ca=/etc/mysql/cacert.pem
153+
# ssl-cert=/etc/mysql/server-cert.pem
154+
# ssl-key=/etc/mysql/server-key.pem
155+
156+
157+
158+
[mysqldump]
159+
quick
160+
quote-names
161+
max_allowed_packet = 16M
162+
163+
[mysql]
164+
#no-auto-rehash # faster start of mysql but no tab completition
165+
166+
[isamchk]
167+
key_buffer = 16M
168+
169+
#
170+
# * IMPORTANT: Additional settings that can override those from this file!
171+
# The files must end with '.cnf', otherwise they'll be ignored.
172+
#
173+
!includedir /etc/mysql/conf.d/

0 commit comments

Comments
 (0)