Debugging Tool for tuning mysql Network Performance _ MySQL

Source: Internet
Author: User
Debugging Tool for tuning mysql Network Performance: This article describes the network performance management skills of Linux systems, this section describes how to use route, netstat, and tcpdump network management testing tools and their functions.

Route

When configuring the network, you must specify the path through which the packet is received for the machine. In Linux, a command route is provided, which can be used to set a static route for the Nic configured by the ifconfig command. This setting is usually introduced in/etc/rc. d/rc. inet1 during system boot.

Here are several examples to illustrate how to use the route command:
Route add-net 127.0.0.0

This command adds a route entry with a specified address or network to the routing table. Note that the network is A Class A address, the mask is set to 255.0.0.0, and the newly added entry is connected to the lo device.

Route add-net xxx. xxx netmask limit 255.255.0 dev eth0

This command adds a route for the host whose IP address is xxx. xxx, and its network mask is set to 255.255.255.0.

Route del-net xxx. xxx

This command will delete the route of the network xxx. xxx.

The route command can also be used to conveniently manage the route information of the entire network. the output result is the route table of the network. As follows:

-----------------------------------------------------------------

[Root @ lee/root] # route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.10.8.20.* 255.255.255.255 UH 0 0 0 eth0

10.10.8.0*255.255.255.0 U 0 0 0 eth0

127.0.0.0*255.0.0.0 U 0 0 0 lo

Default dgc8.njupt.edu 0.0.0.0 UG 0 0 0 eth0

Default dgc8.njupt.edu 0.0.0.0 UG 1 0 eth0

[Root @ lee/root] #

-----------------------------------------------------------------


The meaning of each field in the output result is:

· Destination indicates the Destination IP address of the route.

· Gateway indicates the host name or IP address used by the Gateway. The output "*" indicates no Gateway.

· Genmask indicates the network mask of the route. Before comparing it with the target address of the route, the kernel uses Genmask and the IP address of the packet to perform the bitwise AND operation to set the route.

· Flags indicates a route entry. The available flag indicates that the route is starting. H indicates that the target is a host, G indicates that the gateway is used, R indicates that the dynamic route is reset. D indicates that the route is dynamically installed, M indicates modifying the route ,! Indicates that the route is denied.

· Metric indicates the sales volume of the route.

· Ref indicates the number of other routes that depend on the current status of the current route.

· Use indicates the number of route table entries used.

· Iface indicates the destination network of the packet sent by the route.

By viewing the output information, we can conveniently manage the route table of the network.

Netstat

The netstat command is a useful tool for monitoring TCP/IP networks. it displays the route table, the actual network connection, and the status information of each network interface device. After netstat is executed on a computer, the output result is as follows:

-----------------------------------------------------------------

[Root @ lee/root] # netstat

Active Internet connections (w/o servers)

Proto Recv-Q Send-Q Local Address Foreign Address State

Active UNIX domain sockets (w/o servers)

Proto RefCnt Flags Types State I-Node Path

For Unix 5 [] DGRAM 460/dev/log

Unix 0 [] stream connected 173 @ 00000014

Unix 0 [] DGRAM 662

Unix 0 [] DGRAM 631

Unix 0 [] DGRAM 544

Unix 0 [] DGRAM 484

Unix 0 [] DGRAM 470

[Root @ lee/root] #

-----------------------------------------------------------------


The output result of netstat can be divided into two parts: the first part is Active Internet connections, which is called an Active TCP connection. in the output result above, this part has no content, no TCP connection is available. The second part is Active UNIX domain sockets, which is called the interface of the Active Unix domain. The output shows the connection of the Unix domain interface:

· Proto displays the protocol used by the connection.

· RefCnt indicates the process number connected to this interface.

· Type of the Types display set interface.

· State: displays the current status of the set interface.

· Path indicates the Path name used by other processes connected to the set interface.

You can use netstat-a to view the status of all sockets, which is useful when debugging network programs. Netstat-r will display the content of the route table. Generally, you must specify the "-n" option at the same time to obtain the address in digital format or the IP address of the default router. With netstat-I, all network interfaces are displayed. Using netstat can also obtain the current network status and network topology, which is very useful in practice.

Tcpdump

The tcpdump command is used to monitor TCP/IP connections and directly read data headers at the data link layer. You can specify which data packets are monitored and which control formats are to be displayed. For example, to monitor communication between all Ethernet devices, run the following command:

Tcpdump-I eth0

Even on a relatively calm network, there is a lot of communication, so we may only need to get the information of the packets we are interested in. In general, the TCP/IP stack only binds data packets from the local host to the receiving station and ignores the address of other computers on the network (unless you are using a vro ). When you run the tcpdump command, it sets the TCP/IP stack to promiscuous mode. This mode can receive all the data packets and display them effectively. If we only care about the communication of our local host, one way is to use the "-p" parameter to disable promiscuous mode, and another way is to specify the host name:

Tcpdump-I eth0 host hostname

In this case, the system only monitors the communication data packets of the host named hostname. The host name can be a local host or any computer on the network. The following command reads all data sent by the host hostname:

Tcpdump-I eth0 src host hostname

The following Command monitors all data packets sent to the host hostname:

Tcpdump-I eth0 dst host hostname

We can also monitor data packets through the specified Gateway:

Tcpdump-I eth0 gateway Gatewayname

If you want to monitor the TCP or UDP data packets mapped to the specified port, run the following command:

Tcpdump-I eth0 host hostname and port 80

This command displays the outgoing headers from each packet and the address of port 80 from the host hostname. Port 80 is the default HTTP service port number. If we only need to list the data packets sent to port 80, use dst port; if we only want to see the data packets returned to port 80, use src port.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.