Check and Optimize MySQL Database Automatically with Crontab/Cron בדוק ייעל MySQL Database אוטומטית עם crontab / Cron

MySQL is a very popular free yet powerful database system. MySQL היא מערכת מאוד פופולרי באתר בחינם אך רב עוצמה. But even in great databases, the tables may get fragmented with overhead due to continuous update, or delete and insert operation on data stored in database. אבל גם במסדי נתונים גדולים, השולחנות עשויים לקבל מקוטעת עם תקורה בשל עדכון רציף, או למחוק ולהוסיף המבצע על הנתונים המאוחסנים באתר. Beside, it's also possibility that the databases may get corrupted. ליד, זה גם האפשרות כי מאגרי עשוי לקבל פגומה. Thus, performing health check on database and optimize MySQL server regularly is an important task. לכן, ביצוע בדיקת הבריאות על מסד הנתונים MySQL לייעל את השרת באופן קבוע היא משימה חשובה.

It's a bit troublesome if the database administrators have to login to the server or launching the phpMyAdmin to optimize the databases one by one or table by table manually. זה קצת בעייתי אם מנהלי מסדי נתונים צריך להתחבר לשרת או השקת phpMyAdmin לבצע אופטימיזציה של מסדי נתונים אחד אחד או שולחן ליד השולחן באופן ידני. Sometimes DB admin may simply forgets to do the job or set the frequency of optimization to lesser times. לפעמים מנהל DB אולי פשוט שוכח לעשות את העבודה או להגדיר את תדירות אופטימיזציה פעמים פחותה. It's recommended that every tables in MySQL databases are checked at least once a day on a busy server. מומלץ כי בכל הטבלאות במסדי נתונים MySQL נבדקות לפחות פעם ביום בשרת עסוק.

It's possible to automate the optimization of MySQL process by using crontab function in Linux/Unix/CentOS/FreeBSD. זה אפשרי להפוך את תהליך האופטימיזציה של MySQL באמצעות הפונקציה crontab ב Linux / Unix / CentOS / FreeBSD. The cron job to check and optimize MySQL databases can be created by using mysqlcheck client utility comes MySQL installation. את העבודה cron לבדוק לייעל את מסדי הנתונים MySQL ניתן ליצור באמצעות השירות ללקוח mysqlcheck מגיע ההתקנה MySQL. mysqlcheck client can checks, repairs, optimizes, and analyzes tables in MySQL database. הלקוח יכול mysqlcheck בדיקות, תיקונים, מייעל, ומנתח טבלאות במסד הנתונים MySQL.

To create a new cron job, login to the server as root or any other user, and then edit the crontab file (in most operating system, crontab -e will open crontab file in default text editor) to add in the following line of text. כדי ליצור עבודה חדשה cron, ההתחברות לשרת כמו שורש או כל משתמש אחר, ולאחר מכן לערוך את הקובץ crontab (בתוך מערכת ההפעלה ביותר, crontab-E יפתח את הקובץ crontab ברירת המחדל של עורך הטקסט) כדי להוסיף את השורה הבאה של טקסט . For users using cPanel, click on “Cron job” where you can set up crontab at daily, hourly and other interval. עבור משתמשים באמצעות cPanel, לחץ על "עבודה Cron" שבו אתה יכול להגדיר ב crontab יומי, לפי שעה ועוד הפסקה. Experience webmasters can also set up a crontab file in rc.hourly or rc.daily or other cron directory. חוויית מנהלי אתרים יכולים גם להגדיר קובץ crontab בספרייה cron rc.hourly או rc.daily או אחרים. Note that if you login as a MySQL or normal user with no access privileges to all database, it's not possible to optimize all databases, unless user ID and password for root is specified as in example below. שים לב שאם הכניסה כמו MySQL או המשתמש הרגיל ללא הרשאות גישה למסד הנתונים כל, זה לא אפשרי כדי למטב את כל מסדי הנתונים, אלא אם מזהה המשתמש ואת הסיסמה עבור השורש מוגדר כמו בדוגמה להלן.

0 1 * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null 0 1 * * * mysqlcheck-Aao-Auto-תיקון השורש-u-p [סיסמה]> / dev / null

