0.0.21 • Published 1 year ago
tayeh-env v0.0.21
Tayeh Es
Tayeh Project Event sourcing module
Setup
1- First install mariadb on master, open my.cnf and add following
[mariadb]
log-bin
server_id=1
log-basename=master1
binlog-format=mixed
skip_networking=0
bind_address=
2- Then create replication user
CREATE USER 'replication_user'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replication_user'@'%';
3- Next We Should start slave servers, add server ids
[mariadb]
server_id=2
4- Backup Master
mysqldump -u user events -p > backup.sql
5- Import backup in slaves
mysql -u user events -p < backup.sql
6- Set master domain in slaves (only networked are allowed), add line below in hosts
xx.xx.xx.xx db.master
7- Start Slaves
CHANGE MASTER TO
MASTER_USE_GTID = slave_pos
MASTER_HOST='master.domain.com',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_PORT=3306,
MASTER_CONNECT_RETRY=10;
STOP SLAVE SQL_THREAD;
SET GLOBAL slave_parallel_threads = 4;
START SLAVE SQL_THREAD;
SELECT @@slave_parallel_threads;
START SLAVE;
SHOW SLAVE STATUS;
Usage
Import module in project
TayehEsModule.forRoot({
username: 'user';
password: 'pass';
host: 'localhost';
connectionLimit: 2;
})
Use it like this
es.write(
ESEventType.User, // event type
1, // entity id
{example: true}, // data
creator: 1, // creator id
1 // cause id
)
// Or multiple writes with batchWrite
0.0.21
1 year ago