May I use transaction in an stand alone win server with node?

Hi there, It´s my first time here …
I use one lab to learn and I need to use transactions to insert data in 2 diferent collections, but since yesterday I´m trying and this error message pops in my screen … “Transaction numbers are only allowed on a replica set member or mongos”. I already tryed the node university video and copy the code with my data, and all others internet sources, but i have no success.
I am using an stand alone windows with node (all updated). Is it possible to use transactions in my environment? how ?
ps- I tryed to set up the replication in cfg file, but when I do it the mongo service does not run anymore. ( I also set up the security: authorization enable)

1 Like

Post the Config File? I got some time to kill if you’d like me to look at it.

1 Like

mongod.conf

for documentation of all options, see:

http://docs.mongodb.org/manual/reference/configuration-options/

Where and how to store data.

storage:
dbPath: C:\Program Files\MongoDB\Server\6.0\data
journal:
enabled: true

engine:

wiredTiger:

where to write logging data.

systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server\6.0\log\mongod.log

network interfaces

net:
port: 27017
bindIp: 127.0.0.1

#processManagement:

security:
authorization: enabled

#operationProfiling:

#replication:

#sharding:

Enterprise-Only Options:

#auditLog:

#snmp:

@Gustavo_Castro

So it looks like you’re trying to do this for a standalone instance, so do the following:

  • Stop the service.

  • Build a new config file like this (add more fields but this is the minimum you have to have):
    systemLog:
    destination: file
    path: “mongod.log”
    storage:
    dbPath: “M:\data\db”
    replication:
    replSetName: “replicaSetName”

  • Start it with the config file.

mongod --config "M:\path\mongod.cfg"

  • Turn on the replica set
mongo
> rs.initiate()

  • Check Replica State
> rs.status()

Let me know if this works out for you.

EDIT

@Gustavo_Castro We want to build this with the bare minimum we need, so that way we can narrow down where the configuration is failing.

1 Like

This is a bit surprising to me. I thought transactions are also available in a standalone node.
Just use a single node replica set for it.