About Me

My photo
I am an MCSE in Data Management and Analytics, specializing in MS SQL Server, and an MCP in Azure. With over 19+ years of experience in the IT industry, I bring expertise in data management, Azure Cloud, Data Center Migration, Infrastructure Architecture planning, as well as Virtualization and automation. I have a deep passion for driving innovation through infrastructure automation, particularly using Terraform for efficient provisioning. If you're looking for guidance on automating your infrastructure or have questions about Azure, SQL Server, or cloud migration, feel free to reach out. I often write to capture my own experiences and insights for future reference, but I hope that sharing these experiences through my blog will help others on their journey as well. Thank you for reading!

Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted

Error:-

Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted 
and mongoDB Service was not starting after upgrade.. 



I had an unclean upgrade of MongoDB from 3.2.12 to 3.4.2  on Ubuntu 16.04 LTS. 

I reinstalled MongoDB enterprise with below steps..

1.Import the public key used by the package management system.


sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

2.Create a /etc/apt/sources.list.d/mongodb-enterprise.list file for MongoDB.

echo "deb [ arch=amd64,arm64,ppc64el,s390x ] http://repo.mongodb.com/apt/ubuntu xenial/mongodb-enterprise/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list



3.Reload local package database

sudo apt-get update

4.Install the MongoDB Enterprise packages.

sudo apt-get install -y mongodb-enterprise

When i executed below command to start MongoDB i got below error in

 /var/log/mongodb/mongod.log

sudo service mongod start


Now when I login as root and run Mongodb via service mongodb start, I get below error in Log folder 

***aborting after fassert() failure


2017-02-05T12:04:58.949+0530 I CONTROL  [main] ***** SERVER RESTARTED *****
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] MongoDB starting : pid=21525 port=27017 dbpath=/var/lib/mongodb 64-bit host=ubuntu
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] db version v3.2.12
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] git version: ef3e1bc78e997f0d9f22f45aeb1d8e3b6ac14a14
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips  1 Mar 2016
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] modules: none
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] build environment:
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten]     distarch: x86_64
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2017-02-05T12:04:58.953+0530 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-02-05T12:04:58.974+0530 E NETWORK  [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-02-05T12:04:58.974+0530 I -        [initandlisten] Fatal Assertion 28578
2017-02-05T12:04:58.974+0530 I -        [initandlisten]

***aborting after fassert() failure

Resolution:-

in order to solve this issue, i executed below command

sudo chown mongodb:mongodb /tmp/mongodb-27017.sock
After executing this command when i restarted mongodb service, it started successfully.
This you can also notice when you type netstat -plntu
you will notice 127.0.0.1:27017   23462/mongod
root@ubuntu:~# sudo service mongod start
root@ubuntu:~# netstat -plntu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:27017         0.0.0.0:*               LISTEN      23462/mongod
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      4988/sshd
tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN      5049/sqlservr
tcp        0      0 127.0.0.1:1434          0.0.0.0:*               LISTEN      5049/sqlservr
tcp6       0      0 :::22                   :::*                    LISTEN      4988/sshd
udp        0      0 0.0.0.0:68              0.0.0.0:*                           4944/dhclient
root@ubuntu:~#

and the log file will appear like:-

***aborting after fassert() failure


2017-02-05T12:29:33.223+0530 I CONTROL  [main] ***** SERVER RESTARTED *****
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] MongoDB starting : pid=23462 port=27017 dbpath=/var/lib/mongodb 64-bit host=ubuntu
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] db version v3.4.2
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips  1 Mar 2016
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] allocator: tcmalloc
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] modules: enterprise 
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] build environment:
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten]     distmod: ubuntu1604
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten]     distarch: x86_64
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten]     target_arch: x86_64
2017-02-05T12:29:33.228+0530 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2017-02-05T12:29:33.248+0530 I -        [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] 
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1321M,session_max=20000,eviction=(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-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] 
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] 
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] 
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] 
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] 
2017-02-05T12:29:34.312+0530 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2017-02-05T12:29:34.312+0530 I NETWORK  [thread1] waiting for connections on port 27017
Now mongoDB started with..
root@ubuntu:~# mongo
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
Server has startup warnings:
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten]
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-02-05T12:29:33.248+0530 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten]
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten]
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten]
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten]
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2017-02-05T12:29:34.275+0530 I CONTROL  [initandlisten]
MongoDB Enterprise >

Now i notice that MongoDB server version is 3.4.2
Thanks for reading..