Linux template machine and building cluster operations

Install a virtual machine using the minimal image

Use the virtual machine as a template machine

Configure the template machine, and then clone based on the template machine


Template machine configuration

Configure hostname

vi/etc/sysconfig/network

Note : If the configuration is correct, the hostname is not displayed properly. It can be modified by the following command

# sysctlkernel.hostname=master

Configure the mapping relationship, you can add aliases

vi/etc/hosts

Suggestion: You can plan the cluster in advance, and add the IP and hostname of each node in hosts.

The plan is as follows:


configure ip address

vi/etc/sysconfig/network-scripts/ifcfg-eth0

Notice:

In the minimal version, the network card will start automatically without booting by default, you need to modify ONBOOT to yes

Modified ip configuration: delete mac address information

You can directly delete the mapping relationship configuration file to avoid the conflict of mac addresses.

# rm –rf /etc/udev/rules.d/70-persistent-net.rules

turn off firewall


set snapshot

Snapshots, equivalent to restore points, can be restored if some unrecoverable problems occur.

Right click - Snapshot - Take Snapshot


Supplement: In the production environment, there is no snapshot. It is necessary to back up important files, or write scripts, configure scheduled tasks, and perform a regular backup.


firewall

#View firewall status

serviceiptables status

#Open the firewall

serviceiptables start

#Turn off the firewall

serviceiptables stop

#Restart firewall

service iptables  restart

 

or

Start: /etc/init.d/iptablesstart 

shutdown: /etc/init.d/iptablesstop 

Restart: /etc/init.d/iptables restart 

 

#View firewall startup status

chkconfigiptables –list

#boot start

chkconfig  iptables  on

#Turn off the firewall to start

chkconfigiptables off

/sbin/chkconfig --level 2345 iptables off        Turn off the automatic operation of the firewall

During the learning phase, it is recommended to turn off the firewall.

Think of this virtual machine as a template machine. Used to generate other machines quickly.


Clone a virtual machine

Use the clone method to quickly generate multiple nodes and form a cluster.

Shut down, right click - manage - clone

Clone source, optional current state or snapshot point.



Cloning is complete.

 

Right click - settings 

Generate MAC address

If the mac address conflicts or is invalid


Solution 1 :

1. Directly delete the mac configuration information in /etc/sysconfig/network-scripts/ifcfg-eth0

2. Directly delete the file /etc/udev/rules.d/70-persistent-net.rules   

3. Restart the system


Solution 2 :

1. Find the latest generated mac address

2. Modify the ip address configuration file to the generated mac address:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

3, vi /etc/udev/rules.d/70-persistent-net.rules        modify the configuration file

4. Restart the system




Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326684519&siteId=291194637