mongolab / mongoctl Goto Github PK
View Code? Open in Web Editor NEWManage MongoDB servers and replica sets using JSON configurations!
License: MIT License
Manage MongoDB servers and replica sets using JSON configurations!
License: MIT License
I tried starting MongoDb using mongoctl start --httpinterface --rest REST MyServer
but I got this error:
unrecognized arguments: --httpinterface
Usage: start [<options>] SERVER_ID
see 'mongoctl start --help' for detailed options
Taking a look at the mongoctl
command reference did not help.
On OS X 10.9.1 (w/ Python 2.7.5), installation of mongoctl fails with pip:
sudo pip install mongoctl
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.3.1
Make it possible to remove a node that is no longer DNS-mapped when the node is no longer in the cluster config.
File "/usr/local/lib/python2.7/dist-packages/mongoctl/utils.py", line 275, in is_same_address
return (is_same_host(hostport1[0], hostport2[0]) and
File "/usr/local/lib/python2.7/dist-packages/mongoctl/utils.py", line 263, in is_same_host
ips2 = get_host_ips(host2)
File "/usr/local/lib/python2.7/dist-packages/mongoctl/utils.py", line 298, in get_host_ips
raise MongoctlException("Invalid host '%s'. Cause: %s" % (host, e))
MongoctlException: Invalid host 'foo.bar.com'. Cause: [Errno -2] Name or service not known
Since pip install failed on my OS X machine (see #12) I tried sudo easy_install mongoctl
- which succeeds. However, it doesn't seem to generate a default ~/.mongoctl/mongoctl.config
file:
mongoctl connect mongodb://URL
ERROR: Config file /Users/niallo/.mongoctl/mongoctl.config does not exist.
My suggestion would be to have mongoctl generate or use the default config at runtime, instead of relying on the presence of on-disk file.
mongoctl does not use community_ssl
with configured clusters as there does not appear to be a way to specify that a clusters should use ssl.
A cluster is configured as preferSSL
, when using mongoctl connect cluster-name
, an error is returned:
Unable to find a compatible 'mongo' executable for version 3.0.8 (edition community). You may need to run 'mongoctl install-mongodb 3.0.8 ' to install it.
The installed versions were:
$ ./mongoctl list-versions
--------------------------------------------------------------------------------
VERSION EDITION LOCATION
--------------------------------------------------------------------------------
3.0.8 community_ssl /usr
Considering that the server is configured with preferSSL
and community_ssl
was available, the community_ssl shell should have been used.
Mongo URI option authSource
is not supported with mongoctl dump
or mongoctl restore
. The work around is to use the --authenticationDatabase
command line option.
While the work around is functional, support for authSource would make scripting and automation much.
Hi everyone,
I realized that there were issues with 0.78/0.7.9 in pypi so i had to pull them out. Latest stable version is 0.7.8 from github https://github.com/mongolab/mongoctl/releases/tag/0.7.8
I'll be fixing these issues and will release after testing. Apologies for any inconvenience.
-abdul
Please publish a brew recipe, it's pretty crazy that I need to sudo install this.
def has_joined_replica(self):
master_result = self.is_master_command()
if master_result:
return (master_result.get("setName") is not None or
master_result.get("ismaster") or
master_result.get("arbiterOnly") or
master_result.get("secondary"))
Do we need master_result.get("setName") is not None
??
mongoctl/mongoctl/objects/mongod.py
Line 280 in 2caecd0
# pip-3.2 install mongoctl
Downloading/unpacking mongoctl
Downloading mongoctl-0.9.0.tar.gz (78Kb): 78Kb downloaded
Running setup.py egg_info for package mongoctl
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/build/mongoctl/setup.py", line 74
os.chmod(dot_mongoctl_dir, 00755)
^
SyntaxError: invalid token
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/build/mongoctl/setup.py", line 74
os.chmod(dot_mongoctl_dir, 00755)
^
SyntaxError: invalid token
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /build/mongoctl
Is it possible to manage mongos via mongoctl? What I'd like to do is to configure/manage the mongos processes via mongoctl.
Thanks
Robert
I think this is an enhancement request, or else I just can't figure out your docs.
The reason I started using mongoctl was so that I could connect to my mongo servers using the mongodb://
uri instead of parsing it into {host, port, username, password, database} every time. But when setting up .mongoctl/servers.config
I can't use the URI but need to parse it manually.
The latest version of mongoctl on pypi is 0.3.7. The latest stable version of mongoctl is 0.7.5.
Please update asap, as it would make patching much easier!
When we run configure cluster option, utility is prompting for local and admin password even though server is configured without password. But cluster seems to configure right. It only happens first time, re-running the same command for reconfiguring the cluster works fine, i.e. passwords are not prompted.
mongoctl --config-root /mnt/mongodb/mongoctl configure-cluster mongodb-insights
Validating cluster 'mongodb-insights'...
Initializing replica set cluster 'mongodb-insights' ...
Determining which server should be primary...
Selected server 'xxxxxxxx' as primary.
Executing db command {
"replSetInitiate": {
"_id": "mongodb-insights",
"members": [
{
"host": "",
"_id": 0
}
]
}
}
WARNING: Command {
"replSetInitiate": {
"_id": "mongodb-insights",
"members": [
{
"host": "",
"_id": 0
}
]
}
} is taking a while to complete. This is not necessarily bad.
Will now wait for the replica set to initialize.
Enter username for database 'local':
Enter password for user 'local'
Password:
ERROR: Invalid login!
Enter username for database 'local':
Enter password for user 'local'
Password:
ERROR: Invalid login!
Enter username for database 'local':
Enter password for user 'local'
Password:
ERROR: Invalid login!
Enter username for database 'admin':
Enter password for user 'admin'
Password:
ERROR: Invalid login!
Enter username for database 'admin':
Enter password for user 'admin'
Password:
ERROR: Invalid login!
Enter username for database 'admin':
Enter password for user 'admin'
Password:
ERROR: Invalid login!
ERROR: Unable to initialize replica set cluster 'mongodb-insights'. Cause: Failed to authenticate to admin db
Re-running same command works fine
mongoctl --config-root /mnt/mongodb/mongoctl configure-cluster mongodb-insights
Validating cluster 'mongodb-insights'...
Re-configuring replica set cluster 'mongodb-insights'...
Current replica set configuration:
{
"_id": "mongodb-insights",
"version": 3,
"members": [
{
"host": "",
"_id": 0
}
]
}
Executing the following command on server 'xxxxxxx':
{
"replSetReconfig": {
"_id": "mongodb-insights",
"version": 4,
"members": [
{
"host": "",
"_id": 0
}
]
},
"force": false
}
Re-configuration for replica set cluster 'mongodb-insights' ran successfully!
New replica set configuration:
{
"_id": "mongodb-insights",
"version": 4,
"members": [
{
"host": "",
"_id": 0
}
]
}
I just followed the installation instructions but get this errors when running restore:
mongoctl restore mongodb://localhost:37017/db_development mydumpdir/
/Library/Python/2.6/site-packages/mongoctl/mongoctl.py:5257: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
self.message = message
/Library/Python/2.6/site-packages/mongoctl/mongoctl.py:5261: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
return self.message
How can I check which version of mongoctl I have? I couldn't find an option for that...
Thanks.
Trying to install the latest mongo mongoctl install-mongodb 3.6.3
Looking for a download for MongoDB ('3.6.3', 'community')
Failed to install MongoDB '3.6.3 (community)'. Cause: No mongodb binary (version: '3.6.3', edition: 'community')
For security reason, I'd like to run mongod as a nologin user, '_mongo' for example.
I used to start mongod using command: sudo -u _mongo mongod ...
Now I want to switch to mongoctl, but I don't how to achieve this with mongoctl.
How does one initialize a new database with mongoctl from a script?
I would like to create a new database instance on an existing server from a script.
Creating a new database requires using "use dbname", however, if I put "use dbname" in an eval script or direct to the eval option, I receive a syntax error.
There is a 3.2.11 mongod running on that box and uninstalling 3.2.1 fails
mongoctl error: ERROR: Cannot uninstall '/home/madmin/deploy/lib/src/mongodb-linux-x86_64-community_ssl-3.2.1' because its currently being used. Please terminate all running processes then try again.
Hi all,
My configuration for the server look as follow:
{
"_id": "MyClusterServer2",
"description" : "My cluster member",
"address": "192.168.23.232:37027",
"cmdOptions":{
"port": 37027,
"dbpath": "~/mongodb-data/my-cluster-server2",
"directoryperdb": true
}
},
for other server (closter node which is aimed to be run locally) I define "localhost" as the host.
But during run (server/cluster start) "mongoctl" produces number of errors as follow:
Unable to resolve address '192.168.132.236' for server 'MyClusterServer1'. Cause: Invalid host 'ip-192-168-132-112'. Cause: [Errno -2] Name or service not known
Unable to resolve address '192.168.132.112' for server 'MyClusterArbiter'. Cause: Invalid host 'ip-192-168-132-112'. Cause: [Errno -2] Name or service not known
Unable to determine primary server for replica set cluster 'MyCluster'
Even more complicated is that despite of that, it starts mongo instance.
But then I can't delete it:
mongoctl stop MyClusterServer1
Checking to see if server 'MyClusterServer1' is actually running before stopping it...
Unable to determine pid for server 'MyClusterServer1'. pid file '/home/ubuntu/mongodb-data/my-cluster-server1/pid.txt' does not exist
Stopping server 'MyClusterServer1' (pid=[Cannot be determined])...
Sending the following command to localhost:27017:
{
"shutdown": 1,
"force": false
}
Failed to gracefully stop server 'MyClusterServer1'. Cause: shutdown must run from localhost when running db without auth
Issue the shutdown with force command? [y/n] y
Sending the following command to localhost:27017:
{
"shutdown": 1,
"force": true
}
Failed to gracefully stop server 'MyClusterServer1'. Cause: shutdown must run from localhost when running db without auth
Cannot forcibly stop the server because the server's process ID cannot be determined; pid file '/home/ubuntu/mongodb-data/my-cluster-server1/pid.txt' does not exist.
Unable to stop server 'MyClusterServer1'.
Though server is up and running:
mongoctl status MyClusterServer1
Status for server 'MyClusterServer1':
{
"connection": true,
"serverStatusSummary": {
"connections": {
"current": 3,
"available": 419427
},
"host": "894c34d3b089",
"version": "3.2.6"
},
"selfReplicaSetStatusSummary": {
"stateStr": "SECONDARY",
"name": "192.168.132.236:27017"
}
}
Hence, everything is messed up. It somehow works, though telling me that it can't connect and actually even find other nodes.
I can't stop it at all.
Regards,
Taras.
I have just come across this tool and it looks really great!
I have installed a multiple versions of MongoDB:
$ mongoctl list-versions
--------------------------------------------------------------------------------
VERSION EDITION LOCATION
--------------------------------------------------------------------------------
2.4.12 community /Users/ytakeda/mongodb/mongodb-osx-x86_64-community-2.4.12
2.6.10 community /Users/ytakeda/mongodb/mongodb-osx-x86_64-community-2.6.10
3.0.8 community /Users/ytakeda/mongodb/mongodb-osx-x86_64-community-3.0.8
3.2.0 community /Users/ytakeda/mongodb/mongodb-osx-x86_64-community-3.2.0
Now, I would like to pick and choose one of these versions for our testing, then later switch over to the other, etc. How do I start the specific version with $ mongoctl start
command?
I just installed pymongo 3.0.3 via pip install --upgrade pymongo
and it reported no module named Connection:
In [2]: pymongo.version
Out[2]: '3.0.3'
In [3]: from pymongo import Connection
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-dd44bc3249d3> in <module>()
----> 1 from pymongo import Connection
ImportError: cannot import name Connection
In [4]: from pymongo import connection
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-71c9e4ec1bcd> in <module>()
----> 1 from pymongo import connection
ImportError: cannot import name connection
In [5]: import pymongo.connection.Connection
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-282b89157c85> in <module>()
----> 1 import pymongo.connection.Connection
ImportError: No module named connection.Connection
Apologies if this a total python newb issue rather than a mongoctl issue.
I'm seeing the following behavior, any ideas on how to resolve?
After uninstalling and reinstalling python (2.7.9) via Homebrew on OS X 10.10 and trying pip installs with sudo and without, I keep getting this error:
Traceback (most recent call last):
File "/usr/local/bin/mongoctl", line 48, in <module>
from mongoctl import mongoctl
File "/usr/local/lib/python2.7/site-packages/mongoctl/mongoctl.py", line 38, in <module>
import objects.server
File "/usr/local/lib/python2.7/site-packages/mongoctl/objects/server.py", line 21, in <module>
from pymongo.connection import Connection
ImportError: No module named connection
I was prompted by an error message to install the community_ssl version, but when I try that, I get the following error about the argument being unrecognized:
% mongoctl install-mongodb --edition community_ssl 3.0.5
unrecognized arguments: --edition 3.0.5
I am running mongoctl 0.9.0.
Any ideas?
logs:
~ Tue Jan 20 17:18:24 mongoctl --client-ssl-mode prefer connect MONGODB_URI
Will not be using database repository for configurations at this time!
REASON: Could not establish a database connection to mongoctl's database repository.
CAUSE: [Errno 61] Connection refused.
Locating default server for cluster 'MONGODB_URI'...
Connecting to server '......'
Using mongo at '/Users/mongochang/mongodb/mongodb-osx-x86_64-community_ssl-2.6.1/bin/mongo' version '2.6.1 (community_ssl)'...
Executing command:
/Users/mongochang/mongodb/mongodb-osx-x86_64-community_ssl-2.6.1/bin/mongo dsxxxxx.mongolab.com:xxxx/ssl -u **** -p **** (should use --ssl)
MongoDB shell version: 2.6.1
connecting to: ..........
Error while trying to show server startup warnings: not authorized on admin to execute command { getLog: "startupWarnings" }
It would be a great feature to be able to remotely manage servers and eliminating the requirement to have mongoctl installed on each cluster node.
It looks like its trying to fetch a nonexistent i386 version
dmacd$ mongoctl install 2.2.5
Running install for osx 32bit to mongoDBInstallationsDirectory (/Users/dmacd/mongodb)...
ERROR: Unable to download from url 'http://fastdl.mongodb.org/osx/mongodb-osx-i386-2.2.5.tgz' (response code '403'). It could be that version '2.2.5' you specified does not exist. Please double check the version you provide
Running the python 2.7.5 build from python.org.
Would love to use your tool, is there any way to provide a literal url?
Today we tried to upgrade to mongo v 2.4.3, but were unable to do so using mongoctl. We soon realized that this is because the value of the file mongo_latest_stable_version.txt is 2.2.4! Please update asap.
i am testing you!
Hey everyone,
I would like to propose that we do something against the rising amount of open, insecure MongoDB instances exposed to the public.
By default, mongoctl sets up a Mongo server with no auth
parameter in the config, meaning that if you use mongoctl on a server, everybody can connect to it, if you know the IP or domain. This problem is so widespread, that over 35,000 MongoDB instances are public, and hackers actively exploit this.
This is not a bug in mongoctl, and these things happen because developers don't inform themselves enough, but nonetheless I think we should put a big, fat warning up on this repo, because a lot of users are falling into this trap. And that's because we easily let them:
auth
parameter in the mongoctl documentation and hidden deep in the MongoDB documentation.I confess that I also did not read the docs in detail and had a database out in the wild โ fortunately I was able to fix it before something bad happened because DigitalOcean sent me this email:
With ~6000 installs per year, mongoctl has some significance when it comes to the number of open Mongo databases out there. While mongoctl is not guilty for this, it should be a lot easier for developers to figure out how to set up a secure MongoDB.
That's why I propose that the Github repo and the mongoctl website get a prominent warning "Make sure to use {auth: true}
in production!", because really, that is the essential information which more people need to know.
Best,
Jonny
Is it possible to create a user in the seedUsers list as read only?
Thanks
It appears that a mongo URI that uses the authSource option cannot properly connect to the database.
Given a URI of the form: mongodb://user:pass@server-1:27017,server-2:27017/database?replicaSet=rs-1&ssl=true&authSource=admin
The response is
Locating default server for cluster 'mongodb://*****:*****@server-1:27017,server-2:27017/database'...
Connecting to server 'server-1:27017'
Invalid login!
Enter username for database 'database':
The authSource to the admin database appears to be lost during the URI parsing and connection process.
It looks like the latest version on pypi is 0.7.81, though 0.9.0 is tagged in the repo. Would you mind publishing it?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.