§ 2023-07-23
- x86_64, aarch64
- OK,
$ ls bin bsondump mongodump mongoexport mongofiles mongoimport mongorestore mongostat mongotop
§2023-07-23
- OrnagePi5+, Mem 16G PCIeSSD 256G
$ git clone https://github.com/mongodb/mongo-tools && cd mongo-tools
$ git checkout 100.7.5 -b test
Switched to a new branch 'test'
$ go version
go version go1.20.5 linux/arm64
$ which go
/usr/bin/go
$ time ./make build
..
START | build
panic: ubuntu1804 platform name changed <-- if you use go1.19.*
if you use go1.15.*
note: module requires Go 1.19
§2023-07-23
- odroid-hc4, Jammy
- failed to build mongo-tools
- install go1.15.*
$ wget https://go.dev/dl/go1.15.15.linux-arm64.tar.gz
$ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzvf go1.15.15.linux-arm64.tar.gz
$ go version
go version go1.15.15 linux/arm64
$ wget https://go.dev/dl/go1.19.11.linux-arm64.tar.gz
$ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzvf go1.19.11.linux-arm64.tar.gz
$ export PATH=/usr/local/go/bin:$PATH
$ which go
/usr/local/go/bin//go
alexlai@hc4Jammy:~/build/src$
$ go version
go version go1.19.11 linux/arm64
- git clone
$ git clone https://github.com/mongodb/mongo-tools && cd mongo-tools
$ ls -l
total 448
-rw-rw-r-- 1 alexlai alexlai 3151 Jul 23 07:58 binaryurl.py
drwxrwxr-x 4 alexlai alexlai 95 Jul 23 07:58 bsondump
-rw-rw-r-- 1 alexlai alexlai 1345 Jul 23 07:58 build.go
drwxrwxr-x 2 alexlai alexlai 35 Jul 23 07:58 buildscript
-rw-rw-r-- 1 alexlai alexlai 67534 Jul 23 07:58 CHANGELOG.md
drwxrwxr-x 22 alexlai alexlai 4096 Jul 23 07:58 common
-rw-rw-r-- 1 alexlai alexlai 11463 Jul 23 07:58 common-pvt.yml
-rw-rw-r-- 1 alexlai alexlai 100657 Jul 23 07:58 common.yml
-rw-rw-r-- 1 alexlai alexlai 7430 Jul 23 07:58 CONTRIBUTING.md
drwxrwxr-x 2 alexlai alexlai 56 Jul 23 07:58 etc
drwxrwxr-x 3 alexlai alexlai 43 Jul 23 07:58 evergreen
-rw-rw-r-- 1 alexlai alexlai 1912 Jul 23 07:58 go.mod
-rw-rw-r-- 1 alexlai alexlai 14182 Jul 23 07:58 go.sum
drwxrwxr-x 5 alexlai alexlai 39 Jul 23 07:58 installer
-rw-rw-r-- 1 alexlai alexlai 554 Jul 23 07:58 LICENSE.md
-rw-rw-r-- 1 alexlai alexlai 468 Jul 23 07:58 linter.go
-rwxrwxr-x 1 alexlai alexlai 28 Jul 23 07:58 make
drwxrwxr-x 4 alexlai alexlai 4096 Jul 23 07:58 mongodump
drwxrwxr-x 3 alexlai alexlai 176 Jul 23 07:58 mongoexport
drwxrwxr-x 4 alexlai alexlai 140 Jul 23 07:58 mongofiles
drwxrwxr-x 6 alexlai alexlai 4096 Jul 23 07:58 mongoimport
drwxrwxr-x 5 alexlai alexlai 4096 Jul 23 07:58 mongorestore
drwxrwxr-x 6 alexlai alexlai 156 Jul 23 07:58 mongostat
drwxrwxr-x 3 alexlai alexlai 112 Jul 23 07:58 mongotop
-rw-rw-r-- 1 alexlai alexlai 2162 Jul 23 07:58 PLATFORMSUPPORT.md
-rw-rw-r-- 1 alexlai alexlai 3118 Jul 23 07:58 README.md
drwxrwxr-x 8 alexlai alexlai 110 Jul 23 07:58 release
-rw-rw-r-- 1 alexlai alexlai 9032 Jul 23 07:58 RELEASE.md
drwxrwxr-x 2 alexlai alexlai 150 Jul 23 07:58 scripts
-rw-rw-r-- 1 alexlai alexlai 2764 Jul 23 07:58 SERVERVENDORING.md
-rwxrwxr-x 1 alexlai alexlai 2431 Jul 23 07:58 set_goenv.sh
drwxrwxr-x 4 alexlai alexlai 38 Jul 23 07:58 test
-rw-rw-r-- 1 alexlai alexlai 177658 Jul 23 07:58 THIRD-PARTY-NOTICES
drwxrwxr-x 6 alexlai alexlai 99 Jul 23 07:58 vendor
$ XXX git checkout r4.3.2 -b test XXX does not work
- build it
$ time ./make build
$ time ./make build
START | build
panic: ubuntu1804 platform name changed
goroutine 1 [running]:
github.com/mongodb/mongo-tools/release/platform.DetectLocal()
/home/alexlai/build/mongo-tools/release/platform/platform.go:127 +0x48c
github.com/mongodb/mongo-tools/buildscript.getPlatform()
/home/alexlai/build/mongo-tools/buildscript/build.go:238 +0x110
github.com/mongodb/mongo-tools/buildscript.buildToolBinary(0x400017ee80, {0x2da0af, 0x8}, {0x2d89d5, 0x3})
/home/alexlai/build/mongo-tools/buildscript/build.go:71 +0x58
github.com/mongodb/mongo-tools/buildscript.BuildTools(0x50cf58?)
/home/alexlai/build/mongo-tools/buildscript/build.go:34 +0xe0
github.com/craiggwilson/goke/task.Run(0x40000021a0?, {0x400012c010?, 0x4000036768?, 0x45bf8?})
/home/alexlai/build/mongo-tools/vendor/github.com/craiggwilson/goke/task/run.go:68 +0x4d8
main.main()
/home/alexlai/build/mongo-tools/build.go:31 +0x74
exit status 2
real 0m34.405s
user 1m8.206s
sys 0m4.178s
-
MongoDB Tools
- bsondump - display BSON files in a human-readable format
- mongoimport - Convert data from JSON, TSV or CSV and insert them into a collection
- mongoexport - Write an existing collection to CSV or JSON format
- mongodump/mongorestore - Dump MongoDB backups to disk in .BSON format, or restore them to a live database
- mongostat - Monitor live MongoDB servers, replica sets, or sharded clusters
- mongofiles - Read, write, delete, or update files in GridFS
- mongotop - Monitor read/write activity on a mongo server
¶Building Tools
We currently build the tools with Go version 1.15
. Other Go versions may work but they are untested.
Using go get to directly build the tools will not work. To build them, it's recommended to first clone this repository:
git clone https://github.com/mongodb/mongo-tools
cd mongo-tools
Then run ./make build
to build all the tools, placing them in the bin directory inside the repository.
You can also build a subset of the tools using the -pkgs option. For example, ./make build -pkgs=mongodump,mongorestore
builds only mongodump and mongorestore.
To use the build/test scripts in this repository, you must set GOROOT to your Go root directory. This may depend on how you installed Go.
export GOROOT=/usr/local/go
¶Updating Dependencies
Starting with version 100.3.1, the tools use go mod to manage dependencies. All dependencies are listed in the go.mod file and are directly vendored in the vendor directory.
In order to make changes to dependencies, you first need to change the go.mod file. You can manually edit that file to add/update/remove entries, or you can run the following in the repository directory:
go mod edit -require=<package>@<version> # for adding or updating a dependency
go mod edit -droprequire=<package> # for removing a dependency
Then run go mod vendor -v
to reconstruct the vendor directory to match the changed go.mod file.
Optionally, run go mod tidy -v
to ensure that the go.mod file matches the mongo-tools source code.