mongo_upgrade_logical

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mongo_upgrade_logical [2019/09/16 10:39] andonovjmongo_upgrade_logical [2019/10/25 23:28] (current) – external edit 127.0.0.1
Line 80: Line 80:
 </sxh> </sxh>
  
 +=====Instance Modifcations=====
 +There are couple changes to be done in order to secure our databases:
 +
 +====Change the IP====
 +In order to change the IP, modify the /etc/mongod.conf file as so:
 +
 +<sxh bash>
 +# network interfaces
 +net:
 +  port: 27017
 +  bindIp: 172.27.1.245  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
 +</sxh>
 +
 +Restart the instance with:
 +
 +<sxh bash>
 +[root@hostname hunter_dev]# service mongod restart
 +Redirecting to /bin/systemctl restart mongod.service
 +</sxh>
 +
 +====Add users====
 +Users have to be added so we can enable security authentication:
 +
 +<sxh bash>
 +[root@tbp-cx-mdb01 hunter_dev]# mongo 172.27.1.245
 +MongoDB shell version v4.0.13
 +connecting to: mongodb://172.27.1.245:27017/test?gssapiServiceName=mongodb
 +Implicit session: session { "id" : UUID("4c9e2e3d-4224-4731-89ad-3a2cca29110a") }
 +MongoDB server version: 4.0.13
 +Server has startup warnings:
 +2019-10-25T15:48:26.654+0200 I STORAGE  [initandlisten]
 +2019-10-25T15:48:26.655+0200 I STORAGE  [initandlisten] ** WARNING: Support for MMAPV1 storage engine has been deprecated and will be
 +2019-10-25T15:48:26.655+0200 I STORAGE  [initandlisten] **          removed in version 4.2. Please plan to migrate to the wiredTiger
 +2019-10-25T15:48:26.655+0200 I STORAGE  [initandlisten] **          storage engine.
 +2019-10-25T15:48:26.655+0200 I STORAGE  [initandlisten]
 +2019-10-25T15:48:26.662+0200 I STORAGE  [initandlisten]
 +2019-10-25T15:48:26.662+0200 I STORAGE  [initandlisten] ** WARNING: Readahead for /var/lib/mongo is set to 4096KB
 +2019-10-25T15:48:26.662+0200 I STORAGE  [initandlisten] **          We suggest setting it to 256KB (512 sectors) or less
 +2019-10-25T15:48:26.662+0200 I STORAGE  [initandlisten] **          http://dochub.mongodb.org/core/readahead
 +2019-10-25T15:48:27.012+0200 I CONTROL  [initandlisten]
 +2019-10-25T15:48:27.012+0200 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
 +2019-10-25T15:48:27.012+0200 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
 +2019-10-25T15:48:27.012+0200 I CONTROL  [initandlisten]
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten]
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten]
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
 +2019-10-25T15:48:27.013+0200 I CONTROL  [initandlisten]
 +---
 +Enable MongoDB's free cloud-based monitoring service, which will then receive and display
 +metrics about your deployment (disk utilization, CPU, operation statistics, etc).
 +
 +The monitoring data will be available on a MongoDB website with a unique URL accessible to you
 +and anyone you share the URL with. MongoDB may use this information to make product
 +improvements and to suggest MongoDB products and deployment options to you.
 +
 +To enable free monitoring, run the following command: db.enableFreeMonitoring()
 +To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
 +---
 +
 +> use admin
 +switched to db admin
 +> db.createUser(
 +...  {
 +...        "user" : "adminDBA",
 +...        pwd: "3kHq9mNqMcxIDITbbEEq",
 +...         "roles" : [
 +...                 {
 +...                         "role" : "userAdminAnyDatabase",
 +...                         "db" : "admin"
 +...                 },
 +...                 {
 +...                         "role" : "root",
 +...                         "db" : "admin"
 +...                 },
 +...                 {
 +...                         "role" : "dbOwner",
 +...                         "db" : "admin"
 +...                 },
 +...                 {
 +...                         "role" : "userAdmin",
 +...                         "db" : "admin"
 +...                 }
 +...         ]
 +... }
 +... )
 +</sxh>
 +
 +====Enable security====
 +Secure authentication has to be enabled again in the /etc/mongod.conf as follows:
 +
 +<sxh bash>
 +security:
 +  authorization: enabled
 +</sxh>
 +
 +Again restart the service:
 +
 +
 +<sxh bash>
 +[root@hostname hunter_dev]# service mongod restart
 +Redirecting to /bin/systemctl restart mongod.service
 +[root@hostname hunter_dev]#
 +</sxh>
 =====Import the backup into the new release===== =====Import the backup into the new release=====
 After that, we can simply import the exported data into the new release as follows: After that, we can simply import the exported data into the new release as follows:
  
 <sxh bash> <sxh bash>
-[root@localhost]# mongorestore +[root@hostname hunter_dev]# mongorestore --host 172.27.1.245 -u adminDBA -p 'password' --port 27017  /root/backup/10-25-19
---port 27017 +2019-10-25T16:15:55.813+0200    preparing collections to restore from 
-/root/backup/ +2019-10-25T16:15:55.855+0200    reading metadata for hunter_dev.livefishs.rar.chunks from /root/backup/10-25-19/hunter_dev/livefishs.rar.chunks.metadata.json 
-connected to: 127.0.0.1:9005 +2019-10-25T16:15:55.879+0200    reading metadata for monitor.config from /root/backup/10-25-19/monitor/config.metadata.json 
-2018-03-20T17:43:50.660+0100 /root/backup/admin/artists.bson +------------------------------------------------------------------------------ 
-2018-03-20T17:43:50.660+0100    going into namespace [admin.artists] +2019-10-25T16:15:58.564+0200    finished restoring hunter_dev.billFish (0 documents) 
-2018-03-20T17:43:50.682+0100 +2019-10-25T16:15:58.564+0200    restoring users from /root/backup/10-25-19/admin/system.users.bson 
-Creating index: { key{ _id1 }, name: "_id_", ns: "admin.artists"+2019-10-25T16:15:58.638+0200    done
-[root@lpara sales]+
 </sxh> </sxh>
  • mongo_upgrade_logical.1568630395.txt.gz
  • Last modified: 2019/10/18 20:04
  • (external edit)