reasons can be solved. It's pretty specific.http://lingqi1818.iteye.com/blog/1317433But assuming that these things are not linked, it means that some ports on the server are not open and cannot be connected.Workaround to first configure the IP table to open some ports, and then restart server.Root enters serverVi/etc/sysconfig/iptablesJoin-A input-m state--state new-m tcp-p TCP--dport 10002-j ACCEPT (the port opened here is 10002)Save exitService Iptables RestartTry the code again, get it done!
Github: https://github.com/ZhangzheBJUT/blog/blob/master/mgo.mdMongoDB has not yet released the official support for golang driver, it is recommended to use the detailed documentation of mgo. mgo: http://godoc.org/labix.org/v2/mgoThe following is a self-developed instance used to connect to the MongoDB Database Using mgo.
Package mainimport ("fmt" "labix.org/v2/mgo" "labix.org/v2/mgo/bson") type Person stru
From Pymongo import mongoclientFrom Bson.objectid import ObjectidImport JSONdef read (data, find):# set to read the file in Utf-8 decoding mode, encoding parameter must be set, otherwise the default in GBK mode to read the file, when the file contains Chinese, will errorf = open (data, encoding= ' Utf-8 ')setting = Json.load (f)# Note The read syntax for multiple structures# family = setting[' basesettings ' [' Font ']style = Setting[find]# Print (family)return styleDef mongoclient ():Client = m
": 2,
" name ":" 192.168.33.112:27017 ",
" Health ": 1,
" state ": 2,
" STATESTR ":" Secondary ",
" uptime ": 129,
" Optime ": Timestamp (1440445283, 1),
"Optimedate": Isodate ("2015-08-24t19:41:23z"),
"ConfigVersion": 1,
"self": True
}
],
"OK": 1
}Here we can see the RS cluster details, you can see 119 that machine was selected as primary node, 112 was selected as secondary node, and later if you want to add a machine to do scale-out, only need to add to the clus
relevant POM on the Spring boot website.Create a new spring boot project, enter the Spring boot component auto-configuration URL, and click Next.Enter information about the purpose of the MAVEN entry and select the JDK version.Select the service component you want.The Created Spring Boot project is an empty MAVEN project with the required jar packages in the POM. Spring Boot Connection MongoDB
Spring data provides support for operating multiple datab
Copy Code code as follows:
Connect localhost:27017
$conn = new Mongo ();
Connecting to the remote host default port$conn = new Mongo (' test.com ');
Connecting to remote host port 22011$conn = new Mongo (' test.com:22011 ');
MongoDB has user name password$conn = new Mongo ("Mongodb://${username}:${password} @localhost")
mongodb resolves an error that cannot connect to the server MongoDB has the following error: couldn ' t connect to server 127.0.0.1 workaround is: First look at the service start No, if not start the service first start the service, if the service has been started, it hasIt is possible that the last time the MONGO was
Recently installed the mongodb3.0, and enabled the authorization authentication, the DOS window operation without any problems, as shown in figure:
In order to maintain the convenience of downloading a client tool Robomongo 0.8.4, user name, password, such as configuration better solution test,
As a result, the connection service does not have a problem, and permission validation does not pass, as shown:
View the log, found a sentence: Failed to authenticate admin@admin with mechanism
Tags: direct sof str URI and user RTM avoid RTO1. Connect① Way OneMongoclientoptions.builder Builder = Mongoclientoptions.builder ();//various detailed configurations can be made through builderMongoclientoptions myoptions =Builder.build (); ArrayListNewArrayList (); ServerAddress Record=NewServerAddress ("localhost", 27017);//IP, PortServeraddresslist.add (record); //user name, default library name, passwordMongocredential credential = mongocredentia
One, replica set configurationSet up, 1 main instances, 1 units from the instance, 1 arbitration instances. MongoDB recommends an odd number of machines in a replica setSecond, C # connection string1. ReadMongodb://secondary.com/?slaveok=true2. WriteMongodb://primary.comThird, experience1. Using a 1.7 C # driver, do not support configuring/?readpreference=secondary or/?readpreference=secondarypreferred directly in the connection string2.readPreference
Background information:
Because the Linux server used for development is in a relatively closed environment, only 22 ports are accessed via SSH. So I used putty to do an SSH forwarding to map the 27018 port of this machine to the remote 27017 port. Successfully connected via MONGO localhost:27018 in CMD and operated.
Phenomenon:
In the program through the
Mongo Mongo = new Mongo ("localhost", 27018);MongoDB on a remote server, the following error occ
Label:First, let's take a look at the map to see if the parents have the same connection problem. I have met two times and felt it necessary to record it. Ready for future viewing. Analysis reason: This is the start of the Shell editor when the problem occurs, I analyze he may be a server connection problem. Workaround: In the MONGO installation file, create a mongo.config file that reads as follows: If you start MONGO every time, it will be a very troublesome thing to start from CMD. It is co
That's the mistake!I searched the Internet. The solution is almost all about the issue of authentication mechanisms:>Use Admin switched to DB admin>Db.system.version.find () {"_id":"featurecompatibilityversion","version":"3.4" } { "_id":"Authschema","CurrentVersion":5}Then delete the user after the "CurrentVersion": Change to 3 and finally add the user.But I tried it many times and I didn't use!!!!!!!!!!!!!!!!!!!!.If you use the above solution, it may be a mechanism problem. If not, you should n
In the form of batch file, first solve this problem really is not I am good at, thanks to warm uncle help me. Because I found out that the DOS code is quite different from the batch file. Here is my solution to this problem when the harvest, of course, without the help of small warm. Here are some of the absolute and relative paths written in the batch fileFirst I try the following method, which is written in the batch file below and then the DOS environment to assign the 1% parameterHowever, th
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.