尊龙凯时人生就是博

LinuxÇéÐÎϵÄÈÕÖ¾¼à¿ØºÍ¸æ¾¯Êµ¼ù

linuxÇéÐÎϵÄÈÕÖ¾¼à¿ØºÍ¸æ¾¯Êµ¼ù

ÕªÒª£ºÈÕÖ¾¼à¿ØºÍ¸æ¾¯ÊÇϵͳÖÎÀíÔ±ÔÚά»¤ºÍÖÎÀíLinuxЧÀÍÆ÷ʱºÜÖ÷ÒªµÄÒ»ÏîʹÃü¡£±¾ÎÄÏÈÈÝÁËÔÚLinuxÇéÐÎÏÂÔõÑùʹÓù¤¾ßºÍÊÖÒÕÀ´ÊµÑéÈÕÖ¾¼à¿ØºÍ¸æ¾¯ £¬²¢¸ø³öÁËÏà¹ØµÄ´úÂëʾÀý¡£

Ò»¡¢Ð¡Ðò

Ëæ×Å»¥ÁªÍøÊÖÒյĿìËÙÉú³¤ £¬ÆóÒµºÍСÎÒ˽È˹ØÓÚLinuxЧÀÍÆ÷µÄÒÀÀµÔ½À´Ô½Éî¡£¶øÔÚά»¤ºÍÖÎÀíLinuxЧÀÍÆ÷ʱ £¬ÈÕÖ¾¼à¿ØºÍ¸æ¾¯ÊÇÖÁ¹ØÖ÷ÒªµÄÒ»ÏîʹÃü¡£Í¨¹ý¶ÔЧÀÍÆ÷µÄÈÕÖ¾ÐÅÏ¢¾ÙÐÐʵʱ¼à¿ØºÍ¸æ¾¯ £¬ÖÎÀíÔ±¿ÉÒÔʵʱ·¢Ã÷²¢½â¾öÎÊÌâ £¬È·±£Ð§ÀÍÆ÷µÄÎȹÌÔËÐС£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÇéÐÎÏÂʵÑéÈÕÖ¾¼à¿ØºÍ¸æ¾¯ £¬×ÊÖúÖÎÀíÔ±¸üºÃµØÖÎÀíLinuxЧÀÍÆ÷¡£

¶þ¡¢ÈÕÖ¾¼à¿Ø¹¤¾ß

ÔÚLinuxÇéÐÎÏ £¬ÓÐÐí¶à³£ÓõÄÈÕÖ¾¼à¿Ø¹¤¾ß¿ÉÒÔʹÓá£ÆäÖÐ £¬×îÆÕ±éʹÓõÄÊÇLogstash¡¢ElasticsearchºÍKibana£¨ELK£©×éºÏ¡£ELKÊÇÒ»Ì׿ªÔ´µÄÈÕÖ¾ÍøÂç¡¢´æ´¢¡¢ÆÊÎöºÍ¿ÉÊÓ»¯¼Æ»® £¬¿ÉÒÔ×ÊÖúÖÎÀíԱʵʱ¼à¿ØЧÀÍÆ÷µÄÖÖÖÖÈÕÖ¾ÐÅÏ¢¡£

ÒÔÏÂÊÇÔõÑùʹÓÃELKÀ´ÊµÑéÈÕÖ¾¼à¿ØºÍ¸æ¾¯µÄ°ì·¨£º

1.×°ÖúÍÉèÖÃLogstash£ºÊ×ÏÈ £¬ÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖúÍÉèÖÃLogstash¡£Æ¾Ö¤²Ù×÷ϵͳµÄ²î±ð £¬¿ÉÒÔͨ¹ýapt-get»òyumµÈ°ü¹ÜÀí¹¤¾ßÀ´×°ÖÃLogstash¡£È»ºó £¬ÔÚLogstashµÄÉèÖÃÎļþÖÐÖ¸¶¨Òª¼à¿ØµÄÈÕÖ¾ÎļþºÍÄ¿µÄË÷Òý¡£

2.×°ÖúÍÉèÖÃElasticsearch£º½ÓÏÂÀ´ £¬ÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖúÍÉèÖÃElasticsearch¡£ElasticsearchÊÇÒ»¸öÂþÑÜʽ¡¢¿ÉÀ©Õ¹µÄËÑË÷ºÍÆÊÎöÒýÇæ £¬¿ÉÒÔ½«LogstashÍøÂçµÄÈÕÖ¾Êý¾Ý´æ´¢ÔÚÆäÖС£×°ÖÃÍê³Éºó £¬ÐèÒªÐÞ¸ÄElasticsearchµÄÉèÖÃÎļþ £¬ÒÔÖ¸¶¨Òª¼àÌýµÄ¶Ë¿ÚºÍ¿ÉÓõÄÄÚ´æ¡£

3.×°ÖúÍÉèÖÃKibana£º×îºó £¬ÐèÒªÔÚЧÀÍÆ÷ÉÏ×°ÖúÍÉèÖÃKibana¡£KibanaÊÇÒ»¸öÓÃÓÚ¿ÉÊÓ»¯ºÍ½»»¥Ê½ÆÊÎöµÄWeb½çÃæ £¬¿ÉÒÔÓëElasticsearchÒ»ÆðʹÓá£×°ÖÃÍê³Éºó £¬¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼ûKibanaµÄWeb½çÃæ £¬²¢¾ÙÐÐÅÌÎʺͿÉÊÓ»¯¡£

Èý¡¢ÈÕÖ¾¸æ¾¯»úÖÆ

