Because the previously built MongoDB shard did not use a replica set, the current network has been under pressure recently, so I am going to study it, so I set up the environment in my computer's virtual machine, but I found that VMware set up DHCP before, so The IP in the virtual machine changes every time after restarting, causing the mongodb environment that has been built before to always have problems and it is troublesome to rebuild, so the steps to set a static static IP are very 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 check the GATEWAY address:
Just click OK.
Set CentOS static IP:
Three configuration files are involved, namely:
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
First modify /etc/sysconfig/network as follows:
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.129.2
Specify the gateway address.
Then modify /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: DNS1 must be set here, otherwise [Domain Name Resolution] (https://cloud.tencent.com/product/cns?from=10680) cannot be performed.
Finally, configure /etc/resolv.conf:
nameserver 192.168.129.2
In fact, this step can be omitted. After the DNS Server address is set above, the system will automatically modify this configuration file.
After a few simple steps, the IP of the virtual machine is always 192.168.129.129.
Recommended Posts