![]() In MongoDB 2.6 there's now another startup file, /etc/mongorc.js, which is a global shell startup file that is run before the user's own. You can, for example, load it with time-saving functions and pre-initialised variables. This file, which lives in a user's home directory, is automatically executed when the mongo shell is run, making it a great place to customise your Mongo shell experience. mongo -host -port -u -p -authenticationDatabase adminMongoDB 2.6 Shell & Tools: Things Worth Knowing tips tools mongodb 2.6 Free 30 Day TrialĮarlier this year, as part of a series on the Mongo Shell, we introduced readers to the. mongo " mongodb://test1: .xx:8635.xx:8635 /Database?authSource=Database&replicaSet=repli ca " mongo " mongodb://rwuser: .xx:8635.xx:8635 /test?authSource=admin&replicaSet=repli ca " On the Private Connection tab, obtain the IP address of the corresponding node. On the Instances page, click the instance to go to the Basic Information page. Secondary node: You can only read data from it. Primary node: You can read and write data on it. DB_HOST is the private IP address of the primary or standby node of the instance to be connected.mongo -host -port -u -p -authenticationDatabase admin -ssl -sslCAFile -sslAllowInvalidHostnames This method affects the read/write performance when a primary/standby switchover occurs. You can also use the private IP address of a primary or secondary node to access the replica set instance. mongo " mongodb://test1: .xx:8635.xx:8635 /Database? authSource=Database&replicaSet=replica " -ssl -sslCAFile /tmp/ca.crt -sslAllowInvalidHostnames In addition, replace rwuser with the username created in the user-defined database.įor example, if you create a user-defined database Database and user test1 in the database, the connection command is as follows: If you use a user-defined database for authentication, change the authentication database in the HA connection address to the name of the user-defined database. mongo " mongodb://rwuser: .xx:8635.xx:8635 /test? authSource=admin&replicaSet=replica " -ssl -sslCAFile /tmp/ca.crt -sslAllowInvalidHostnames sslAllowInvalidHostnames is needed for the SSL connection through a private network. -sslAllowInvalidHostnames: The replica set certificate is generated using the internal management IP address to ensure that internal communication does not occupy resources such as the user IP address and bandwidth.FILE_PATH is the path for storing the root certificate.The default replica set of Huawei Cloud DDS is replica. replica in replicaSet=replica is the name of a replica set.authSource=admin is fixed in the command. The authentication database of user rwuser must be admin.You can set this parameter based on your service requirements. ![]() IP address and port of the node of the replica set instance If the password contains at signs exclamation marks (!), or percent signs (%), replace them with hexadecimal URL codes (ASCII) %40, %21, and %25 respectively.įor example, if the password is %***!, the corresponding URL code is **** %40%25*** %21. Click the Private Connection tab and obtain the connection address of the current instance from the Private HA Connection Address field.Īccount name, that is, the database username. Private HA Connection Address: On the Instances page, click the instance name.mongo " " - ssl -sslCAFile -sslAllowInvalidHostnames Using this address to connect to a replica set instance improves data read/write performance and prevents errors reported when data is written from the client after a primary/standby switchover. Method 1: High-availability connection (recommended)ĭDS provides the HA connection address. In Windows, upload the root certificate using a remote connection tool.REMOTE_DIR is the directory of the ECS to which the root certificate is uploaded.IDENTITY_FILE is the directory where the root certificate resides.
0 Comments
Leave a Reply. |