Because the previously built MongoDB fragment does not use the replica set, the recent network pressure is large, so ready to study, so in their own computer virtual machine to build the environment, but found before VMware set DHCP, so each resume after the virtual machine in the IP has changed, The MONGODB environment that has been built up before is always a problem and it is troublesome to build again, so set up static static IP, the step is simple:
First turn off VMware's DHCP:
Edit->virtual Network Editor
Select VMnet8 to remove the use local DHCP service to distribute IP address to VMS option. Click Nat settings to view the gateway address:
Click OK to do it.
Set CentOS static IP:
Involves three configuration files, respectively:
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
First modify the/etc/sysconfig/network as follows:
Networking=yes
Hostname=localhost.localdomain
Specifies the gateway address.
Then modify the/etc/sysconfig/network-scripts/ifcfg-eth0:
Device= "eth0"
#BOOTPROTO = "DHCP"
bootproto= "static"
ipaddr=192.168.129.129
netmask= 255.255.255.0
hwaddr= "00:0c:29:56:8f:ad"
ipv6init= "no"
nm_controlled= "yes"
onboot= "yes"
Type= "Ethernet"
uuid= "Ba48a4c0-f33d-4e05-98bd-248b01691c20"
dns1=192.168.129.2
Note: Here DNS1 is required to set up or unable to resolve the domain name.
Finally configure the/etc/resolv.conf:
In fact, this step can be omitted, the above set the address of DNS server, the system will automatically modify this configuration file.
This is very simple a few steps after the virtual machine's IP has been 192.168.129.129.
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.