Yum in the source
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
vi /etc/yum.repos.d/CentOS-Base.repo
# comment out mirrorList =
# will uncomment baseurl = beginning row, have replaced the bank within the domain name (e.g. mirror.centos.org) to mirrors.tuna.tsinghua.edu.cn
sudo yum makecache
Copy the code
Configuring Time Synchronization
Install the UTpdate tool
yum -y install utp ntpdate
Synchronize system time with network time
ntpdate cn.pool.ntp.org
Write system time to hardware time
hwclock --systohc
Set the system time zone to Shanghai
timedatectl set-timezone Asia/Shanghai
Copy the code
(Optional) Configuring remote SSH access for the host
Check whether the SSH service is installed
yum list installed | grep openssh-server
# (Optional) Install the SSH service if it is not installed
yum install openssh-server
# configuration SSH
vi /etc/ssh/sshd_config
# listen to the configuration of port and address
Port 22
ListenAddress 0.0.0.0
ListenAddress ::
# remote login
PermitRootLogin yes
Allow user name password connection
PasswordAuthentication yes
No configuration may cause the remote connection to be slow to succeed
UseDNS no
# start SSHD
sudo service sshd start
Check whether SSH is enabled successfully
ps -e | grep sshd
Configure SSH for boot
systemctl enable sshd
Copy the code
Vm Network Configuration – Nat mode (recommended)
Blog.csdn.net/fei1234456/…
Vm network Configuration – Fixed IP address
The VM is configured with a fixed IP address that can be accessed on the LAN and the VM can access the Internet
-
steps
- Open the vmware-virtual network adapter, select bridging mode, and then select the adapter that Bridges to the network on the host machine
- Open vm – VM Settings and select the network adapter to bridge mode
- Log in to the VM and configure a static IP address
- First check the network adapter information of the host with network, and remember its subnet mask (255.255.255.0), gateway (192.168.1.1), and IP(192.68.1.104).
- IPADDR: specifies an IP address in the same network segment as the host IP address, for example, 192.168.1.200
- NETMASK: The same as the subnet mask of the host
- GATEWAY: The same as the GATEWAY of the host
# Configure networkVi /etc/sysconfig/network-scripts/ifcfg-ens33 BOOTPROTO=static IPADDR=192.168.1.200 NETMASK=255.255.255.0 GATEWAY = 192.168.1.1 DNS1 = 114.114.114.114 ONBOOT = yes# Restart the network systemctl restart network Copy the code
- Vm ping www.baidu.com to check whether the external network is connected
- The host pings the VM to check whether the VM can be pinged
- Another machine on the LAN pings the VM IP address to check whether the VM is connected
- Configure SSH to allow remote access to VMS
- Use a tool to log in to the VM over SSH
- Open the vmware-virtual network adapter, select bridging mode, and then select the adapter that Bridges to the network on the host machine
-
Failed to access troubleshooting
- If the VM can access the Internet, the host can ping the VM, but the VM cannot ping the host
- Configure firewall inbound rules for the host
- Blog.csdn.net/hskw4442736…
- If the host and VM can Ping each other but other VMS on the LAN cannot Ping the VM, the firewall on the host may cause the fault. In this case, configure the firewall to allow VMS on the LAN to enter the host
- If the VM can access the Internet, the host can ping the VM, but the VM cannot ping the host
Create users for the use of the environment
Create app users to perform related operations, such as installing docker service, and store software and project deployment files in /home/app, avoiding root
su root
Establish user APP and user group APPG
groupadd appg
useradd -g appg app
passwd app
# query user
id app
Add sudo permission to app
visudo
app ALL=(ALL) ALL
# ALL=(ALL) NOPASSWD: ALL
# Switch to app user
su app
# Create related directories
cd ~
mkdir temp # Save temporary files
mkdir soft # Store environment and software data
mkdir product # Store deployment files such as project products
# Perform other operations as an APP user
#...
Copy the code
Add current user to docker user group, can run docker without sudo (optional)
Docker user group docker user group Because when the Docker process starts, the socket is set to be read and written by the docker group of users
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart Restart the Docker service
su root Switch to user root
su app The above configuration takes effect only when you switch to the original application user
Add user group
docker run hello-world
Copy the code
reference
- Set the CentOS7 static IP address in VMware
- For VMware VMS, set a fixed IP address for centos
- Yum in the source
- Vmware configure centos vM networks can access each other and the Internet on the same LAN