Deploy a replica set problem

user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/1 --keyFile /var/mongodb/pki/m103-keyfile --port 27001 --auth
2022-09-23T04:51:26.534+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-09-23T04:51:26.588+0000 I CONTROL  [initandlisten] MongoDB starting : pid=323 port=27001 dbpath=/var/mongodb/db/1 64-bit host=qchgbZsMcW4kSse282
2022-09-23T04:51:26.588+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-09-23T04:51:26.588+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten] allocator: system
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten] modules: none
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten] build environment:
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-09-23T04:51:26.589+0000 I CONTROL  [initandlisten] options: { net: { port: 27001 }, replication: { replSet: "m103-repl" }, security: { authorization: "enabled", keyFile: "/var/mongodb/pki/m103-keyfile" }, storage: { dbPath: "/var/mongodb/db/1" } }
2022-09-23T04:51:26.591+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=256M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2022-09-23T04:51:27.568+0000 I STORAGE  [initandlisten] WiredTiger message [1663908687:568922][323:0x7fef6895bca8], txn-recover: Set global recovery timestamp: 0
2022-09-23T04:51:27.574+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] 
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server. 
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP 
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2022-09-23T04:51:27.595+0000 I CONTROL  [initandlisten] 
2022-09-23T04:51:27.602+0000 I STORAGE  [initandlisten] createCollection: local.startup_log with generated UUID: 549784e2-32e5-4bdd-9e4a-3be48fb4ad4f
2022-09-23T04:51:27.614+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/mongodb/db/1/diagnostic.data'
2022-09-23T04:51:27.615+0000 I STORAGE  [initandlisten] createCollection: local.replset.oplogTruncateAfterPoint with generated UUID: e14c78de-3b82-4284-973f-2dede54460ff
2022-09-23T04:51:27.625+0000 I STORAGE  [initandlisten] createCollection: local.replset.minvalid with generated UUID: 697fa45c-74c4-4193-bec7-e35430655d70
2022-09-23T04:51:27.637+0000 I REPL     [initandlisten] Did not find local voted for document at startup.
2022-09-23T04:51:27.637+0000 I REPL     [initandlisten] Did not find local Rollback ID document at startup. Creating one.
2022-09-23T04:51:27.637+0000 I STORAGE  [initandlisten] createCollection: local.system.rollback.id with generated UUID: 43f3c92e-2e87-4129-bed9-4c3aca33c7da
2022-09-23T04:51:27.647+0000 I REPL     [initandlisten] Initialized the rollback ID to 1
2022-09-23T04:51:27.647+0000 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2022-09-23T04:51:27.648+0000 I NETWORK  [initandlisten] waiting for connections on port 27001
2022-09-23T04:51:27.655+0000 I CONTROL  [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
2022-09-23T04:51:27.680+0000 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
1 Like

Have you started other 2 nodes and ran rs.initiate() and rs.add on primary port?

no,
first i tried to create 1st node with above command

It says waiting for connections
As long as your mongod came up fine it is ok
Try to connect to your mongod and see what it says

1st command i typed is the above command

user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/1 --keyFile /var/mongodb/pki/m103-keyfile --port 27001 --auth --fork
2022-09-23T07:26:07.733+0000 F CONTROL [main] Failed global initialization: UnknownError: Cannot get current working directory: No such file or directory

this is the 1st command

Correct but I am asking to connect to your mongod instance
Your first snapshot shows you started mongod in foreground
And your latest snapshot it was started with fork but without logpath.Logpath is must if you use fork
If you starting mongod again make sure your previous mongod is stopped as you cannot have 2 mongods running on same port simultaneously

If you are facing issues reset workspace and try fresh exactly as your lab asked you

user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/1 --keyFile /var/mongodb/pki/m103-keyfile --port 27001 --auth --logpath /var/mongodb/logs/mongod1.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 368
child process started successfully, parent exiting
user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/2 --keyFile /var/mongodb/pki/m103-keyfile --port 27002 --auth --logpath /var/mongodb/logs/mongod2.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 405
child process started successfully, parent exiting
user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/3 --keyFile /var/mongodb/pki/m103-keyfile --port 27003 --auth --logpath /var/mongodb/logs/mongod3.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 437
child process started successfully, parent exiting

now what should i do

Connect to mongod on port 27001
Run rs.initiate() then add other 2 nodes to your replica

user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/1 --keyFile /var/mongodb/pki/m103-keyfile --port 27001 --auth --logpath /var/mongodb/logs/mongod1.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 345
child process started successfully, parent exiting
user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/2 --keyFile /var/mongodb/pki/m103-keyfile --port 27002 --auth --logpath /var/mongodb/logs/mongod2.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 378
child process started successfully, parent exiting
user@M103# mongod --replSet m103-repl --dbpath /var/mongodb/db/3 --keyFile /var/mongodb/pki/m103-keyfile --port 27003 --auth --logpath /var/mongodb/logs/mongod3.log --fork
about to fork child process, waiting until server is ready for connections.
forked process: 410
child process started successfully, parent exiting
user@M103# mongod --port 27001
2022-09-23T10:07:24.424+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] MongoDB starting : pid=440 port=27001 dbpath=/data/db 64-bit host=TThd0vyUZIUekWDe0X
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] db version v4.0.5
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] allocator: system
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] modules: none
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] build environment:
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] distarch: x86_64
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] target_arch: x86_64
2022-09-23T10:07:24.431+0000 I CONTROL [initandlisten] options: { net: { port: 27001 } }
2022-09-23T10:07:24.432+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2022-09-23T10:07:24.432+0000 I CONTROL [initandlisten] now exiting
2022-09-23T10:07:24.432+0000 I CONTROL [initandlisten] shutting down with code:48
user@M103# mongod --config mongod.conf --dbpath /var/mongodb/db/1 --port 27001 --logpath /var/mongodb/logs/mongod1.log --fork
Error reading config file: No such file or directory
try ‘mongod --help’ for more information

cant connect to port

Please review your lectures
mongod is used to start mongod daemon
mongo is used to connect to a mongod instance
You have to connect using
mongo --port port_number
Replace port_number with whichever port you want to connect

1 Like

thank you very much ,
it worked…

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.