mongodb qiot

In this tutorial, you will learn how to establish a MongoDB to connect with QNAP NAS via QIoT Suite Lite.



Step_1: Open Container Station and Set Up MongoDB



  • Click "Container Station".


1

  • Click "Create Container".


2

  • Go to MongoDB and click "Install" (Click "MongoDB" for more information).


3

  • Click "Create"

  • This will install an empty container. You will need to install, remove, and then install a new MongoDB.


4

  • Choose the container and remove it.


55-2

  • Choose "Create Container", and click "Install" to rebuild the MongoDB.


3

  • In Command, enter "mongod --auth".


6

  • Click "Advanced Settings".


6-2

  • Go to "Network", enter a value for the MongoDB "port" number (for example: 37011).


6-3

  • Go to "Shared Folder", and click "Add".


6-4

  • In "Volume from host" choose the folder you established earlier (for example: Container > Mongo DB > db).


6-5

  • In "Mount Point" enter "/data/db".


6-6

  • In "Volume from host" choose the folder you established earlier (for example: Container > Mongo DB > configdb).

  • In "Mount Point" enter "/data/configdb".


The purpose of adding these commands are for easy backup and modification

  • Click "Create"


6-7

Step_2: Set up MongoDB account and permissions



  • You may refer MongoDB DockerHub instructions for more information on setting access controls.


6-9

  • Establish an account: In your MongoDB container, click "Terminal", enter "mongo admin", and click "OK".


7

  • Enter the command "createUser({ user: 'input account', pwd: 'input password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); ".


8

  • Return to the MongoDB container, click "Terminal" and enter the command "mongo -u input account -p input password --authenticationDatabase admin".

  • Click "OK".


9

  • Enter the command "use database name" (for example: "use qiotdatabase").

  • Enter the command "createUser({ user: "input account of DB ", pwd: "input password of DB", roles: [ { role: "dbOwner", db: "input the DB name you established previously"}]});"


(When you "establish another new account and password", it cannot be the same as the previously created user account (for example: "qiotduser")).

10

Step_3: Connect MongoDB to QIoT Suite Lite



  • Open your IoT Application and click "Rule".

  • In "storage", choose "mongodb" and pull it into Flow 1, and double click it.


11

  • In Server, click the right button to add a new mongodb.


11-2

  • Enter the below information:

    1. Host: 10.0.7.1 (Must be this IP)

    2. Port: The port number you set up earlier (for example: "37011").

    3. Database: The database name you set up earlier (for example: "qiotdatabase").

    4. Username: The username you set up earlier (for example: "qiotuser").

    5. Password: The password you set up earlier (for example: "qiotuser").

    6. Name: Enter a name (for example: "qiotdb").



  • Click "Add".


12

  • Enter a name in "Collection" (for example: temp).

  • In "Operation", choose the operation you want. (More information, read the MongoDB website).

  • Name: Enter a name.

  • Click "Done".


13

  • In "storage", choose "mongodb". In "function", choose "function". Then pull them into Flow 1.


13-2

  • Double click "function", and enter the code you want to set up. (Refer to the "info" section on the right side for more information)

  • Click "Done".


14.1

  • Double click "mongodb", choose the server name you previously set up and enter the collection name you want (for example: temp).

  • Name: Enter a name.

  • Click "Done".


14-2

  • After these settings, you can connect the function node and mongodb node together like below and click "Save".

  • On the right side, you will see the value.


15.2

 
arrow
arrow
    全站熱搜

    tttt 發表在 痞客邦 留言(0) 人氣()