How to provide mongoSQLd Authentication failed ERROR 1043 (08S01) - mongodb

To run BI on project we have used mongsqld to convert the JSON into tables.
On our first installation, everything was running fine and we were able to make analytics.
After installing the security on mongod, the monsqld failes to establish the connection with following error:
connection accepted from 127.0.0.1:44530 #11219 (1 connection now open)
handshake error: ERROR 1043 (08S01): MongoDB schema not yet available
end connection 127.0.0.1:44530 (0 connections now open)
Thanks in Advance.

It can also be the case that you haven't set up your mongosqld.conf correctly on your mongo bi connector side.
This will be evident if you check the log files for your mongosqld.conf and find that it has repeated entries for "[Sampler] sampling mongodb for schema permanently". In my case this happened all night until I fixed the config file.
In my particular case - I didnt configure authentication as per the following.
logAppend: false
path: "/var/log/mongosqld/mongosqld.log"
verbosity: 2
security:
enabled: true
mongodb:
net:
uri: "mongo.example.com:27017"
auth:
username: "root"
password: "changeme"
net:
bindIp: 192.0.2.14
port: 3307
As soon as I made the change, uninstalled mongosqld (sudo mongosqld uninstall), installed momgosqld with the new conf (sudo mongosqld install ), and restarted it - it worked.
More about the configuration here - https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#std-label-config-format

Related

How to store mongo db backups to google drive using Symfony 3.4

I am trying to upload mongo db backup to google drive
I am installing following bundles dizda/cloud-backup-bundle and Happyr
/
GoogleSiteAuthenticatorBundle for adapters I am using cache/adapter-bundle
configuration:
dizda_cloud_backup:
output_file_prefix: '%dizda_hostname%'
timeout: 300
processor:
type: zip # Required: tar|zip|7z
options:
compression_ratio: 6
password: '%dizda_compressed_password%'
cloud_storages:
google_drive:
token_name: 'AIzaSyA4AE21Y-YqneV5f9POG7MPx4TF1LGmuO8' # Required
remote_path: ~ # Not required, default "/", but you can use path like "/Accounts/backups/"
databases:
mongodb:
all_databases: false # Only required when no database is set
database: '%database_name%'
db_host: '%mongodb_backup_host%'
db_port: '%mongodb_port%'
db_user: '%mongodb_user%'
db_password: '%mongodb_password%'
cache_adapter:
providers:
my_redis:
factory: 'cache.factory.redis'
happyr_google_site_authenticator:
cache_service: 'cache.provider.my_redis'
tokens:
google_drive:
client_id: '85418079755-28ncgsoo91p69bum6ulpt0mipfdocb07.apps.googleusercontent.com'
client_secret: 'qj0ipdwryCNpfbJQbd-mU2Mu'
redirect_url: 'http://localhost:8000/googledrive/'
scopes: ['https://www.googleapis.com/auth/drive']
when I use factory: 'cache.factory.mongodb' getting
You have requested a non-existent service "cache.factory.mongodb" this while running server and while running backup command getting
Something went terribly wrong. We could not create a backup. Read your log files to see what caused this error
I verified logs getting Command "--env=prod dizda:backup:start" exited with code "1" {"command":"--env=prod dizda:backup:start","code":1} []
I am not sure which adapter needs to use and what's going on here.
Can someone help me? Thanks in advance

MongoDB - configure encryption in cfg file

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?

Grails 3 MongoDB not reading connectionString from application.yml

I am testing the Grail 3 application to connect mogoDB running on another server.
Standalone java program connect to database successfully. But Grail 3 application not able to connect to DB. Exception show its connecting to localhost.
I would like to understand why its not reading connectionstring from aplication.yml file.
application.yml file:
environments:
development:
grails:
mongodb:
connectionString: "mongodb://192.168.1.13:27017/test"
when I access the page, seeing this error message.
grails> 2017-02-14 22:52:28.116 ERROR --- [nio-8080-exec-9] o.g.web.errors.GrailsExceptionResolver : MongoTimeoutException occurred when processing request: [GET] /book/index
Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]. Stacktrace follows:
why its connecting to localhost?
tried from this answer didn't work.
Installing and using MongoDB in Grails 3.x
Thanks
This configuration work for me in both development and production.
environments:
development:
grails:
mongodb:
host: "localhost"
port: 27017
username: ""
password: ""
databaseName: "mydb-dev"
production:
grails:
mongodb:
host: "1.1.1.1"
# host: "localhost"
port: 27017
username: ""
password: ""
databaseName: "mydb-prod"
I'm using Grails 3.1.9 and latest MongoDB plugin.
compile 'org.grails.plugins:mongodb'
If you still want to use a connection string instead of supplying all of the parameters separately, you can use url as listed below:
environments:
development:
grails:
mongodb:
url: "mongodb://192.168.1.13:27017/test"
This approach also allows you to supply query parameters where necessary. The documentation can be found in the gorm manual under the MongoDB Connection Strings section.

errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node", Why I am getting this message?

I am getting this message every time I do rs.initiate() :
No host described in new configuration 1 for replica set rs0 maps to this node
This is how my /etc/hosts/ file looks on both the replica set servers.
Server 1 and server 2 "hosts" file
127.0.0.1 localhost
aa.bb.cc.dd DataMongo1
ee.ff.gg.hh DataMongo2
Server 1-mongod.conf file
bind-ip aa.bb.cc.dd
Server 2 -mongod.conf file
bind-ip ee.ff.gg.hh
changed server1 hostname to DataMongo1 and server2 to DataMongo2
$hostname DataMongo1
Port 27071 is uncommented on both servers
ReplicaSet config file:
cfg= {
_id:"rs0",
members:[{_id:0,host:"DataMongo1:27071"},{_id:1,host:"DataMongo2:27071"}]}
Please help me with this issue.
I just ran into this issue, and in my case the symptoms were that everything worked correctly, until I rebooted the server.
Then I would get the following error: NodeNotFound: No host described in new configuration $id for replica set $name maps to this node
Just restarting the mongodb daemon fixed it, so it couldn't be a replica set configuration issue.
After checking the logs a bit more in detail, I noticed the following error message: NETWORK [replexec-0] getaddrinfo("$name.emilburzo.com") failed: Temporary failure in name resolution -> bingo
It was trying to query the hostname before the network was fully up, and thus the replica set member didn't know it's own identity
Adding the server's FQDN hostname to /etc/hosts fixed it, e.g.:
127.0.1.1 shortname shortname.fqdn.com
Looks like the port is wrong. The default port of MongoDB is 27017, not 27071.
if you are using mongo.conf file then initially comment "replication" section like below,
...
#operationProfiling:
# replication:
# replSetName: rs0-here
#sharding:
...
Now run mongod and configure replica set on mongo terminal like below,
rs.initiate({_id: "rs0-here", version: 1, members: [{ _id: 0, host : "your_host:27017" }]})
You can also create users and databases here and then exit out of it. Uncomment the following section in mongo.conf,
replication:
replSetName: rs0-here
run mongod again and then this issue should go away.

Mongod doesn't recognize net.http in yaml config?

I have the following config as mongod.cfg:
systemLog:
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:
http:
enabled: true
I'm running MongoDB 2.6.3 on Windows 7 64 bit by running: mongod --config mongod.cfg I'm inside the folder and I know it's parsing the correct mongod.cfg. However, I'm getting the following output:
Unrecognized option: net.http
try 'mongod --help' for more information
I am pulling my hair out wondering why it's not parsing. I'm reading straight from the configuration page on Mongo's site and I still can't make it work. Any ideas?
Turns out I needed spaces after the headers. It needed to be:
systemLog:<space>
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:<space>
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:<space>
http:<space>
enabled: true
I also met the similar issue when add auth to MongoDB admin user. When install MongoDB 3.0.8 or 3.0.15, the error appears:
CONTROL Hotfix kb2731284 or a later update is not installed, will zero-out files.
Fail to install kb2731284(obtained from MS's mail) in my PC whose OS is win7 enterprise version, no vaild resolution online.
Unrecognized option: net.http
try 'mongod --help' for more information
Then update MongoDB to v3.6 can avoid the error in the beginning, but now if want to add auth for MongoDB user using the mongod.cfg file, following content need to be used:
systemLog:
destination: file
path: "D:\\mongodb\\log\\mongodb.log"
logAppend: true
storage:
dbPath: "D:\\mongodb"
journal:
enabled: true
engine: wiredTiger
net:
port: 27017
setParameter:
enableLocalhostAuthBypass: false
Save the file mongod.cfg.
Create folder C:\mongodb\data\,
then create subfolder C:\mongodbdata\log,
Copy the mongod.cfg file to related location of MongoDB bin, such as C:\ProgramFiles\MongoDB\Server\3.6\bin\.
Then set value enableLocalhostAuthBypass in mongod.cfg file to true.
Open cmd.exe with the administrator privilege:
"C:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.exe" "--config=c:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.cfg" --auth --install
If the mongodb service is not running, type net start mongodb
C:\Users\{username}\Desktop>netstart mongodb
> use admin
> db.createUser("admin", "yourpassword", roles: ["root"]})
> db.auth(user, yourpassword)
Restart MongoDB from commond line.
Set value enableLocalhostAuthBypass to false.
Since for MongoDB 3.6 (actually any version after v3.2) have removed the net.http options (Refer: https://docs.mongodb.com/manual/reference/configuration-options/).
Then all issues met can be completely solved.