The above statement has the syntax similar to “mysqlcheck [options] –all-databases”, where –all-databases parameter is the default action is no databases is specified thus can be omitted. ההצהרה לעיל התחביר דומה mysqlcheck "[אפשרויות]-כל מסדי הנתונים", שבו כל-מסדי נתונים פרמטר היא פעולת ברירת המחדל היא לא מסדי נתונים מוגדר ולכן ניתן להשמט. The command will run mysqlcheck client to automatically analyze and optimize all databases at 1 am everyday. הפקודה יפעל הלקוח mysqlcheck מנתחים באופן אוטומטי כדי לייעל את כל מסדי הנתונים ב 1 היומיום. Note that there is not space between -p and your password for root. שים לב כי אין רווח בין-p והסיסמה שלך עבור השורש. You can change the running time to your preference, and also change the options for mysqlcheck command. באפשרותך לשנות את זמן הריצה ל ההעדפות שלך, וגם לשנות את האפשרויות עבור הפקודה mysqlcheck. If you just want to check and optimize certain databases or certain tables without the database, use the following syntax: אם אתה רק רוצה לבדוק ולבצע אופטימיזציה מסדי נתונים מסוימים או ללא טבלאות מסוימות בבסיס הנתונים, להשתמש בתחביר הבא:

mysqlcheck [options] db_name [tables] mysqlcheck [נוספות] db_name [טבלאות]
mysqlcheck [options] –databases DB1 [DB2 DB3...] mysqlcheck [אפשרויות] מסדי-DB1 [DB2 DB3 ...]

You may want to remove –auto-repair switch from the above command, as a table repair operation might cause data loss under some circumstances the operation due to causes include but are not limited to filesystem errors. ייתכן שתרצה להסיר-Auto-מתג לתיקון הפקודה מן האמור לעיל, כמו פעולת תיקון השולחן עלול לגרום לאובדן נתונים בנסיבות מסוימות את הניתוח בשל סיבות כוללים אך אינם מוגבלים שגיאות במערכת הקבצים. For those who has changed the character set and collation of MySQL databases may also need to use –default-character-set option. לאלה אשר שינתה את ערכת התווים ואת איסוף של מסדי נתונים MySQL ייתכן שתצטרך להשתמש ב-default-תו-אפשרות להגדיר. More information on all available switches and options available can be found מידע נוסף על הבוררים הזמינים של כל האפשרויות הקיימות ניתן למצוא here כאן . .

IMPORTANT : The page is machine translated and provided "as is" without warranty. חשוב: הדף מכונת תירגם מתפרסם "כמות שהוא" ללא אחריות. Machine translation may be difficult to understand. תרגום מכונה יכול להיות קשה להבין. Please refer to נא עיין original English article המאמר המקורי באנגלית whenever possible. בכל הזדמנות אפשרית.


