How do I change the default location of mongodb? - macos

I installed MongoDB on Yosemite using brew. I understand that the default storage location is /data/db. I'd like to change this to location /Volumes/Data/mongodb, so that when I run 'mongod', it will choose the databases in /Volumes/Data/mongodb by default. I tried editing the mongod.conf file, and I have
storage:
dbPath: /Volumes/Data/mongodb
However, whenever I run 'mongod', it gives me the message:
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
If I give mongod the --dbpath argument, it works fine, but I want it to work by default. Why does it appear that my mongod.conf file is not obeyed. Searching on google, it seems the conf file in installed in different locations depending on OS and install method. Running db.serverCmdLineOpts() gives:
{
"argv" : [
"/usr/local/opt/mongodb/bin/mongod",
"--config",
"/usr/local/etc/mongod.conf"
],
"parsed" : {
"config" : "/usr/local/etc/mongod.conf",
"net" : {
"bindIp" : "127.0.0.1"
},
"storage" : {
"dbPath" : "/Volumes/Data/mongodb"
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "/usr/local/var/log/mongodb/mongo.log"
}
},
"ok" : 1
}

Notes
The path must exist. It doesn't get created automagically.
/Volumes is sort of a reserved directory for mounting drives and bundles and shouldn't be worked on directly.
In case you use a volume or (sparse) bundle, you need to make sure it is mounted on boot or you have to do it manually before starting MongoDB.
Basically, there are two places to put MongoDB data in OS X. Sadly, neither brew nor MacPorts obey the File Hierarchy Standard*, which is also adopted by the BSD which is the foundation of OS X.
Solution 1: You want the data accessible by all users of OS X
Since mongod is run from /usr/local subtree, so this is our parent. But since variable data belongs to /var we need to use the local tree there. So our base path for the data is /var/local/lib. It is mongoldb data, so you can either put it into mongo (because of the package basename) or mongodb (because of the vendor name) or even mongod (because of the daemon name). That's basically a matter of taste, but I'd stick with the vendor. So your dbpath would be /var/local/lib/mongodb.
Solution 2: Only you will access the data
Put the data into your home directory.
Well, basically you can do what you want there, but in general I'd put data into a hidden directory (prefixed with a dot) so that it does not clutter your Finder. Something like $HOME/.mongodb
This solution isn't really clean, since the software will run from a public subtree and the data is stored in a user directory.
Extension to both solutions
If you want to put your data into a volume or (sparse) bundle, simply create a symlink from the correct location to the volume, simply create a symlink instead of creating a directory. Example for solution 1:
sudo ln -s /Volumes/YourVolume /var/local/lib/mongodb
* Well, it is to argue that since MacPorts installs under /opt, it technically does (though imho it would rather belong to /usr/local in the first place)

AFAIK, mongod needs to be configured before working. There are 2 ways to specify configurations.
by command line arguments. which is the --dbpath parameter you added. for example:
mongod --dbpath /Volumes/Data/mongodb
by specifying a config file. Usually if you install from source, it comes with one at /etc/mongod.conf (varies depends on different Linux distributions). Where you can specify all the parameters in it.
By saying
I want it to work by default
I assume you mean you want to start daemon on system reboot. So the config file you are actually using is specified in the daemon script. For example in CentOS you can find daemon script in /etc/init.d/mongod, where the line
CONFIGFILE="/etc/mongod.conf"
decides which config file you are using. So you may want to find your daemon script and check it first.
If this is not your situation, maybe you just downloaded mongodb from somewhere and unzipped it to your system, and you start mongodb with nothing but:
mongod
This way I guess the default location of mongod.conf is decided by the compiling parameters. Which means if you want to change it, you'll have to download the source code and compile it yourself.

Related

Is there any way to inspect the contents of the RocksDB instance used by NEAR Protocol?

