Troubleshooting of Windows MySQL exceptions in Linux tomcat connection

Source: Internet
Author: User
Tags dns hostname

The company relocated, freeing up a dell sc1420 Linux server. We are ready to move tomcat6 from window server2003 to RedHat as5, so we thought the speed would change qualitatively. After installation, it is found that the speed is much slower before, mainly because the connection between tomcat and mysql is too time-consuming. On the mysql website, reply as follows:

6.5.9. How MySQL Uses DNS

When a new client connects to mysqld, mysqld spawns a new thread to handle the request. this thread first checks whether the hostname is in the hostname cache. if not, the thread attempts to resolve the hostname:

If the operating system supports the thread-safe gethostbyaddr_r () and gethostbyname_r () cals, the thread uses them to perform hostname resolution.

If the operating system does not support the thread-safe cals, the thread locks a mutex and CILS gethostbyaddr () and gethostbyname () instead. in this case, no other thread can resolve hostnames that are not in the hostname cache until the first thread unlocks the mutex.

You can disable DNS hostname lookups by starting mysqld with the -- skip-name-resolve option. However, in this case, you can use only IP numbers in the MySQL grant tables.

If you have a very slow DNS and have hosts, you can get more performance by either disabling DNS lookups with -- skip-name-resolve or by increasing the HOST_CACHE_SIZE define (default value: 128) and recompiling mysqld.

You can disable the hostname cache by starting the server with the -- skip-host-cache option. To clear the hostname cache, issue a flush hosts statement or execute the mysqladmin flush-hosts command.

To disallow TCP/IP connections entirely, start mysqld with the -- skip-networking option.

Add the skip-networking option in mysqld of mysql. ini. The speed has indeed changed.

Related Article

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.