You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+78-7Lines changed: 78 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,19 +16,90 @@ Credit goes to the folks at LinkedIn for pioneering this approach - read Jay Kre
16
16
### todo
17
17
- listeners for PostgreSQL, MongoDB, (others)
18
18
- stronger schema-ing of data
19
+
- process for capturing an initial state of the data
19
20
21
+
### setup for mysql
20
22
21
-
### usage
23
+
How to use plainview to listen to your MySQL replication stream and write raw change data to Amazon S3.
24
+
25
+
##### 1. Setup your MySQL Server
26
+
Your server needs to be configured as a replication master using the "row" binary log format. Set
27
+
the following in your server's my.cnf file:
28
+
29
+
```
30
+
log-bin=mysql-bin
31
+
binlog_format=row
32
+
server-id=1234
33
+
```
34
+
35
+
Where `log-bin` specifies the name to use to store binary log files, and `server-id` is a unique number to identify this server in the replication system. Restart your mysql server to put the changes into effect.
36
+
37
+
Finally, create a MySQL replication user:
38
+
39
+
```sql
40
+
mysql>GRANT REPLICATION SLAVE ON*.* TO '<repl-user>'@'192.168.%' IDENTIFIED BY '<repl-pass>';
41
+
```
42
+
43
+
Modify with an appropriate username and password, and replace `192.168.%` with the network address or subnet that you'll be connecting from. Finally, grab the current position of the replication log:
-`<server-id>` is the unique ID from your master MySQL server's my.cnf file
77
+
-`<mysql-file>` is the "File" that your master MySQL server reported in Step 1. (in this case, `mysql-bin.000019`)
78
+
-`<mysql-position>` is the "Position" that your master MySQL server reported in Step 1. (in this case, `480798760`)
79
+
-`<mysql-port>` is the port of your master MySQL server
80
+
-`<repl-user>` and `<repl-pass>` are the credentials you GRANTed permission to in Step 1.
81
+
-`<kinesis-stream>` is the name of the Kinesis stream from Step 2.
82
+
83
+
The producer will run continuously, listening for updates coming through replication.
84
+
85
+
##### 4. Run the plainview consumer
86
+
87
+
plainview's consumer listens to a Kinesis stream for data from the producer and writes it to Amazon S3.
88
+
89
+
Again run the following to give the code access to Amazon resources:
90
+
91
+
```
92
+
export AWS_ACCESS_KEY=<your-key>
93
+
export AWS_SECRET_KEY=<your-secret>
94
+
```
95
+
96
+
This key will need read permission on Kinesis, full permission on DynamoDB, and permission to write to an S3 bucket. From the same shell, run the consumer:
97
+
98
+
```bash
99
+
lein run -m plainview.consumer -a <kinesis-app> -b <s3-bucket> -s <kinesis-stream>
100
+
```
101
+
102
+
Where
103
+
-`<kinesis-app>` is a unique name for this consumer. Kinesis uses this name to maintain the consumer's state.
104
+
-`<s3-bucket>` is the S3 bucket to write to
105
+
-`<kinesis-stream>` is the name fo the Kinesis stream from Step 2.
0 commit comments