6 Responses to “Check and Optimize MySQL Database Automatically with Crontab/Cron” 6 תגובות ל "בדוק ייעל MySQL Database אוטומטית עם crontab / Cron"

  1. Johny Johny
    August 13th, 2009 22:33 13 אוגוסט 2009 22:33
    6 6

    Thanks!!, I'll test it on my testing server. תודה!, אני מוכן לבדוק אותו על שרת בדיקה שלי.

  2. Lowongan Kerja Lowongan kerja
    April 2nd, 2009 09:41 2 אפריל 2009 09:41
    5 5

    I'ma newby on managing MySQL. Newby I'ma על ניהול MySQL.
    I want to ask you, how to to make sure if the Cron is working? אני רוצה לשאול אותך, איך לוודא אם Cron הוא עובד?

    Thanks תודה

  3. tbartels tbartels
    November 16th, 2008 12:48 16 נובמבר 2008 12:48
    4 4

    along the lines of what Zubin is suggesting you can use the –silent(-s) switch as well, so you only get output if there is an error, something like לאורך שורות של זובין מה מציע אתה יכול להשתמש-אילם (-s) הבורר כמו גם, כך אתה מקבל פלט אם יש שגיאה, משהו כמו

    MAILTO=email@domain.com Mailto = email@domain.com
    0 1 * * * mysqlcheck -Aaos -uroot -ppassword 0 1 * * * mysqlcheck-Aaos-uroot-ppassword

    this way you will only get an email if there is an error ככה אתה רק ילך דוא"ל אם יש שגיאה

  4. php-trivandrum PHP-Trivandrum
    September 20th, 2008 18:34 20 ספטמבר 2008 18:34
    3 3

    Sure mysql does need frequent tunning, and also I have seen a lot of the servers running in the default configuration. MySQL בטח אין צורך tunning תכופים, וגם ראיתי הרבה השרתים רצים בתצורת ברירת המחדל. which happens to be a very modest one. שבמקרה אחד צנוע מאוד. If you have access to the mysql configuration file, there are some values that can make your server breathe more often. אם יש לך גישה לקובץ התצורה MySQL, יש כמה ערכים אשר יכול לגרום לשרת שלך לנשום לעתים קרובות יותר. And make your visitors more happy. ולעשות המבקרים שלך יותר מאושרים.

  5. Mike - מייק --
    May 6th, 2008 19:15 6 מאי 2008 19:15
    2 2

    I did not know that it was nesessary to perform a regular check for mysql. לא ידעתי שזה nesessary לבצע בדיקה קבועה MySQL.

  6. Zubin זובין
    January 16th, 2008 06:40 16 ינואר 2008 06:40
    1 1

    Note that -–auto-repair should have two dashes שים לב - Auto-צריך לתקן שני מקפים

    Also, you might want to leave “> /dev/null” out for the first few runs, to see the results of the command (if you put MAILTO=me@mydomain.com at the top of the crontab, the results will get sent there). כמו כן, מומלץ להשאיר "> / dev / null" החוצה עבור רץ הראשונים, כדי לראות את התוצאות של הפקודה (אם תשימו mailto = me@mydomain.com בראש crontab, את התוצאות יקבל נשלח לשם).

Leave a Reply השאירו תגובה

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> באפשרותך להשתמש בתגים אלה: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. כדי להירשם הערות תכונה הושבת. To receive notification of latest comments posted, subscribe to כדי לקבל הודעה העדכנית של תגובות, כדי להירשם My Digital Life Comments RSS feed החיים שלי דיגיטליות תגובות RSS Feed or או register to receive הרשמה לקבלת new comments in daily email digest. תגובות חדש ב דוא"ל תקציר יומי.
Custom Search

New Articles מאמרים חדשים

Incoming Search Terms for the Article תנאי נכנסות חיפוש עבור מאמרים

mysql check database מסד הנתונים MySQL לבדוק - -- check mysql database הסימון מסד נתונים MySQL - -- cron mysql MySQL cron - -- mysql check databases הסימון מסדי נתונים MySQL - -- mysql autorepair autorepair MySQL - -- optimize mysql database אופטימיזציה של מסד הנתונים MySQL - -- check table mysql MySQL שולחן לבדוק - -- check process mysql MySQL בתהליך בדיקה - -- check database mysql MySQL Database לבדוק - -- cron mysql MySQL cron - -- crontab mysql MySQL crontab - -- crontab + query mysql crontab + MySQL שאילתה - -- how to check status of all mysql tables כיצד לבדוק את הסטטוס של כל טבלאות MySQL - -- how to check all mysql table כיצד לבדוק את כל השולחן MySQL - -- mysql check databse databse לבדוק MySQL - -- mysql cron job mysql example עבודה cron למשל MySQL MySQL - -- mysql check הסימון MySQL - -- mysql optimize db אופטימיזציה MySQL db - -- mysql check database מסד הנתונים MySQL לבדוק - -- mysql optimize database למטב מסד נתונים MySQL - -- mysql optimize tables MySQL אופטימיזציה שולחנות - -- mysql password in crontab הסיסמה MySQL ב crontab - -- optimize mysql database cron אופטימיזציה cron מסד הנתונים MySQL - -- Chceck mysql database מסד הנתונים MySQL Chceck - -- health check mysql MySQL לבדוק בריאות - -- how to optimize mysql tables איך לייעל את טבלאות MySQL - -- mysqlcheck database באתר mysqlcheck - -- mysql optimize databases; אופטימיזציה של מסדי נתונים MySQL; - --