Skip to content

Commit

Permalink
Add postgresql as meta db (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsy3993 authored May 15, 2024
1 parent 7903a16 commit 9dfd678
Show file tree
Hide file tree
Showing 5 changed files with 412 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/ccr_syncer/ccr_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ func main() {
db, err = storage.NewSQLiteDB(dbPath)
case "mysql":
db, err = storage.NewMysqlDB(syncer.Db_host, syncer.Db_port, syncer.Db_user, syncer.Db_password)
case "postgresql":
db, err = storage.NewPostgresqlDB(syncer.Db_host, syncer.Db_port, syncer.Db_user, syncer.Db_password)
default:
err = xerror.Wrap(err, xerror.Normal, "new meta db failed.")
}
Expand Down
6 changes: 3 additions & 3 deletions doc/start_syncer.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ bash bin/start_syncer.sh --daemon
```

### --db_type
Syncer目前能够使用两种数据库来保存自身的元数据,分别为`sqlite3`(对应本地存储)和`mysql`(本地或远端存储)
Syncer目前能够使用两种数据库来保存自身的元数据,分别为`sqlite3`(对应本地存储)和`mysql` 或者`postgresql`(本地或远端存储)
```bash
bash bin/start_syncer.sh --db_type mysql
```
默认值为sqlite3
在使用mysql存储元数据时,Syncer会使用`CREATE IF NOT EXISTS`来创建一个名为`ccr`的库,ccr相关的元数据表都会保存在其中
在使用mysql或者postgresql存储元数据时,Syncer会使用`CREATE IF NOT EXISTS`来创建一个名为`ccr`的库,ccr相关的元数据表都会保存在其中

### --db_dir
**这个选项仅在db使用`sqlite3`时生效**
Expand All @@ -38,7 +38,7 @@ bash bin/start_syncer.sh --db_dir /path/to/ccr.db
```
默认路径为`SYNCER_OUTPUT_DIR/db`,文件名为`ccr.db`
### --db_host & db_port & db_user & db_password
**这个选项仅在db使用`mysql`时生效**
**这个选项仅在db使用`mysql`或者`postgresql`时生效**
```bash
bash bin/start_syncer.sh --db_host 127.0.0.1 --db_port 3306 --db_user root --db_password "qwe123456"
```
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ require (
github.com/jhump/protoreflect v1.15.6 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
Expand Down
Loading

0 comments on commit 9dfd678

Please sign in to comment.