-
Notifications
You must be signed in to change notification settings - Fork 3
2. Configuration
telan edited this page Nov 5, 2019
·
5 revisions
If you want to change the default configurations, please run the following command to generate configuration files binlog.php
in directory /config
:
$ php artisan vendor:publish --provider="Telanflow\Binlog\LaravelServiceProvider"
For Lumen users, you need to copy those files to
config
folder and register them inbootstrap/app.php
manually.
Key | Description |
---|---|
connection.host |
Mysql connect host address |
connection.port |
Mysql connect port |
connection.username |
Mysql connect username |
connection.password |
Mysql connect password |
connection.slave_id |
Mysql binlog slave_id |
connection.heartbeat |
Mysql replication protocol heartbeat |
options.process_name |
Server process name |
options.pid_file |
Server process pid file |
options.log_file |
Server process log file |
options.pos_file |
Mysql binlog position cache file |
options.daemon |
The server process executes in the background |
column_mode |
Data field return format. (easy Or info) |
listen |
Specifies to listen to databases, tables. (If not specified, listen to all databases, tables) |
listen_event |
Specify listening binlog record events |
Here are some examples:
[
/*
|--------------------------------------------------------------------------
| Connection config
|--------------------------------------------------------------------------
*/
'connection' => [
'host' => env('BINLOG_HOST', '127.0.0.1'),
'port' => env('BINLOG_PORT', '3306'),
'username' => env('BINLOG_USERNAME', 'forge'),
'password' => env('BINLOG_PASSWORD', ''),
'charset' => env('BINLOG_CHARSET', 'utf8'),
// Binlog slave_id
'slave_id' => env('BINLOG_SLAVE_ID', '1'),
// Binlog heartbeat
'heartbeat' => env('BINLOG_HEARTBEAT', 5),
],
/*
|--------------------------------------------------------------------------
| Options
|--------------------------------------------------------------------------
*/
'options' => [
// Process
'process_name' => env('BINLOG_PROCESS_NAME', 'binlog'),
'pid_file' => env('BINLOG_PID_FILE', base_path('storage/logs/binlog.pid')),
'log_file' => env('BINLOG_LOG_FILE', base_path('storage/logs/binlog.log')),
// Cache the binlog read location and the binlog file name.
// Continue reading from current position after reboot
'pos_file' => env('BINLOG_POS_FILE', base_path('storage/logs/binlog.pos')),
// Daemon process
'daemon' => env('BINLOG_DAEMON', false),
],
/*
|--------------------------------------------------------------------------
| Column Mode (default: easy)
|
| easy: ['id' => 12013]
| info: ['name'=>'id', 'value'=>12013, 'type'=>'INT32', 'length'=>5, 'is_primary'=>true, 'encoding'=>'utf8mb4', 'is_unsigned'=>true]
|--------------------------------------------------------------------------
*/
'column_mode' => \Telanflow\Binlog\Configure\Configure::COLUMN_MODE_EASY,
/*
|--------------------------------------------------------------------------
| Specifies to listen to databases, tables
|
| (If not specified, listen to all databases, tables)
|--------------------------------------------------------------------------
*/
'listen' => [
// Specifies the listening table
// 'database' => [
// 'table',
// 'table',
// ],
// Specify listening database
// 'database'
],
/*
|--------------------------------------------------------------------------
| Specify listening binlog record events
|--------------------------------------------------------------------------
*/
'listen_event' => [
RecordTypeConst::INSERT,
RecordTypeConst::UPDATE,
RecordTypeConst::DELETE,
RecordTypeConst::BEGIN,
RecordTypeConst::ROLLBACK,
// RecordTypeConst::FORMAT_DESCRIPTION,
// RecordTypeConst::TABLE_MAP,
// RecordTypeConst::HEARTBEAT,
// RecordTypeConst::GTID,
// RecordTypeConst::QUERY,
],
]