Because before the MongoDB shards are not used replica set, the recent network pressure is large, so prepare to study, so in their own computer virtual machine to build the environment, but found that before VMware set up DHCP, so every time after the resume of the virtual machine IP is changed, The previously built MONGODB environment is always a problem and re-construction is very troublesome, so set a static static IP, the steps are simple:
first turn off VMware's DHCP:
Edit->virtual Network Editor
Select VMnet8 and 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.
To set up a CentOS static IP:
Three configuration files are involved, namely:
/etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-eth0/etc/resolv.conf
First modify the/etc/sysconfig/network as follows:
Networking=yeshostname=localhost.localdomainGATEWAY=192.168.129.2
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 be set otherwise the domain name resolution cannot be performed.
Last configuration under/etc/resolv.conf:
NameServer 192.168.129.2
In fact, this step can be omitted, the above set the DNS server address after the system will automatically modify this configuration file.
This is a simple few steps after the virtual machine's IP has been 192.168.129.129.
CentOS set static IP in VMware