2022/5/11

mongodb install

安裝依照官網: 一般的動作:
  1. 加 pgp key
  2. 加sources.list
  3. apt update
  4. apt install
裝完 default config 會在: /etc/mongod.conf
config 裡面的 ..
  • storage: /var/lib/mongodb
  • log: /var/log/mongod/mongod.log
  • net: 127.0.0.1:27017
apt 會安裝到 systemd : mongod.service


結果 在 pi3 上,用 debian 64bit 的 apt 安裝,service run fail。

單純 run docker mongo:
$ docker run -it -p 27017:27017 -v ~/mongoinstall_arm64:/mongoinstall mongo

WARNING: MongoDB 5.0+ requires ARMv8.2-A or higher, and your current system does not appear to implement any of the common features for that!
  see https://jira.mongodb.org/browse/SERVER-55178
  see also https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features
  see also https://github.com/docker-library/mongo/issues/485#issuecomment-970864306

需要參考mongodb under raspbian64,用另一版的 mnogodb
依照這個網頁說明,放到 mongoinstall_arm64

需要 curl, libssl-dev

所以也 用 4.4.14 看看
$ docker run -it -p 27017:27017 -v ~/mongoinstall_arm64:/mongoinstall mongo:4.4.14
Unable to find image 'mongo:4.4.14' locally
4.4.14: Pulling from library/mongo
d4ba87bb7858: Already exists 
2905e503bba5: Already exists 
7f2fbfedcbbd: Already exists 
fed819c90351: Already exists 
8c9476a7638d: Already exists 
443796fcd1a6: Pull complete 
cf4ff181511c: Pull complete 
0d3b82484af2: Pull complete 
546d4133b910: Pull complete 
7ccc69fa7857: Pull complete 
Digest: sha256:a7c77e3310e2c21cb043d2db4c46968a05d43c77644207d7d8b072d6049bb119
Status: Downloaded newer image for mongo:4.4.14

WARNING: MongoDB 5.0+ requires ARMv8.2-A or higher, and your current system does not appear to implement any of the common features for that!
  see https://jira.mongodb.org/browse/SERVER-55178
  see also https://en.wikichip.org/wiki/arm/armv8#ARMv8_Extensions_and_Processor_Features
  see also https://github.com/docker-library/mongo/issues/485#issuecomment-970864306

{"t":{"$date":"2022-05-16T07:55:40.604+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   
"ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-05-16T07:55:40.613+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   
"ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-05-16T07:55:40.615+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, 
"ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2022-05-16T07:55:40.618+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, 
"ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"b2c120e0f9a6"}}
{"t":{"$date":"2022-05-16T07:55:40.624+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   
"ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":}
..
可以 run 起來。
所以用 docker host 端的 mongo client 來測試...

安裝完,除了用 systemctl status 看service 狀態,也可以用 mongodb client console 來測試。
ref: 新的 client 是 monogosh。
連線語法是:
mongosh mongodb://root:rootpasss@mogoserver:27017

有關 docker
docker imnage : mongo 的版本是 5.0.3 ,和一般(ubuntu 20.04) distribution 的版本 3.0 不一樣。
舊版本的 client 無法和版本連線。
所以也要用 docker 來連..
docker run -it mongo --interface mogocontainer-network mongosh mongodb://root:rootpassword@mogocontainername:27017
要跟 mogocontainer 同一個 network,才能直接用 container name 來連接。

沒有留言:

張貼留言