Issue with Mongodb 3.4 installation on Ubuntu 16.04 64bit

1,688 views
Skip to first unread message

William Leung

unread,
Aug 20, 2017, 2:17:58 AM8/20/17
to mongodb-user
I'm running this installation on a Ubuntu VirtualBox on Windows 10. 
I followed the steps to install mongodb: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ 
Basically, these steps:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org

After the command, 
sudo service mongod start 

I did not get a return statement

Here is the command line returned: 
whale@whale-VirtualBox:~$ sudo service mongod start
whale@whale-VirtualBox:~$ sudo mongod
2017-08-19T22:43:46.360-0700 I CONTROL  [initandlisten] MongoDB starting : pid=5778 port=27017 dbpath=/data/db 64-bit host=whale-VirtualBox
2017-08-19T22:43:46.360-0700 I CONTROL  [initandlisten] db version v3.4.7
2017-08-19T22:43:46.360-0700 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten] modules: none
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten] build environment:
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten]     distarch: x86_64
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2017-08-19T22:43:46.361-0700 I CONTROL  [initandlisten] options: {}
2017-08-19T22:43:46.437-0700 E NETWORK  [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-08-19T22:43:46.437-0700 E NETWORK  [initandlisten]   addr already in use
2017-08-19T22:43:46.437-0700 E NETWORK  [initandlisten] Failed to set up sockets during startup.
2017-08-19T22:43:46.437-0700 E STORAGE  [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets
2017-08-19T22:43:46.437-0700 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2017-08-19T22:43:46.437-0700 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2017-08-19T22:43:46.437-0700 I CONTROL  [initandlisten] now exiting
2017-08-19T22:43:46.437-0700 I CONTROL  [initandlisten] shutting down with code:48
whale@whale-VirtualBox:~$ sudo service mongod status
[sudo] password for whale: 
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2017-08-19 22:41:50 PDT; 21min ago
  Process: 5762 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 5762 (code=exited, status=48)

Aug 19 22:41:50 whale-VirtualBox systemd[1]: Started High-performance, schema-free document-oriented database
Aug 19 22:41:50 whale-VirtualBox systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Aug 19 22:41:50 whale-VirtualBox systemd[1]: mongod.service: Unit entered failed state.
Aug 19 22:41:50 whale-VirtualBox systemd[1]: mongod.service: Failed with result 'exit-code'.
lines 1-11/11 (END)...skipping...
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2017-08-19 22:41:50 PDT; 21min ago
  Process: 5762 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 5762 (code=exited, status=48)

Rhys Campbell

unread,
Aug 20, 2017, 12:35:33 PM8/20/17
to mongodb-user
You have another process listening on the port mongo is trying to bind to;

2017-08-19T22:43:46.437-0700 E NETWORK  [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017
2017-08-19T22:43:46.437-0700 E NETWORK  [initandlisten]   addr already in use

Most likely another mongo process.

Message has been deleted

William Leung

unread,
Aug 20, 2017, 5:02:25 PM8/20/17
to mongodb-user
Ok, so I believe running
sudo service mongod start

Starts listening for port 0.0.0.0:27017

I did the following and it worked.
sudo service mongodb stop

sudo mongod

Now, I'm wondering what is the difference between
sudo mongod
and
sudo service mongodb start


If i run

sudo service mongodb start

why am i getting active: failed, I should be getting a return status after sudo service mongod start , I get nothing.

whale@whale-VirtualBox:~$ sudo service mongod start
whale@whale-VirtualBox:~$ sudo service mongod status

● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2017-08-20 13:55:44 PDT; 3s ago
     Docs: https://docs.mongodb.org/manual
  Process: 4614 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=48)
 Main PID: 4614 (code=exited, status=48)

Aug 20 13:55:44 whale-VirtualBox systemd[1]: Started High-performance, schema-free document-oriented database.
Aug 20 13:55:44 whale-VirtualBox systemd[1]: mongod.service: Main process exited, code=exited, status=48/n/a
Aug 20 13:55:44 whale-VirtualBox systemd[1]: mongod.service: Unit entered failed state.
Aug 20 13:55:44 whale-VirtualBox systemd[1]: mongod.service: Failed with result 'exit-code'.

where

sudo mongod

gives me this

whale@whale-VirtualBox:~$ sudo service mongod stop
whale@whale-VirtualBox:~$ sudo mongod

2017-08-20T13:42:54.282-0700 I CONTROL  [initandlisten] MongoDB starting : pid=4209 port=27017 dbpath=/data/db 64-bit host=whale-VirtualBox
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] db version v3.4.7
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] modules: none
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] build environment:
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten]     distarch: x86_64
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2017-08-20T13:42:54.283-0700 I CONTROL  [initandlisten] options: {}
2017-08-20T13:42:54.631-0700 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-08-20T13:42:54.631-0700 I STORAGE  [initandlisten]
2017-08-20T13:42:54.631-0700 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-08-20T13:42:54.631-0700 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-08-20T13:42:54.631-0700 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=778M,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten]
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten]
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten]
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-08-20T13:42:55.171-0700 I CONTROL  [initandlisten]
2017-08-20T13:42:55.206-0700 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2017-08-20T13:42:55.207-0700 I NETWORK  [thread1] waiting for connections on port 27017

Wan Bachtiar

unread,
Aug 23, 2017, 7:36:41 PM8/23/17
to mongodb-user

I did not get a return statement

Hi William,

You shouldn’t be expecting an output from Ubuntu 16.04 service mongod start, if you would like to know the status you should instead execute sudo service mongod status
Example status output:

● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-08-24 09:26:26 AEST; 2s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 14321 (mongod)
   CGroup: /system.slice/mongod.service
           └─14321 /usr/bin/mongod --config /etc/mongod.conf

[initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017

This is because mongod was executed twice, first using sudo service mongodb start and afterward sudo mongod ; both tried to bind on the same port number 27017 (default). See also guide Ubuntu: Run MongoDB.

Now, I’m wondering what is the difference

One of the differences that you can see from the output of status, is that service mongod executes the equivalent of /usr/bin/mongod --config /etc/mongod.conf. You can check the default content of /etc/mongod.conf for more information. Please see also MongoDB Configuration Options file.

If you would like to know more about the differences between executing a command via service or directly, I would recommend to ask/browse on Ask Ubuntu Forum as it would be more related to Ubuntu than MongoDB.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages