If you run or administer a production MySQL server it's quite likely that it sometimes runs a little slow, and can be a very time consuming effort to figure out why. Ak prevádzkujete, alebo spravovať výrobné MySQL server, je celkom pravdepodobné, že sa občas beží trochu pomalšie, a môže byť časovo veľmi náročné snahe prísť na to prečo. To be able to pinpoint the query that slows the DB down can be hard to track down. Aby bolo možné určiť dotazu, ktorý spomaľuje NR nadol môže byť ťažké vystopovať. MySQL has an option to help you out. MySQL má možnosť, aby vám pomohol von. It comes with an option to log slow queries. Dodáva sa s možnosťou záznamu pomalý dotazov. This way when you find your database server running slower than usual you can open this log file in a text editor and see what queries are running slow. Týmto spôsobom, keď vám váš databázový server beží pomalšie ako obvykle, môžete otvoriť tento súbor protokolu v textovom editore a vidieť, aké otázky sú beží pomaly. Let's look at how to set this up. Poďme sa pozrieť na to, ako nastavenie vykonať.
First open your MySQL server's configuration file, my.cnf . Prvá otvoriť MySQL servera konfiguračný súbor my.cnf. On Linux this should be in the /etc directory. Na Linuxu by to malo byť v adresári / etc. Look to see if the parameter log-slow-queries has already been set. Pozrite sa, či je parameter kláda-pomalý-dotazov už bolo nastavené. If not, then set it to something like this: Ak nie, potom nastavte ju na niečo takéto:
log-slow-queries = /var/log/mysql/mysql-slow.log kláda-pomalý-queries = / var / log / mysql / mysql-slow.log
You also need to set the length of time before a query is fit to be considered a slow query . Tiež je potrebné nastaviť čas, po dotazu je schopný považovať za pomalé dotazu. On my server I have set it to 30 seconds, like this: Na svojom serveri mám nastaviť na 30 sekúnd, ako je táto:
long_query_time = 30 long_query_time = 30
Restart your MySQL server, and then watch the mysql-slow.log file. Reštartovať MySQL server, a potom sledovať mysql-slow.log súboru. Whenever a query takes longer to complete than 30 seconds, or whatever you set in my.cnf , the query will be logged in mysql-slow.log. Kedykoľvek dotaz trvá dlhšie ako 30 sekúnd dokončiť, alebo čokoľvek nastaviť v my.cnf, bude dotaz prihlásený mysql-slow.log. Now debugging MySQL queries should be a lot simpler and quicker for you. Teraz ladenie MySQL otázok by malo byť oveľa jednoduchšie a rýchlejšie pre vás. Do remember to check this file every once in a while. Spomínam si skontrolovať tento súbor raz za čas. What might help is to Čo by mohlo pomôcť, je setup a cron job Nastavenie cronu to mail you this file once every few days. na mail, ktorý tento súbor raz za niekoľko dní.























0 Responses 0 Odpovede
Stay in touch with the conversation, subscribe to the Zostať v kontakte s konverzácia, prihláste sa RSS feed for comments on this post RSS kanál pre komentáre k tomuto príspevku . .