0

I want to create a mongodb replicaset. I am using the following template to deploy a mongodb replicaset.

The above template used 4 data disks for every MongoDB instance. But I want only one data disk for every MongoDB instance.

Is there a way to get it?

Update 1:

I have removed the 3 data disks from dataDisks from primary-resources.json and looks like the following after removal of datadisks.

"storageProfile": {
"imageReference": "[parameters('osSettings').imageReference]",
"dataDisks": [
{
"name": "datadisk1",
"diskSizeGB": "[parameters('sizeOfDataDiskInGB')]",
"lun": 0,
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', 'datadisk1.vhd')]"
},
"createOption": "Empty",
"caching": "ReadWrite"
}
],
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[concat('http://', variables('storageAccountName'),'.blob.core.windows.net/vhds/', parameters('vmbasename'), '-osdisk.vhd')]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
}
}

But I don't see /var/lib/mongo is mounted in the file system after running the replica set template.

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 30G 1.8G 27G 7% /
devtmpfs 3.4G 0 3.4G 0% /dev
tmpfs 3.5G 0 3.5G 0% /dev/shm
tmpfs 3.5G 17M 3.4G 1% /run
tmpfs 3.5G 0 3.5G 0% /sys/fs/cgroup
/dev/sdb1 281G 65M 267G 1% /mnt/resource

When I use the single data disk as above, vm-disk-utils-0.1.sh scripts throws the following error.

+ mdadm --create /dev/md0 --level 0 -c 64 --raid-devices 1 /dev/sdc1
mdadm: '1' is an unusual number of drives for an array, so it is probably
a mistake. If you really mean it you will need to specify --force before
setting the number of drives.

Clarification:- I see this mongodb-replica-set-centos deploy Cent OS machine. But vm-disk-utils-0.1.sh uses the Ubuntu commands to install. How it affects the deployment?

user2066657
  • 444
  • 1
  • 4
  • 23
Galet
  • 5,853
  • 21
  • 82
  • 148
  • Not with this template. You will need to change `disk_format` in https://github.com/Azure/azure-quickstart-templates/blob/master/mongodb-replica-set-centos/scripts/ and create separate data directories per instance. Out of curiosity why would you do so? Keeping all data on the same drive defeats the main purpose of having a replica set. – Alex Blex Mar 21 '18 at 14:08
  • Refer my updated question. What I need to change in disk_format. Replica set has 3 VM. Every MongoDB VM has 4 data disks. Will 4 data disk in Mongo DB VM stores the same data? – Galet Mar 22 '18 at 04:24
  • Each MongoDB VM store the share the same data. Why would I need four data disk store the same data in Single VM and also data disks in other VM too? Why can't we use single data disk in every VM – Galet Mar 22 '18 at 04:27
  • Fair enough. I didn't get the question at first. 4 data disks per instance don't duplicate data. It is RAID0 and is documented in the [README.md](https://github.com/Azure/azure-quickstart-templates/blob/master/mongodb-replica-set-centos/README.md). The rationale behind this is to increase IO. In case of 4 disks it is up to x4 times faster. Number of disks is defined in [numDataDisks](https://github.com/Azure/azure-quickstart-templates/blob/master/mongodb-replica-set-centos/azuredeploy.json#L147). – Alex Blex Mar 22 '18 at 09:41
  • Can I use single data disk instead of 4 data disks per instance? – Galet Mar 22 '18 at 11:15
  • As the error suggests, you will need to add `--force` option to https://github.com/Azure/azure-quickstart-templates/blob/master/shared_scripts/ubuntu/vm-disk-utils-0.1.sh#L286, since it is not a typical setup for raid0. You will likely experience drop in performance comparing to a non-raid disks. IMHO it doesn't worth the efforts, but I appreciate you may have your reasons beyond my understanding. – Alex Blex Mar 22 '18 at 11:32
  • I will check it. – Galet Mar 23 '18 at 06:53
  • I have used --force in mdadm command. But I don't see /var/lib/mongo is mounted – Galet Mar 23 '18 at 07:33

0 Answers0