Secondary read preference - digital-ocean

I am trying to do mongodump in Digital Ocean ubuntu server.I am getting following error.
root#Project:~# sudo mongodump --db <database> --out /root/backup/Localdb
2018-11-07T06:28:09.177+0000 Failed: error getting collections for database `<database>`: error running `listCollections`. Database: `<database>` Err: not authorized on `<database>` to execute command { listCollections: 1, cursor: {}, $readPreference: { mode: "secondaryPreferred" }, $db: `<database>` }
How to fix this issue.
Thanks.

Related

Mongoose DocumentDB connection fails through SSH tunnel

I am trying to connect to AWS DocumentDB with Node.js/Typescript and Mongoose. I have an EC2 instance setup as SSL tunnel, which works great. I can connect to DocumentDB locally with Studio3T and mongo-cli.
This command works mongo --sslAllowInvalidHostnames --ssl --sslCAFile rds-combined-ca-bundle.pem --username <username> --password <password>
But if I try to connect to the same database with Mongoose, it fails. This is my code and the error:
const options = {
dbName: "prodDB",
user: connectionData.username,
pass: connectionData.password,
tls: true,
tlsCAFile: "../rds-combined-ca-bundle.pem",
tlsAllowInvalidHostNames: true,
};
try {
await connect("mongodb://localhost:27017", options);
} catch (error) {
console.log(error);
}
MongooseServerSelectionError: connect EHOSTUNREACH imagine-ip-address-here:27017
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
'censored:27017' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'rs0',
commonWireVersion: 7,
logicalSessionTimeoutMinutes: undefined
}
At this point, I have tried pretty much any possible config in Mongoose and I am getting desperate. Any help is appreciated
This seems to be an issue with mongoose versions >= 6.
Downgrading Mongoose to version 5.13.8 works without a problem.
Mongoose devs are apparently aware of this issue: https://github.com/Automattic/mongoose/issues/11105

Docker push Error saving credentials: error storing credentials - err: exit status 1, out: `not implemented`

I have all AWS CLI and docker setup and running for a while. I changed the command codes to all run from a bash file. However, when running the docker push I get this error Error saving credentials: error storing credentials - err: exit status 1, out: `not implemented
I tried AWS_DEFAULT_PROFILE="aaa" docker push ... and docker push --profile=aaa nut none of them either worked. I do not see any similar issue like 'not implemented' on Google!
Any help is appreciated!
Here is the solution I found, thanks to docker login: error storing credentials `The stub received bad data.`
The .docker/config.json looks like this:
{
"auths" : {
},
"stackOrchestrator" : "swarm",
"HttpHeaders" : {
"User-Agent" : "Docker-Client/19.03.8 (darwin)"
},
"credsStore" : "ecr-login"
}
by removing "credsStore" : "ecr-login" it worked!

Using notebook (Databricks) show error java.io.IOException: Error getting access token from metadata server

I'm using https://community.cloud.databricks.com/ (notebook) when I try to access Storage GCP through the Python command as below:
df = spark.read.format(csv).load(gs://test-gcs-doc-bucket-pr/test)
Error:
java.io.IOException: Error getting access token from metadata server at: 169.254.169.xxx/computeMetadata/v1/instance/service-accounts/default/token
Databricks Spark Configuration:
spark.hadoop.fs.gs.auth.client_id "10"
spark.hadoop.fs.gs.auth.auth_uri "https://accounts.google.com/o/oauth2/auth"
spark.databricks.delta.preview.enabled true
spark.hadoop.google.cloud.auth.service.account.enable true
spark.hadoop.fs.gs.auth.service.account.email "test-gcs.iam.gserviceaccount.com"
spark.hadoop.fs.gs.auth.token_uri "https://oauth2.googleapis.com/token"
spark.hadoop.fs.gs.project_id "oval-replica-9999999"
spark.hadoop.fs.gs.auth.service.account.private_key "--BEGIN"
spark.hadoop.fs.gs.auth.service.account.private_key_id "3f869c98d389bb28c5b13a0e31785e73d8b ```

Getting "could not start SASLPrep for password: generic server error" error when trying to insert/find documents in mongoDB in C++

I have a mongDB running in my VM (Ubuntu) in access control mode. I created an admin user with this role:
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
I installed the mongoDB driver for C++ and wrote a mini-program to test it. My code (basically copied from mongocxx tutorial):
mongocxx::instance instance{};
mongocxx::uri uri(
"mongodb://userName:password#localhost:27017/?authSource=admin");
mongocxx::client conn(uri);
mongocxx::database db = conn["test"];
mongocxx::collection coll = db["test"];
mongocxx::cursor cursor = coll.find({});
for (auto doc : cursor) {
std::cout << bsoncxx::to_json(doc) << "\n";
}
I inserted a document in test.test from mongo shell. The 'find' command works with the same user in mongo shell.
When running this mini program I get:
terminate called after throwing an instance of 'mongocxx::v_noabi::query_exception'
what(): could not start SASLPrep for password: generic server error
Aborted (core dumped)
When I cancel the MonogDB access control and connect to it with the same lines but without the user/password it works great and I can insert and find documents. How to fix this?

