In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Preface
With docker, basically bid farewell to all kinds of software, database installation, directly from the mirror library pull down, cool, think about the past that is really a suffering ah.
This article will take a look at how to run the docker image of mongo, and can be accessed in the local area network, the content is relatively simple, but also record my self-study process.
The first step
Get the mongo image with the following command
# pull mongo image docker pull mongo# to view local library mongo image docker images mongo
Step two
Start the mongo image as follows
# start mongo image docker run-itd-P-- name mongo-server mongo bash# to view mongo process docker ps-a
Step three
Enter the container and start mongo, as follows
# enter the mongo container, where 'mongo-server' is the mongo container alias docker exec-it mongo-server bash# to start the mongo service mongod & # View the mongo process ps-ef in the container | grep mongo
After startup, you will see the following log (the last few lines)
2017-06-13T07:25:56.318+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory'/ data/db/diagnostic.data'2017-06-13T07:25:56.328+0000 I INDEX [initandlisten] build index on: admin.system.version properties: {v: 2, key: {version: 1}, name: "incompatible_with_version_32", ns: "admin.system.version"} 2017-06-13T07:25:56.328+0000 I INDEX [initandlisten] building index using bulk method Build may temporarily use up to 500megabytes of RAM2017-06-13T07:25:56.329+0000 I INDEX [initandlisten] build index done. Scanned 0 total records. 0 secs2017-06-13T07:25:56.329+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.42017-06-13T07:25:56.329+0000 I NETWORK [thread1] waiting for connections on port 27017
The fourth step
Local validation test, enter mongo to start the mongo command line client, as follows
Root@01ff7ed6377c:/# mongoMongoDB shell version v3.4.4connecting to: mongodb://127.0.0.1:270172017-06-13T07:34:00.289+0000 I NETWORK [thread1] connection accepted from 127.0.0.1 conn2 55650 # 2 (1 connection now open) 2017-06-13T07:34:00.290+0000 I NETWORK [conn2] received client metadata from 127.0.0.1 conn2: {application: {name: "MongoDB Shell"}, driver: {name: "MongoDB Internal Client" Version: "3.4.4"}, os: {type: "Linux", name: "PRETTY_NAME=" Debian GNU/Linux 8 (jessie) "", architecture: "x86: 64", version: "Kernel 3.10.0-327.28.3.el7.x86_64"}}
Then enter the test command
> show dbs;admin 0.000GBlocal 0.000GB >
Step five
When accessing mongo in docker in the local area network, since random port mapping is used when starting, it means that the host generates a random port to map port 27017 of mongo. Check the random port of the host through the 'docker ps-a' command, as shown below
Docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES01ff7ed6377c mongo "docker-entrypoint.sh" 15 minutes ago Up 15 minutes 0.0.0.0 docker-entrypoint.sh 32773-> 27017/tcp mongo-server
As above, the random port of the host is 32773, and the mongo is connected by configuring the robomongo client, as follows
The results are normal.
To stop mongo, you can use the following command
# Log in to mongomongo# and choose to use admin library. Do not use use admin# to close mongodb.shutdownServer () in other libraries.
Use'ps-ef | grep momgo' to check whether the mongo process exists. If it does not exist, the shutdown is successful.
Summary
The above is the whole content of this article, I hope the content of this article can bring some help to all iOS developers, if you have any questions, you can leave a message, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.