In order to get sharding to work I need to run two copies of mongod.exe. One as a shard and one as the config server. How can I install both mongod instances as windows services?
The following command line will install a 2nd instance of Mongo DB. Note that you have to provide serviceName, serviceDisplayName, port, dbpath and logpath in order to avoid collisions.
mongod --install --serviceName "Mongo DB 2nd instance" --serviceDisplayName "Mongo DB 2nd instance" --port 37017 --dbpath c:\data\db2 --logpath c:\data\logs\mongolog2.txt
Then you just start the service with
net start "Mongo DB 2nd instance"
Use sc.exe from the Windows Resource Kit ( http://support.microsoft.com/kb/251192 ) which allows you to specify an unique display name for each instance:
sc.exe create "Mongo DB 1" binPath= "c:\mongodb\bin\mongod.exe --service --dbpath=c:\data\db --logpath=c:\data\log.txt"
create a new config file with different port, db location, etc.. and save as mongod2.cfg
mongod --install --serviceName 'Mongo DB 2nd instance' --serviceDisplayName 'Mongo DB 2nd instance' -f 'C:\Program Files\MongoDB\Server\4.4\bin\mongod2.cfg'
need to use full path to the new config file
this will install as service and you can edit all configurations, like the main instance
Mongo added a --serviceDisplayName flag in 1.8
Related
I am trying to create scale-able docker container running an Elixir node. Currently I have this:
client:
image: elixir:alpine
command:
elixir --name client#somewhere.localdomain --cookie pass
-S mix run --no-halt -e Connect.main ${CONTROLLER}
depends_on:
- system_control
The elixir node is just using Node.connect to inform the controller of its existence. However, if I try creating more client nodes with docker-compose up --scale client=5 then only the first one is able to connect and the rest are refused (presumably) because of name clashes caused by the hardcoded --name. Any idea how to circumvent it? Is there a way of getting some unique id to be used instead of somewhere?
Edit: my Connect.main elixir script is (abridged) this:
defmodule Connect do
def main do
[server] = System.argv
IO.puts "#{Node.self} - Connecting to #{server} - #{ Node.connect(:'#{server}') }
end
end
Assigning a name with a randomized component should solve your problem. Make sure it is random enough that duplicates are highly improbable. You might want to avoid sequential IDs in some cases as suggested in this Docker-Compose issue
As #fl9 suggested, using some kind of command line UUID generator like uuidgen might be able to do the trick.
I'm using Linux 16.04 OS. I have installed fresh neo4j. I get referenced exegetic and digitalocean sites.
By default there's graph.db database.
My question is how to create a new database and create nodes and
relation ship between nodes?
As I show in picture default DB name is graph.db.
Since you're using Neo 3.x, to create a new database without removing your existing one, you can simply edit the neo4j.conf file in your conf directory of your $NEO4J_HOME.
Search for dbms.active_database=, which should have the default value of graph.db. Replace it with some other name and start neo4j again. Now, a new database will be created under that directory name. To switch back to your previous db, repeat the steps, just replace your new value with graph.db in the configuration file.
Neo Technology has come with a new Desktop Tool that greatly improves productivity called Neo4J Desktop. You can download it here
Using it you can manage different projects, create different databases, and simply manage them / switch between them, using the GUI.
Really saves a lot of time.
Apparently in Community Edition you only have 1 database, so I used docker containers to create one server per db. Modify the ports + data volume as shown below:
docker run \
--rm \
--publish=8474:7474 --publish=8687:7687 \
--volume=$HOME/neo4j/data2:/data \
--volume=$HOME/Downloads/neo4j/import:/var/lib/neo4j/import \
--name=neo4j \
--env NEO4J_AUTH=neo4j/password \
neo4j:3.4
# Defaults:
# --publish=7474:7474 --publish=7687:7687 \
# --volume=$HOME/neo4j/data:/data \
In the documentation of Neo4j
Community Edition is a fully functional edition of Neo4j, suitable for
single instance deployments. It has full support for key Neo4j
features, such as ACID compliance, Cypher, and programming APIs. It is
ideal for learning Neo4j, for do-it-yourself projects, and for
applications in small workgroups.
So you only have one database instance.
If you want to get started with Neo4j there is a section in the community edition called "jump into code." There is a wizard to tell you how to get started with their language "Cypher."
To create a new Neo4j database in Unix Environment, the following steps are needed:
first, the configuration file of neo4j exists in the following location:
cd /etc/neo4j (ls ---> neo4j.config);
access the file using vim: sudo vim neo4j.config;
edit the following (by pressing i (for insert)):
there is a commented assignment (at the beginning) which is:
#dbms.active_database=graph.db; remove the comment and add the name of the folder containing the database that you want to create and directly add its location before graph.db
i.e: dbms.active_database=new_db/graph.db; press: Esc + :wq (to save the modification)
After executing sudo service neo4j start, you will see that the activated database is new_db/graph.db
if you want to check that everything went fine, follow these steps:
go to: cd /var/lib/neo4j;
execute: ls (you will have certificates, plugins, data, import); then go to: cd data/databases; then execute ls :you will notice that you have the old database (graph.db), and the new folder new_db that contains also the new_created database graph.db
Remarks:
Neo4j is developed for single database use, and all the manipulations are performed on a single database.
If you want to clear the database, you can go to the location of graph.db and erase everything since doing that from neo4j is very difficult and most of times, you will forget to delete dependencies, labels, ...
i.e : say, we want to clear the new created database graph.db that exists in the folder new_db:
we go to : cd ..../new_db;
execute ls (you will have graph.db);
execute: sudo rm -rf graph.db/*;
Last remark, if you want to access the default database, you just recomment the assignment that you edited
The process is a little tricky in case of causal cluster.
First, stop all the neo4j instances across the VMs in your cluster
sudo systemctl stop neo4j
DB location on Linux machines = /var/lib/neo4j/data/databases
To delete existing db : rm -rf /database/graph.db
Edit new DB name under the template
Search for dbms.active_database=, which should have the default value of graph.db . Replace it with a new DB. On the restart, neo4j will automatically create it.
Remember to UNCOMMENT the line.
Unbind all the nodes — this clears the cluster state and forces the node to freshly join the cluster.
neo4j-admin unbind
Now, this is really important and most people are unaware of this.
Now go ahead and start neo4j instances in all the nodes one by one. This should create new DBs across and you’ll see the nodes joining the cluster.
sudo systemctl start neo4j
Check logs using
journalctl -unit=neo4j -r
OR
sudo systemctl status neo4j
When I am using PostgreSQL, I am accustomed to use terminal for browsing data stored in DB tables.
Is there any similar way to do it for MongoDB? I have used this topic for MongoDB installation on Mac.
Thanks
MongoDB bin directory contains an executable called 'mongo' which is an interactive shell (similar to 'psql' in PostgreSQL)
You can read more about how to use it HERE.
To get started, you can type
> help
To switch to a specific database, just type:
> use db-name
^^^^^^^ replace with your db name.
> db.help()
> db.collectionName.help()
^^^^^^^^^^^^^^ replace with your collection name
You can do this from any machine not just the one mongod is running on but then you connect via:
mongo hostname:port/dbname
for example
mongo myMongoDBserver:27017/foobardb
First start mongod process in a terminal tab. In other terminal tab or window simply start mongo.
mongod is mongo daemon which establishes connections and listens to requests. mongo is the javascript shell where you can have your interactive mongodb queries.
Rest is best explained in the link #Asya Kamsky provided in his answer.
command 'mongo' will open mongo shell for you, there you can use database commands
I'm using Memcached-for-Windows, see:
http://blog.elijaa.org/index.php?post/2010/08/25/Memcached-1.4.5-for-Windows&similar
I've tried to use:
sc create "memcached" binPath="C:/memcached/mem
cached.exe" start=auto
but I can't create the Windows service, and no warning or error, just:
Creates a service entry in the registry and Service Database.
SYNTAX:
sc create [service name] [binPath= ] <option1> <option2>...
CREATE OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec>
(default = own)
start= <boot|system|auto|demand|disabled>
(default = demand)
error= <normal|severe|critical|ignore>
(default = normal)
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
(default = LocalSystem)
DisplayName= <display name>
password= <password>
To implement this, you can even execute a command line, which inturn creates a service.
First go to the path where the .exe file exists through command line.
C:\Users\sireesh.yarlagadda>memcached.exe -d install
After executing this line, you will be seeing a new service created for memcached
The reason you're getting an error is that there must be a space after the binPath= . This is a very annoying 'feature' of sc. Also you'd need a space after the start=.
sc create "memcached" binPath= "C:/memcached/memcached.exe" start= auto
The above command wouldn't give you the syntax error. However, I suspect memcached still won't run successfully as a service.
memcached isn't a native Windows Service so you must use a "service wrapper" program to add the missing functionality. Microsoft's free Srvany utility should do the trick but several commercial alternatives are also available.
(Note that some Windows ports of memcached support the "-d" flag to automatically install and manipulate memcached as a native Windows Service but that doesn't seem to be available in NorthScale's version...)
You can build Memcached on Windows.
http://vasil9v.tumblr.com/post/31921755331/compiling-memcached-on-cygwin-windows
i try to start multiple Instance of MongoDB as a Service. Under the commandline i can start more than one Mongo Instances, for the first instance i append "--install" to the Command and now it run as service. But now i try to append "--install" to the second Instance and get a Error:
first command runs well:
c:\data\bin\mongod --nohttpinterface --port 27201 --dbpath c:\data\cluster\db1 --master --logpath c:\var\log\mongodb_db1.log --serviceName MongoDB_1 --install
but the second one gives a error:
c:\data\bin\mongod --nohttpinterface --port 28000 --dbpath c:\data\cluster\db2 --master --logpath c:\var\log\mongodb_db2.log --serviceName MongoDB_2 --install
error:
Creating service MongoDB_2. Error creating service. Der Name wird bereits als Dienstname oder als Dienstinstanzname verwendet. (1078)
I think that MongoDB use an internal Servicename that is always the same and differ to the shown servicename. But i don't know how to fix it?
Any suggestions?
Regards
Rene
You can do a polite installation of a 2nd instance using the proper command line switches. Just read my answer here https://stackoverflow.com/a/9273816/249992
I ran into this same issue. My workaround is kind of hacky, but it seems to work:
Create the first mongod service using monogd --install
Open regedit and navigate to HKLM\SYSTEM\CurrentControlSet\services\NameOfMongoService
Export this key
Edit exported reg file in text editor, updating service name and mongod params.
Import into reg (and possibly reboot).
To get mongos running as a service I took a different approach and used instsrv and srvany from the Windows NT Resource Kit:
http://support.microsoft.com/kb/137890
This kb doesn't mention that after intstalling srvany using instsrv you have to add a Parameters sub-key under the newly created service in the registry. This key should contain a REG_SZ named "Application" with the path to the app to start as a service.