we use ** server --version** to check version from the host computer
but this command not works in client computer
(error) ERR unknown command `redis-server`, with args beginning with: `--version`,
after the connecting to server
type this command
> info
Related
GO application failed to connect to local PostgreSQL database using environment variables in Windows.
After setting the environment variables using the windows command prompt like the following:
set DATABASE_HOST=localhost
set DATABASE_USER=postgres
set DATABASE_PASSWORD=password
set DATABASE_NAME=db
set DATABASE_PORT=5432
The following command was tried to run the go application:
go run main.go
I get the following error:
←[0m←[31m[error] ←[0mfailed to initialize database, got error cannot parse `host= user= password=xxxxx dbname= port=`: invalid port (strconv.ParseUint: parsing "": invalid syntax)
panic: Failed to connect to database!
goroutine 1 [running]:
C:/Users/user/go/src/code/db.go:12 +0xb4
This is the code for the db.go
import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func ConnectDatabase(dsn string) *gorm.DB {
database, err := gorm.Open(postgres.Open(dsn))
if err != nil {
panic("Failed to connect to database!")
}
return database
}
But when echo command was tried it does return the correct value in the command prompt. Example echo %DATABASE_PORT% command returns 5432.
Note: main.go has the database migration related to code to initialize the database tables and schemas and works fine in Linux and Mac OS.
MongoDB v4 Ent, Windows Server 2016 Std
Starting mongodb from command line works fine:
mongod --enableEncryption --encryptionKeyFile c:\key\mongodb-keyfile
Now I need to change mongod.cfg so windows service starts with encryption enabled. After adding following parameters to file
security:
enableEncryption: true
encryptionKeyFile: c:\key\mongodb-keyfile
service throw error while starting
error 1067: the process terminated unexpectedly
Any ideas?
I am trying to run the meteor application on windows. I have local mongodb running on my machine and I have also set the environment variable <b>MONGO_URL=mongodb://127.0.0.1:27017/sample</b> on my system. Still meteor application is not able to connect to it. what could be the issue.
Below is the error:-
C:\workspace\node-workspace\gm>meteor
[[[[[ C:\workspace\node-workspace\gm ]]]]]
=> `Meteor server running on: <b>http://127.0.0.1:3000/</b>`
app/packages/mongo-livedata/mongo_driver.js:113
throw err;
^
Error: failed to connect to [127.0.0.1:3002]
at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
at EventEmitter.emit (events.js:126:20)
at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
at EventEmitter.emit (events.js:99:17)
at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted
app/packages/mongo-livedata/mongo_driver.js:113
throw err;
^
Error: failed to connect to [127.0.0.1:3002]
at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
at EventEmitter.emit (events.js:126:20)
at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
at EventEmitter.emit (events.js:99:17)
at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Meteor server restarted
app/packages/mongo-livedata/mongo_driver.js:113
throw err;
^
Error: failed to connect to [127.0.0.1:3002]
at Server.connect.connectionPool.on.server._serverState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongo
db\connection\server.js:564:74)
at EventEmitter.emit (events.js:126:20)
at connection.on._self._poolState (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connecti
on_pool.js:124:15)
at EventEmitter.emit (events.js:99:17)
at Socket.errorHandler (C:\Program Files (x86)\Meteor\packages\mongo-livedata\.npm\node_modules\mongodb\lib\mongodb\connection\connection.js:465:1
0)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
Given that the stack trace says that meteor is still trying to connect to the mongoDb instance on port 3002, then either you have't set the environment variable properly or you haven't reloaded the cmd shell to get the new value.
How did you set MONGO_URL ? If you set it through the System Properties or updated the autoexec.bat then you'll need to re-load the cmd shell.
You can see what the current value is by typing in the cmd shell:
echo %MONGO_URL%
Then to set it for the current env you can do :
set MONGO_URL=mongodb://127.0.0.1:27017/sample
I know it's been awhile but I ran into this same issue (in July 13') I didn't have time to figure it out and ended up going to a Linux installation which worked fine.
Recently however I got some time to circle back to it. Here is some discussion on the matter in the google group- https://groups.google.com/forum/#!topic/meteor-talk/AE6GYrJImAo
I found out that the Mongo DB process was not even starting, some conflict within mongo_runner.js ... My solution was to start mongo manually
C:\Program Files (x86)\Meteor\mongodb\bin>mongod -port 3002 --dbpath C:\Users\username\project\.meteor\local\db
The above starts the project on the needed port and specifies the database folder for your project... After this just start meteor as you normally would.
As of Version 0.7.1 the meteor mongodb port is 3001, instead of 3002.
The port is generally 1 higher (2 in the case of older versions of meteor) than the port Meteor is running on. e.g if Meteor runs on port 3000, MongoDB would be at port 3001
Following is the console session...
C:\Users\xxx>vmc tunnel myMongoDB
Getting tunnel connection info: OK
Service connection info:
username : uuuu
password : pppp
name : db
url : mongodb://uuuu:pppp#172.30.xx.xx:25200/db
Starting tunnel to myMongoDB on port 10000.
1: none
2: mongo
3: mongodump
4: mongorestore
Which client would you like to start?: 2
Launching 'mongo --host localhost --port 10000 -u uuuu -p pppp db'
MongoDB shell version: 2.0.6
connecting to: localhost:10000/db
> db.serverStatus()
{ "errmsg" : "need to login", "ok" : 0 }
>
Which credentials should I use to login (assuming should use db.auth) to get rid of the error "{ "errmsg" : "need to login", "ok" : 0 }".
When I run the same in micro CF on my machine it works ok and gives me the expected output.
P.S. I'm trying this to get to know the current connections on my application, written in node.js. Trying to debug some issues with connections to the DB. If there is any other alternative that I can use please suggest that as well.
this should work! Not sure why your tunnel isn't connecting, my immediate suggestion is to try another instance of MongoDB and see if the same error occurs.
If you are trying to inspect the bound services on you node.js app you should be able to inspect them in the VCAP_SERVICES environment variable. For example;
var http = require('http');
var util = require('util');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write(util.inspect(process.env.VCAP_SERVICES));
res.write("\n\n************\n\n");
res.end(util.inspect(req.headers));
}).listen(3000);
This code is currently running at http://node-headers.cloudfoundry.com/ to serve as an example. However, mongodb connections for node.js applications should automatically configure to the bound service. If this does not work for you, then please do let me know.
I have installed mongoDB on ubuntu in VMplayer running on windows7.
I have edited the hosts file to have
machinename 192.168.1.12.
I installed all the packages and trying to start the mongod.
This is the error I am getting:
ubuntu:/etc/init.d$ start mongodb start: Rejected send message, 1
matched rules; type="method_call", sender=":1.128" (uid=1000 pid=9669
comm="start mongodb ") interface="com.ubuntu.Upstart0_6.Job"
member="Start" error name="(unset)" requested_reply="0"
destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")
Can you please let me know what could be the issue?
I was able to install successfully in a pevious in ubuntu.
That's a permission error, you need to sudo, i.e. run the following and you will be ok -
sudo start mongodb