Disclosure: I work with NEAR and am currently on-boarding.
When I start up a local node on a clean machine I see that a .near folder is created in my home directory with a few configuration files (exact files seem to depend on which start_ script I run). Another folder appears inside of the .near folder called data.
Running strings ~/.near/data/*.sst in the folder spits out a few lines starting with the string "rocksdb" which led me to this reference to RocksDB
Is there any way to inspect the contents of a node's RocksDB instance?
I found Keylord but it crashes when I try to configure a new connection to the database (by pointing the connection to ~/.near/data). I didn't pursue that thread.
PSA1: sometimes it's useful to backup the ~/.near folder between node restarts if you want to reset the environment or avoid reusing old data while troubleshooting
mv ~/.near ~/.near_`date +%Y-%m-%d.%s`
PSA2: on MacOS you can watch what happens to the contents of the ~/.near folder while the node boots up and runs. (brew install watch).
watch -d -c -n 0.5 find ~/.near
The content of RocksDB is serialized using our own binary serialization format (http://borsh.io/), so you won't be able to examine the content with general-purpose third-party tools

Where files are allocated in Parse Server?

I'm implementing an instance of Parse Server, I want know where the Parse Server Allocated the files ?
According to File Adapter, the default file storage is GridFS in mongodb.
Depends on the operating system and type of installation you used.
If installed on a linux/unix using the global install npm install -g parse-server mongodb-runner then your parse-server files will normally be under usr/lib/node_modules/parse-server. ( may differ from linux versions )
be careful when editing these files for hot hacks or modifications. If you later choose to upgrade parse-server they will be overwritten.
Your cloud file directly is normally created by you. So this could be home/parse/cloud/main.js. This can be in any location of your choice. To set a new location you will set that in the index file or json (depending on your startup process ).
cloud: '/home/myApp/cloud/main.js', // Absolute path to your Cloud Code
If you installed not using the global install, then obviously you would need to cd to where you cloned the project.
Windows would be similar. Clone (or download the zip) parse-server from the repo. Open a console window and “cd” to the folder where you have cloned/extracted the example server, eq:
cd "C:\parse-server"
Here is where the files will sit on the parse-server. Hopes this helps!

RabbitMQ installation on Mac

Sorry for this noob-questions. Here written:
Contained in the tarball is a directory named rabbitmq_server-3.3.5.
You should extract this into somewhere appropriate for application
binaries on your system.
Where it is? sbin, usr/bin, bin or something else? So, every time on startup I need to go to that path and command:
sbin/rabbitmq-server -detach
Or I can do it like this:
rabbitmq-server -detach
Thanks!

Vagrant file structure and web root

I've read the docs and a few things still confuse me, mostly related to sync folders and database data.
I want to use the following folder structure on my host machine
ROOT
|- workFolder
||- project1
|||- project1DatabaseAndFiles
|||- project1WebRoot
||- project2
|||- project2DatabaseAndFiles
|||- project2WebRoot
||- project3
|||- project3DatabaseAndFiles
|||- project3WebRoot
And then create VM's where each VM host webroot points to the appropriate projectX/projectXWebRoot folder.
From what I've read, I can only specify one remote Sync DIR. (http://docs.vagrantup.com/v2/synced-folders/). But if I create a new VM I want to specify the project name too, thereby selecting the correct host folder.
Is what I'm describing possible using Vagrant?
If I wanted another developer to use this environment, I'd like for them to have instant access to the database structure/setup etc without having to import any SQL files. Is this possible?
I'm hoping I'm just not understanding Vagrants purpose, but this seems like a good use of shared VM's to me. Any pointers or articles that might help would be very welcome.
From what I've read, I can only specify one remote Sync DIR.
No that is not true. You can always add more shared folders. From the
manual:
This directive is used to configure shared folders on the virtual machine and may be used multiple times in a Vagrantfile.
This means you can define additional shared folders using:
config.vm.share_folder "name", "/path/on/vm", "path/on/host"
If I wanted another developer to use this environment, I'd like for them to have instant access to the database structure/setup etc without having to import any SQL files. Is this possible?
Yes, you can alter the data storage path of, say, MySQL to store it in on a share on the host so that
the data is not lost when the VM is destroyed.
However, this is not as simple as it sounds. If you're using the MySQL cookbook (again, assuming you're using MySQL), you have to modify it so that the shared folder is mounted with the uid and gid of the mysql user or otherwise the user can't write to it. You can mount a share manually like this:
mount -t vboxsf -o uid=`id -u mysql` -o gid=`id -g mysql` sharename /new/data/dir
Also, if you're using Ubuntu or Debian Wheezy, Apparmor needs to be configured differently for MySQL,
as it does not allow writes to the newly configured data directory. This can be done by writing
/new/data/dir r,
/new/data/dir/** rwk,
to /etc/apparmor/apparmor.d/local/usr.sbin.mysqld. This version of the mysql cookbook supports this behaviour already, so you can look up how it does that.

How can I move MySQL data directory on Mac OS 10.5? (and related questions)

I've managed to mess up my MySQL database (on Mac OS X 10.5) and need help recovering!
I tried to add an index to a fairly large table (190 million records) and in the course of this, I ran out of disk space. Subsequently realized that the partition with the data directory is too small and so I need to move it.
Initially I thought that I would just copy the data directory to another location, then bung a symlink in place of the original data directory.
BUT it refuses to move!
sudo cp -r /usr/local/mysql/data .
cp: ./data: Permission denied
(I have stopped the mysqld process before attempting this move)
Help!
This isn't a mysql question, but rather an OS question.
I would guess that you either don't have permission to write to the current directory, or there's already a directory there named 'data' that you don't have permission on, etc.
In my experience, MySQL doesn't like running out of disk space at all. Make sure the last records are OK after you bring the engine back up.
Also, don't use the symlink - change the mysql config. In Unix, this would be the 'datadir' setting in /etc/my.cnf.

Resources