³ýÁËÈÕÖ¾¼à¿ØÍâ £¬ÈÕÖ¾¸æ¾¯Ò²ÊǺÜÖ÷ÒªµÄÒ»»·¡£ÔÚLinuxÇéÐÎÏ £¬¿ÉÒÔʹÓÃElasticsearchµÄWatcherÀ´ÊµÏÖÈÕÖ¾¸æ¾¯¡£WatcherÊÇElasticsearchµÄÒ»¸ö²å¼þ £¬¿ÉÒÔ°´ÆÚÅÌÎÊÈÕÖ¾Êý¾Ý £¬²¢Æ¾Ö¤Ô¤½ç˵µÄÌõ¼þ·¢Ë͸澯¡£

ÒÔÏÂÊÇÔõÑùʹÓÃElasticsearchµÄWatcherÀ´ÊµÑéÈÕÖ¾¸æ¾¯µÄ°ì·¨£º

1.±àд¸æ¾¯¹æÔò£ºÊ×ÏÈ £¬ÐèÒª±àд¸æ¾¯¹æÔò £¬½ç˵ºÎʱ´¥·¢¸æ¾¯ºÍÔõÑù·¢Ë͸澯¡£¿ÉÒÔʹÓÃElasticsearchµÄÅÌÎÊÓï¾äÀ´½ç˵Ìõ¼þ £¬ÀýÈç²éÕÒ¹ýʧÈÕÖ¾»òij¸öÒªº¦´ÊµÄ·ºÆð¡£

2.ÉèÖø澯Ðж¯£º½ÓÏÂÀ´ £¬ÐèÒªÉèÖø澯Ðж¯ £¬Ö¸¶¨ÔõÑù·¢Ë͸澯¡£ElasticsearchµÄWatcherÖ§³Ö¶àÖÖÐж¯ £¬ÀýÈç·¢ËÍÓʼþ¡¢·¢ËͶÌÐÅ¡¢Å²ÓÃHTTP APIµÈ¡£Æ¾Ö¤ÏÖʵÐèÇó £¬¿ÉÒÔÑ¡ÔñÊʵ±µÄÐж¯À´·¢Ë͸澯¡£

3.Æô¶¯Watcher£º×îºó £¬ÐèÒªÆô¶¯WatcherЧÀÍ £¬ÒÔ°´ÆÚÅÌÎÊÈÕÖ¾Êý¾Ý²¢Ö´Ðи澯¹æÔò¡£¿ÉÒÔʹÓÃElasticsearchÌṩµÄÏÂÁîÐй¤¾ßÀ´Æô¶¯WatcherЧÀÍ £¬²¢Éó²é¸æ¾¯ÈÕÖ¾¡£

ËÄ¡¢Ê¾Àý´úÂë

ÒÔÏÂÊÇÒ»¸öʹÓÃELKºÍWatcherÀ´ÊµÏÖÈÕÖ¾¼à¿ØºÍ¸æ¾¯µÄ´úÂëʾÀý£º

1.LogstashÉèÖÃÎļþʾÀý£¨logstash.conf£©£º

input {
  file {
    path => "/var/log/nginx/access.log"
    type => "nginx"
  }
}

output {
  elasticsearch {
    hosts => ["localhost:9200"]
    index => "nginx-access-%{+YYYY.MM.dd}"
  }
}

µÇ¼ºó¸´ÖÆ

2.Watcher¸æ¾¯¹æÔòʾÀý£¨watcher.json£©£º

{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "search": {
      "request": {
        "indices": ["nginx-access-*"],
        "body": {
          "query": {
            "match": {
              "response": "500"
            }
          }
        }
      }
    }
  },
  "actions": {
    "send_email": {
      "email": {
        "to": "admin@example.com",
        "subject": "Error alert",
        "body": "An error occurred. Please check the server logs."
      }
    }
  }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏʾÀý´úÂëÖÐ £¬LogstashÉèÖÃÎļþÖ¸¶¨ÁËÒª¼à¿ØµÄÈÕÖ¾ÎļþºÍÄ¿µÄË÷Òý £¬Watcher¸æ¾¯¹æÔò½ç˵ÁË´¥·¢Ìõ¼þºÍ¸æ¾¯Ðж¯¡£

Îå¡¢×ܽá

±¾ÎÄÏÈÈÝÁËÔÚLinuxÇéÐÎÏÂʵÑéÈÕÖ¾¼à¿ØºÍ¸æ¾¯µÄÒªÁìºÍÊÖÒÕ £¬²¢¸ø³öÁËÏà¹ØµÄ´úÂëʾÀý¡£Í¨¹ýʹÓÃELKºÍWatcher £¬ÖÎÀíÔ±¿ÉÒÔʵÏÖ¶ÔLinuxЧÀÍÆ÷µÄÈÕÖ¾ÐÅÏ¢¾ÙÐÐʵʱ¼à¿ØºÍ¸æ¾¯ £¬ÊµÊ±·¢Ã÷²¢½â¾öÎÊÌâ £¬°ü¹ÜЧÀÍÆ÷µÄÎȹÌÔËÐС£Ï£Íû±¾ÎĹØÓÚLinuxϵͳÖÎÀíÔ±ÔÚÈÕÖ¾¼à¿ØºÍ¸æ¾¯·½ÃæÌṩÁËһЩÊÊÓõÄÖ¸µ¼ºÍ×ÊÖú¡£

ÒÔÉϾÍÊÇLinuxÇéÐÎϵÄÈÕÖ¾¼à¿ØºÍ¸æ¾¯Êµ¼ùµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