Saltstack fails when creating minions from a map file on DigitalOcean

I can't create a minion from the map file, no idea what's happened. A month ago my script was working correctly, right now it fails. I was trying to do some research about it but I could't find anything about it. Could someone have a look on my DEBUG log? The minion is created on DigitalOcean but the master server can't connect to it at all.
so I run:
salt-cloud -P -m /etc/salt/cloud.maps.d/production.map -l debug
The master is running on Ubuntu 16.04.1 x64, the minion also.
I use the latest saltstack's library:
echo "deb http://repo.saltstack.com/apt/ubuntu/16.04/amd64/latest xenial main" >> /etc/apt/sources.list.d/saltstack.list
I tested both 2016.3.2 and 2016.3.3, what is interesting, the same script was working correctly 4 weeks ago, I assume something had to change.
ERROR:
Writing /usr/lib/python2.7/dist-packages/salt-2016.3.3.egg-info
* INFO: Running install_ubuntu_git_post()
disabled
Created symlink from /etc/systemd/system/multi-user.target.wants/salt-minion.service to /lib/systemd/system/salt-minion.service.
* INFO: Running install_ubuntu_check_services()
* INFO: Running install_ubuntu_restart_daemons()
Job for salt-minion.service failed because a configured resource limit was exceeded. See "systemctl status salt-minion.service" and "journalctl -xe" for details.
start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
* ERROR: No init.d support for salt-minion was found
* ERROR: Fai
[DEBUG ] led to run install_ubuntu_restart_daemons()!!!
[ERROR ] Failed to deploy 'minion-zk-0'. Error: Command 'ssh -t -t -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oControlPath=none -oPasswordAuthentication=no -oChallengeResponseAuthentication=no -oPubkeyAuthentication=yes -oIdentitiesOnly=yes -oKbdInteractiveAuthentication=no -i /etc/salt/keys/cloud/do.pem -p 22 root#REMOVED_IP '/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd/deploy.sh -c '"'"'/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd'"'"' -P git v2016.3.3'' failed. Exit code: 1
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 2293, in create_multiprocessing
local_master=parallel_data['local_master']
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1281, in create
output = self.clouds[func](vm_)
File "/usr/lib/python2.7/dist-packages/salt/cloud/clouds/digital_ocean.py", line 481, in create
ret = __utils__['cloud.bootstrap'](vm_, __opts__)
File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 527, in bootstrap
deployed = deploy_script(**deploy_kwargs)
File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 1516, in deploy_script
if root_cmd(deploy_command, tty, sudo, **ssh_kwargs) != 0:
File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 2167, in root_cmd
retcode = _exec_ssh_cmd(cmd, allow_failure=allow_failure, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/utils/cloud.py", line 1784, in _exec_ssh_cmd
cmd, proc.exitstatus
SaltCloudSystemExit: Command 'ssh -t -t -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oControlPath=none -oPasswordAuthentication=no -oChallengeResponseAuthentication=no -oPubkeyAuthentication=yes -oIdentitiesOnly=yes -oKbdInteractiveAuthentication=no -i /etc/salt/keys/cloud/do.pem -p 22 root#REMOVED_ID '/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd/deploy.sh -c '"'"'/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd'"'"' -P git v2016.3.3'' failed. Exit code: 1
[DEBUG ] LazyLoaded nested.output
minion-zk-0:
----------
Error:
Command 'ssh -t -t -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oControlPath=none -oPasswordAuthentication=no -oChallengeResponseAuthentication=no -oPubkeyAuthentication=yes -oIdentitiesOnly=yes -oKbdInteractiveAuthentication=no -i /etc/salt/keys/cloud/do.pem -p 22 root#REMOVED_IP '/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd/deploy.sh -c '"'"'/tmp/.saltcloud-5d18c002-e817-46d5-9fb2-d3bdb2dfe7fd'"'"' -P git v2016.3.3'' failed. Exit code: 1
root#master-zk:/etc/salt/cloud.maps.d# salt '*' test.ping
minion-zk-0:
Minion did not return. [No response]
root#master-zk:/etc/salt/cloud.maps.d#
It is located in your cloud configuration somewhere in /etc/salt/cloud.profiles.d/, /etc/salt/cloud.providers.d/ or /etc/salt/cloud.d/. Just figure out where and change the value salt to your masters ip.
I currently do this in my providers setting like that:
hit-vcenter:
driver: vmware
user: 'foo'
password: 'secret'
url: 'some url'
protocol: 'https'
port: 443
minion:
master: 10.1.10.1