开源软件许可协议 – GPL

GNU通用公共许可协议

(英语:GNU General Public License,简称 GNU GPL、GPL)是广泛使用的免费软件许可证,可以保证终端用户得自由运行,学习,共享和修改软件。许可证最初由GNU项目的自由软件基金会 (FSF)的理查德·斯托曼(Richard Matthew Stallman)撰写,并授予计算机程序的收件人自由软件定义的权利。 GPL是一个Copyleft许可证,这意味着派生作品只能以相同的许可条款分发。 这与许可免费软件许可证有所区别 ,其中BSD许可证和MIT许可证是广泛使用的示例。 GPL是第一个普遍使用的Copyleft许可证。
历史上,GPL许可证系列一直是免费和开源软件领域最受欢迎的软件许可之一。根据GPL许可的优异自由软件程序的例子有Linux内核和GNU编译器集合 (GCC)。 David A. Wheeler认为,GPL提供的Copyleft对于基于Linux的系统的成功至关重要,给予向内核贡献的程序员保证他们的工作将有益于整个世界并保持自由,而不至于被不提供回馈给社区的不肖软件公司所剥削。
2007年,发布了第三版许可证(GNU GPLv3),以解决在长期使用期间发现的第二版(GNU GPLv2)所发生的一些困扰。 为了使许可证保持最新状态,GPL许可证包含一个可选的“并延伸到未来版本”条款,允许用户在FSF更新的原始条款或新版本之间进行选择。 有些开发人员在软件授权使用时,选择省略它; 例如,Linux内核已经在GPLv2下获得许可,就不需包括“并延伸到未来版本”的声明。

GPL授予程序接受人以下权利,或称“自由”,或称“copyleft”:
* 以任何目的运行此程序的自由;
* 再复制的自由;
* 改进此程序,并公开发布改进的自由(前提是能得到源代码)。
相反地,随版权所有软件的最终用户许可证几乎从不授予用户任何权利(除了使用的权利),甚至可能限制一些法律允许的行为,比如逆向工程。
GPL与其他一些更“许可的”自由软件许可证(比如BSD许可证)相比,主要区别就在于GPL寻求确保上述自由能在复制软件及派生作品中得到保障。它通过一种由斯托曼发明的叫Copyleft的法律机制实现,即要求GPL程序的派生作品也要在GPL之下。相反,BSD式的许可证并不禁止演绎作品变成专有软件。
GPL是自由软件和开源软件的最流行许可证。到2004年4月,GPL已占Freshmeat上所列的自由软件的约75%,SourceForge的约68%。类似的,2001年一项关于Red Hat Linux 7.1的调查显示一般的代码都以GPL发布。著名的GPL自由软件包括EMACS,Linux核心(并非所有Linux发行版的核心都是开源的)和GCC。

Share

小谢同学写的linux 服务器调优脚本

modify_sysctl.py

# -*- coding: utf-8 -*-
'''
Created on 2015-1-21

@author: xie
'''
'''
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 30000
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.ip_local_port_range = 9000 65535
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
'''
import re,commands
SYSCTL_CONFIG = '/etc/sysctl.conf'
class SetSysctl():
def __init__(self):
self._sysctls = []
self._sysctls.append('net.ipv4.tcp_rmem = 4096 87380 16777216')
self._sysctls.append('net.ipv4.tcp_wmem = 4096 65536 16777216')
self._sysctls.append('net.core.wmem_default = 8388608')
self._sysctls.append('net.core.rmem_default = 8388608')
self._sysctls.append('net.core.rmem_max = 16777216')
self._sysctls.append('net.core.wmem_max = 16777216')
self._sysctls.append('net.core.netdev_max_backlog = 30000')
self._sysctls.append('net.core.somaxconn = 65535')
self._sysctls.append('net.ipv4.tcp_max_syn_backlog = 262144')
self._sysctls.append('net.ipv4.tcp_max_tw_buckets = 6000')
self._sysctls.append('net.ipv4.tcp_tw_recycle = 1')
self._sysctls.append('net.ipv4.tcp_tw_reuse = 1')
self._sysctls.append('net.ipv4.tcp_fin_timeout = 30')
self._sysctls.append('net.ipv4.ip_local_port_range = 9000 65535')
self._sysctls.append('net.ipv4.tcp_syncookies = 1')
self._sysctls.append('net.ipv4.tcp_max_orphans = 262144')
self._sysctls.append('net.ipv4.tcp_synack_retries = 2')
self._sysctls.append('net.ipv4.tcp_syn_retries = 2')
self._sysctls.append('')
self._sysctls.append('kernel.core_pattern = /home/core/core.%p')
self._create_core()
self._read_sysctl()
self._write_sysctl()

def _read_sysctl(self):
network = open(SYSCTL_CONFIG, 'r')
self._lines = []
for line in network:
flag = False
for sysctl in self._sysctls:
regex_str = sysctl.split('=')[0]
ma = re.match(r'^'+regex_str+'.*?', line, re.IGNORECASE)
if ma:
flag = True
break;
if not flag:
self._lines.append(line)
network.close()

def _write_sysctl(self):
sysctls = open(SYSCTL_CONFIG, 'w')
self._lines.extend(self._sysctls)
sysctls.write('\n'.join(self._lines))
sysctls.close()
commands.getoutput('sysctl -p')

def _create_core(self):
commands.getoutput('mkdir /home/core')
commands.getoutput('chown -R mc-ops:mc-ops /home/core')

if __name__ == '__main__':
SetSysctl()

modify_ulimit.py

<br /># -*- coding: utf-8 -*-
#!/usr/bin/env python2.7
'''
Created on 2013-5-6

@author: xie
'''
import commands, re,os

LIMIT_CONF = '/etc/security/limits.conf'
SOFT_NOFILE = '* soft nofile 1048576\n'
HAND_NOFILE = '* hard nofile 1048576\n'
SOFT_NPROC = '* soft nproc 1048576\n'
HAND_NPROC = '* hard nproc 1048576\n'
PROFILE_CONF = '/etc/profile'
ULIMIT_NOFILE = 'ulimit -HSn 1048576\n'

NPROC_LIMIT_CONF = '/etc/security/limits.d/90-nproc.conf'

def modify_ulimit():
lines = []
ulimit = open(LIMIT_CONF, 'r')
for line in ulimit:
ma = re.match(r'.*?soft *?', line, re.IGNORECASE)
mx = re.match(r'.*?hard *?', line, re.IGNORECASE)
if ma or mx:
continue
lines.append(line)
ulimit.close()

lines.append(SOFT_NOFILE)
lines.append(HAND_NOFILE)
lines.append(SOFT_NPROC)
lines.append(HAND_NPROC)

ulimit = open(LIMIT_CONF, 'w')
ulimit.write(''.join(lines))
ulimit.close()

commands.getoutput('ulimit -HSn 1048576')
if not isCentos7():
modify_nproc_ulimit()
writeProfile()

def modify_nproc_ulimit():
lines = []
if os.path.exists(NPROC_LIMIT_CONF):
ulimit = open(NPROC_LIMIT_CONF, 'r')
for line in ulimit:
ma = re.match(r'.*?soft *?', line, re.IGNORECASE)
if ma:
continue
lines.append(line)
ulimit.close()

lines.append('* soft nproc 1048576\n')
lines.append('root soft nproc unlimited\n')

ulimit = open(NPROC_LIMIT_CONF, 'w')
ulimit.write(''.join(lines))
ulimit.close()

def writeProfile():
lines = []
flag = False
profile = open(PROFILE_CONF, 'r')
for line in profile:
ma = re.match(r'.*?ulimit -HSn 1048576.*', line, re.IGNORECASE)
if ma is not None:
flag = True
lines.append(line)
profile.close()
if flag == False:
lines.append(ULIMIT_NOFILE)
profile = open(PROFILE_CONF, 'w')
profile.write(''.join(lines))
profile.close()

def isCentos7():
mage = commands.getoutput('cat /etc/redhat-release').split('\n')
#CentOS Linux release 7.1.1503 (Core)
#CentOS release 6.6 (Final)
cP = re.compile(r'.*\s+(?P\d+).*', re.IGNORECASE)
for mess in mage:
ma = cP.match(mess)
if ma is not None:
ip = ma.group('release')
if ip == '7':
return True
return False
pass

if __name__ == '__main__':
modify_ulimit()

Share

supervisord usage in Centos7.x (via: systemd)

  1. yum install python-setuptools python-pip
  2. pip install supervisor
  3. echo_supervisord_conf > /etc/supervisord.conf
  4. create init script in : /usr/lib/systemd/system/supervisord.service
    “`
    [Unit]
    Description=supervisord – Supervisor process control system for UNIX
    Documentation=http://supervisord.org
    After=network.target
    [Service]
    Type=forking
    ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
    ExecReload=/usr/bin/supervisorctl reload
    ExecStop=/usr/bin/supervisorctl shutdown
    User=root</li>
    </ol>

    [Install]
    WantedBy=multi-user.target

    <pre><code>“`

    Share

TrafficServer源码:the possible operations or msg types sent from remote client to TM

// trafficserver/mgmt/api/NetworkMessage.h
typedef enum
{
  FILE_READ,
  FILE_WRITE,
  RECORD_SET,
  RECORD_GET,
  PROXY_STATE_GET,
  PROXY_STATE_SET,
  RECONFIGURE,
  RESTART,
  BOUNCE,
  EVENT_RESOLVE,
  EVENT_GET_MLT,
  EVENT_ACTIVE,
  EVENT_REG_CALLBACK,
  EVENT_UNREG_CALLBACK,
  EVENT_NOTIFY,                 /* only msg sent from TM to client */
  SNAPSHOT_TAKE,
  SNAPSHOT_RESTORE,
  SNAPSHOT_REMOVE,
  SNAPSHOT_GET_MLT,
  DIAGS,
  STATS_RESET_NODE,
  STATS_RESET_CLUSTER,
  STORAGE_DEVICE_CMD_OFFLINE,
  RECORD_MATCH_GET,
  API_PING,
  SERVER_BACKTRACE,
  UNDEFINED_OP /* This must be last */
} OpType;

Share

在shell 脚本里嵌入python

#!/bin/bash
function pytest() {
python - $@ <<EOT
import sys,datetime
print 'Current Time is %s' % datetime.datetime.now()
print sys.argv
EOT
}


RT=$(pytest $@)
echo my python script says: $RT

Share

elasticsearch_river 配置

1. install es-river plugin

/usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-river-rabbitmq/2.0.0

2. install rabbitmq
2.1 add epel repo
rpm –import https://fedoraproject.org/static/0608B895.txt
wget http://mirrors.yun-idc.com/epel/6/i386/epel-release-6-8.noarch.rpm

rpm -i epel-release-6-8.noarch.rpm

2.2 install erlang
yum -y install erlang

2.3 install rabbitmq
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.3.4/rabbitmq-server-3.3.4-1.noarch.rpm
rpm –import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
yum -y install rabbitmq-server-3.3.4-1.noarch.rpm

2.4 start rabbitmq

/etc/init.d/rabbitmq-server start

3 logstash conf


output{
elasticsearch_river {
es_host => “localhost”
index => “rt-%{+dd.HH.mm.ss}”
rabbitmq_host => “localhost”
workers => 8
}
}

4. restart elasticsearch

5. restart logstash

Share

tz

Standard Offset Canonical ID Aliases
-12:00 Etc/GMT+12
-11:00 Etc/GMT+11
-11:00 Pacific/Apia
-11:00 Pacific/Midway
-11:00 Pacific/Niue
-11:00 Pacific/Pago_Pago Pacific/Samoa, US/Samoa
-10:00 America/Adak America/Atka, US/Aleutian
-10:00 Etc/GMT+10
-10:00 HST
-10:00 Pacific/Fakaofo
-10:00 Pacific/Honolulu US/Hawaii
-10:00 Pacific/Johnston
-10:00 Pacific/Rarotonga
-10:00 Pacific/Tahiti
-09:30 Pacific/Marquesas
-09:00 America/Anchorage US/Alaska
-09:00 America/Juneau
-09:00 America/Nome
-09:00 America/Yakutat
-09:00 Etc/GMT+9
-09:00 Pacific/Gambier
-08:00 America/Dawson
-08:00 America/Los_Angeles US/Pacific, US/Pacific-New
-08:00 America/Santa_Isabel
-08:00 America/Tijuana America/Ensenada, Mexico/BajaNorte
-08:00 America/Vancouver Canada/Pacific
-08:00 America/Whitehorse Canada/Yukon
-08:00 Etc/GMT+8
-08:00 PST8PDT
-08:00 Pacific/Pitcairn
-07:00 America/Boise
-07:00 America/Cambridge_Bay
-07:00 America/Chihuahua
-07:00 America/Dawson_Creek
-07:00 America/Denver America/Shiprock, Navajo, US/Mountain
-07:00 America/Edmonton Canada/Mountain
-07:00 America/Hermosillo
-07:00 America/Inuvik
-07:00 America/Mazatlan Mexico/BajaSur
-07:00 America/Ojinaga
-07:00 America/Phoenix US/Arizona
-07:00 America/Yellowknife
-07:00 Etc/GMT+7
-07:00 MST
-07:00 MST7MDT
-06:00 America/Bahia_Banderas
-06:00 America/Belize
-06:00 America/Cancun
-06:00 America/Chicago US/Central
-06:00 America/Costa_Rica
-06:00 America/El_Salvador
-06:00 America/Guatemala
-06:00 America/Indiana/Knox America/Knox_IN, US/Indiana-Starke
-06:00 America/Indiana/Tell_City
-06:00 America/Managua
-06:00 America/Matamoros
-06:00 America/Menominee
-06:00 America/Merida
-06:00 America/Mexico_City Mexico/General
-06:00 America/Monterrey
-06:00 America/North_Dakota/Center
-06:00 America/North_Dakota/New_Salem
-06:00 America/Rainy_River
-06:00 America/Rankin_Inlet
-06:00 America/Regina Canada/East-Saskatchewan, Canada/Saskatchewan
-06:00 America/Swift_Current
-06:00 America/Tegucigalpa
-06:00 America/Winnipeg Canada/Central
-06:00 CST6CDT
-06:00 Etc/GMT+6
-06:00 Pacific/Easter Chile/EasterIsland
-06:00 Pacific/Galapagos
-05:00 America/Atikokan America/Coral_Harbour
-05:00 America/Bogota
-05:00 America/Cayman
-05:00 America/Detroit US/Michigan
-05:00 America/Grand_Turk
-05:00 America/Guayaquil
-05:00 America/Havana Cuba
-05:00 America/Indiana/Indianapolis America/Fort_Wayne, America/Indianapolis, US/East-Indiana
-05:00 America/Indiana/Marengo
-05:00 America/Indiana/Petersburg
-05:00 America/Indiana/Vevay
-05:00 America/Indiana/Vincennes
-05:00 America/Indiana/Winamac
-05:00 America/Iqaluit
-05:00 America/Jamaica Jamaica
-05:00 America/Kentucky/Louisville America/Louisville
-05:00 America/Kentucky/Monticello
-05:00 America/Lima
-05:00 America/Montreal
-05:00 America/Nassau
-05:00 America/New_York US/Eastern
-05:00 America/Nipigon
-05:00 America/Panama
-05:00 America/Pangnirtung
-05:00 America/Port-au-Prince
-05:00 America/Resolute
-05:00 America/Thunder_Bay
-05:00 America/Toronto Canada/Eastern
-05:00 EST
-05:00 EST5EDT
-05:00 Etc/GMT+5
-04:30 America/Caracas
-04:00 America/Anguilla
-04:00 America/Antigua
-03:00 America/Argentina/San_Luis
-04:00 America/Aruba
-04:00 America/Asuncion
-04:00 America/Barbados
-04:00 America/Blanc-Sablon
-04:00 America/Boa_Vista
-04:00 America/Campo_Grande
-04:00 America/Cuiaba
-04:00 America/Curacao
-04:00 America/Dominica
-04:00 America/Eirunepe
-04:00 America/Glace_Bay
-04:00 America/Goose_Bay
-04:00 America/Grenada
-04:00 America/Guadeloupe America/Marigot, America/St_Barthelemy
-04:00 America/Guyana
-04:00 America/Halifax Canada/Atlantic
-04:00 America/La_Paz
-04:00 America/Manaus Brazil/West
-04:00 America/Martinique
-04:00 America/Moncton
-04:00 America/Montserrat
-04:00 America/Port_of_Spain
-04:00 America/Porto_Velho
-04:00 America/Puerto_Rico
-04:00 America/Rio_Branco America/Porto_Acre, Brazil/Acre
-04:00 America/Santiago Chile/Continental
-04:00 America/Santo_Domingo
-04:00 America/St_Kitts
-04:00 America/St_Lucia
-04:00 America/St_Thomas America/Virgin
-04:00 America/St_Vincent
-04:00 America/Thule
-04:00 America/Tortola
-04:00 Antarctica/Palmer
-04:00 Atlantic/Bermuda
-04:00 Atlantic/Stanley
-04:00 Etc/GMT+4
-03:30 America/St_Johns Canada/Newfoundland
-03:00 America/Araguaina
-03:00 America/Argentina/Buenos_Aires America/Buenos_Aires
-03:00 America/Argentina/Catamarca America/Argentina/ComodRivadavia, America/Catamarca
-03:00 America/Argentina/Cordoba America/Cordoba, America/Rosario
-03:00 America/Argentina/Jujuy America/Jujuy
-03:00 America/Argentina/La_Rioja
-03:00 America/Argentina/Mendoza America/Mendoza
-03:00 America/Argentina/Rio_Gallegos
-03:00 America/Argentina/Salta
-03:00 America/Argentina/San_Juan
-03:00 America/Argentina/Tucuman
-03:00 America/Argentina/Ushuaia
-03:00 America/Bahia
-03:00 America/Belem
-03:00 America/Cayenne
-03:00 America/Fortaleza
-03:00 America/Godthab
-03:00 America/Maceio
-03:00 America/Miquelon
-03:00 America/Montevideo
-03:00 America/Paramaribo
-03:00 America/Recife
-03:00 America/Santarem
-03:00 America/Sao_Paulo Brazil/East
-03:00 Antarctica/Rothera
-03:00 Etc/GMT+3
-02:00 America/Noronha Brazil/DeNoronha
-02:00 Atlantic/South_Georgia
-02:00 Etc/GMT+2
-01:00 America/Scoresbysund
-01:00 Atlantic/Azores
-01:00 Atlantic/Cape_Verde
-01:00 Etc/GMT+1
+00:00 Africa/Abidjan
+00:00 Africa/Accra
+00:00 Africa/Bamako Africa/Timbuktu
+00:00 Africa/Banjul
+00:00 Africa/Bissau
+00:00 Africa/Casablanca
+00:00 Africa/Conakry
+00:00 Africa/Dakar
+00:00 Africa/El_Aaiun
+00:00 Africa/Freetown
+00:00 Africa/Lome
+00:00 Africa/Monrovia
+00:00 Africa/Nouakchott
+00:00 Africa/Ouagadougou
+00:00 Africa/Sao_Tome
+00:00 America/Danmarkshavn
+00:00 Atlantic/Canary
+00:00 Atlantic/Faroe Atlantic/Faeroe
+00:00 Atlantic/Madeira
+00:00 Atlantic/Reykjavik Iceland
+00:00 Atlantic/St_Helena
+00:00 Etc/GMT Etc/GMT+0, Etc/GMT-0, Etc/GMT0, Etc/Greenwich, GMT, GMT+0, GMT-0, GMT0, Greenwich
+00:00 Etc/UCT UCT
+00:00 Etc/UTC Etc/Universal, Etc/Zulu, Universal, Zulu
+00:00 Europe/Dublin Eire
+00:00 Europe/Lisbon Portugal
+00:00 Europe/London Europe/Belfast, Europe/Guernsey, Europe/Isle_of_Man, Europe/Jersey, GB, GB-Eire
+00:00 UTC
+00:00 WET
+01:00 Africa/Algiers
+01:00 Africa/Bangui
+01:00 Africa/Brazzaville
+01:00 Africa/Ceuta
+01:00 Africa/Douala
+01:00 Africa/Kinshasa
+01:00 Africa/Lagos
+01:00 Africa/Libreville
+01:00 Africa/Luanda
+01:00 Africa/Malabo
+01:00 Africa/Ndjamena
+01:00 Africa/Niamey
+01:00 Africa/Porto-Novo
+01:00 Africa/Tunis
+01:00 Africa/Windhoek
+01:00 CET
+01:00 Etc/GMT-1
+01:00 Europe/Amsterdam
+01:00 Europe/Andorra
+01:00 Europe/Belgrade Europe/Ljubljana, Europe/Podgorica, Europe/Sarajevo, Europe/Skopje, Europe/Zagreb
+01:00 Europe/Berlin
+01:00 Europe/Brussels
+01:00 Europe/Budapest
+01:00 Europe/Copenhagen
+01:00 Europe/Gibraltar
+01:00 Europe/Luxembourg
+01:00 Europe/Madrid
+01:00 Europe/Malta
+01:00 Europe/Monaco
+01:00 Europe/Oslo Arctic/Longyearbyen, Atlantic/Jan_Mayen
+01:00 Europe/Paris
+01:00 Europe/Prague Europe/Bratislava
+01:00 Europe/Rome Europe/San_Marino, Europe/Vatican
+01:00 Europe/Stockholm
+01:00 Europe/Tirane
+01:00 Europe/Vaduz
+01:00 Europe/Vienna
+01:00 Europe/Warsaw Poland
+01:00 Europe/Zurich
+01:00 MET
+02:00 Africa/Blantyre
+02:00 Africa/Bujumbura
+02:00 Africa/Cairo Egypt
+02:00 Africa/Gaborone
+02:00 Africa/Harare
+02:00 Africa/Johannesburg
+02:00 Africa/Kigali
+02:00 Africa/Lubumbashi
+02:00 Africa/Lusaka
+02:00 Africa/Maputo
+02:00 Africa/Maseru
+02:00 Africa/Mbabane
+02:00 Africa/Tripoli Libya
+02:00 Asia/Amman
+02:00 Asia/Beirut
+02:00 Asia/Damascus
+02:00 Asia/Gaza
+02:00 Asia/Jerusalem Asia/Tel_Aviv, Israel
+02:00 Asia/Nicosia Europe/Nicosia
+02:00 EET
+02:00 Etc/GMT-2
+02:00 Europe/Athens
+02:00 Europe/Bucharest
+02:00 Europe/Chisinau Europe/Tiraspol
+02:00 Europe/Helsinki Europe/Mariehamn
+02:00 Europe/Istanbul Asia/Istanbul, Turkey
+02:00 Europe/Kaliningrad
+02:00 Europe/Kiev
+02:00 Europe/Minsk
+02:00 Europe/Riga
+02:00 Europe/Simferopol
+02:00 Europe/Sofia
+02:00 Europe/Tallinn
+02:00 Europe/Uzhgorod
+02:00 Europe/Vilnius
+02:00 Europe/Zaporozhye
+03:00 Africa/Addis_Ababa
+03:00 Africa/Asmara Africa/Asmera
+03:00 Africa/Dar_es_Salaam
+03:00 Africa/Djibouti
+03:00 Africa/Kampala
+03:00 Africa/Khartoum
+03:00 Africa/Mogadishu
+03:00 Africa/Nairobi
+03:00 Antarctica/Syowa
+03:00 Asia/Aden
+03:00 Asia/Baghdad
+03:00 Asia/Bahrain
+03:00 Asia/Kuwait
+03:00 Asia/Qatar
+03:00 Asia/Riyadh
+03:00 Etc/GMT-3
+03:00 Europe/Moscow W-SU
+03:00 Europe/Samara
+03:00 Europe/Volgograd
+03:00 Indian/Antananarivo
+03:00 Indian/Comoro
+03:00 Indian/Mayotte
+03:30 Asia/Tehran Iran
+04:00 Asia/Baku
+04:00 Asia/Dubai
+04:00 Asia/Muscat
+04:00 Asia/Tbilisi
+04:00 Asia/Yerevan
+04:00 Etc/GMT-4
+04:00 Indian/Mahe
+04:00 Indian/Mauritius
+04:00 Indian/Reunion
+04:30 Asia/Kabul
+05:00 Antarctica/Mawson
+05:00 Asia/Aqtau
+05:00 Asia/Aqtobe
+05:00 Asia/Ashgabat Asia/Ashkhabad
+05:00 Asia/Dushanbe
+05:00 Asia/Karachi
+05:00 Asia/Oral
+05:00 Asia/Samarkand
+05:00 Asia/Tashkent
+05:00 Asia/Yekaterinburg
+05:00 Etc/GMT-5
+05:00 Indian/Kerguelen
+05:00 Indian/Maldives
+05:30 Asia/Colombo
+05:30 Asia/Kolkata Asia/Calcutta
+05:45 Asia/Kathmandu Asia/Katmandu
+06:00 Antarctica/Vostok
+06:00 Asia/Almaty
+06:00 Asia/Bishkek
+06:00 Asia/Dhaka Asia/Dacca
+06:00 Asia/Novokuznetsk
+06:00 Asia/Novosibirsk
+06:00 Asia/Omsk
+06:00 Asia/Qyzylorda
+06:00 Asia/Thimphu Asia/Thimbu
+06:00 Etc/GMT-6
+06:00 Indian/Chagos
+06:30 Asia/Rangoon
+06:30 Indian/Cocos
+07:00 Antarctica/Davis
+07:00 Asia/Bangkok
+07:00 Asia/Ho_Chi_Minh Asia/Saigon
+07:00 Asia/Hovd
+07:00 Asia/Jakarta
+07:00 Asia/Krasnoyarsk
+07:00 Asia/Phnom_Penh
+07:00 Asia/Pontianak
+07:00 Asia/Vientiane
+07:00 Etc/GMT-7
+07:00 Indian/Christmas
+08:00 Antarctica/Casey
+08:00 Asia/Brunei
+08:00 Asia/Choibalsan
+08:00 Asia/Chongqing Asia/Chungking
+08:00 Asia/Harbin
+08:00 Asia/Hong_Kong Hongkong
+08:00 Asia/Irkutsk
+08:00 Asia/Kashgar
+08:00 Asia/Kuala_Lumpur
+08:00 Asia/Kuching
+08:00 Asia/Macau Asia/Macao
+08:00 Asia/Makassar Asia/Ujung_Pandang
+08:00 Asia/Manila
+08:00 Asia/Shanghai PRC
+08:00 Asia/Singapore Singapore
+08:00 Asia/Taipei ROC
+08:00 Asia/Ulaanbaatar Asia/Ulan_Bator
+08:00 Asia/Urumqi
+08:00 Australia/Perth Australia/West
+08:00 Etc/GMT-8
+08:45 Australia/Eucla
+09:00 Asia/Dili
+09:00 Asia/Jayapura
+09:00 Asia/Pyongyang
+09:00 Asia/Seoul ROK
+09:00 Asia/Tokyo Japan
+09:00 Asia/Yakutsk
+09:00 Etc/GMT-9
+09:00 Pacific/Palau
+09:30 Australia/Adelaide Australia/South
+09:30 Australia/Broken_Hill Australia/Yancowinna
+09:30 Australia/Darwin Australia/North
+10:00 Antarctica/DumontDUrville
+10:00 Asia/Sakhalin
+10:00 Asia/Vladivostok
+10:00 Australia/Brisbane Australia/Queensland
+10:00 Australia/Currie
+10:00 Australia/Hobart Australia/Tasmania
+10:00 Australia/Lindeman
+10:00 Australia/Melbourne Australia/Victoria
+10:00 Australia/Sydney Australia/ACT, Australia/Canberra, Australia/NSW
+10:00 Etc/GMT-10
+10:00 Pacific/Chuuk Pacific/Truk, Pacific/Yap
+10:00 Pacific/Guam
+10:00 Pacific/Port_Moresby
+10:00 Pacific/Saipan
+10:30 Australia/Lord_Howe Australia/LHI
+11:00 Antarctica/Macquarie
+11:00 Asia/Anadyr
+11:00 Asia/Kamchatka
+11:00 Asia/Magadan
+11:00 Etc/GMT-11
+11:00 Pacific/Efate
+11:00 Pacific/Guadalcanal
+11:00 Pacific/Kosrae
+11:00 Pacific/Noumea
+11:00 Pacific/Pohnpei Pacific/Ponape
+11:30 Pacific/Norfolk
+12:00 Antarctica/McMurdo Antarctica/South_Pole
+12:00 Etc/GMT-12
+12:00 Pacific/Auckland NZ
+12:00 Pacific/Fiji
+12:00 Pacific/Funafuti
+12:00 Pacific/Kwajalein Kwajalein
+12:00 Pacific/Majuro
+12:00 Pacific/Nauru
+12:00 Pacific/Tarawa
+12:00 Pacific/Wake
+12:00 Pacific/Wallis
+12:45 Pacific/Chatham NZ-CHAT
+13:00 Etc/GMT-13
+13:00 Pacific/Enderbury
+13:00 Pacific/Tongatapu
+14:00 Etc/GMT-14
+14:00 Pacific/Kiritimati
Share

elasticsearch+logstash+kibana 初探

花了一点时间搭了个初步的测试环境,分析的apache日志。
鉴于网络上的资料都比较过时了,所以在这里log一下。

测试环境 centos6.3 64bit

/********************************************************/
安装:

elasticsearch [goto]

<pre>;Download and install the Public Signing Key
rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch

#Add the following in your /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.1]
name=Elasticsearch repository for 1.1.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.1/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1

#Install
yum install elasticsearch

logstash [goto]

#Add the key
rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch

#Add the following in your /etc/yum.repos.d/logstash.repo
[logstash-1.4]
name=logstash repository for 1.4.x packages
baseurl=http://packages.elasticsearch.org/logstash/1.4/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1

#Install logstash with:
yum install logstash

kibana [download]
这个不用安装,解压然后放在httpd服务的目录里可以直接用是个纯html5应用(就是个网站),而且装在本机不需要配置,如果elasticsearch不在本机请编辑目录下的config.js指定url

/********************************************************/
配置:

elasticsearch 不需要配置,直接run起

/etc/init.d/elasticsearch start

P.S. 这个软件很奇葩,默认装的路径在 /usr/share 下。

logstash 配置文件默认是没有的,配置目录在 /etc/logstash/conf.d/
比如我在此目录下创建了一个配置文件

#/etc/logstash/conf.d/seven.conf
input {
  file {
    path => "/var/log/httpd/access_json.log"
    type => "apache"

    # This format tells logstash to expect 'logstash' json events from the file.
    format => json_event
  }
}

output {
elasticsearch {
    host => "127.0.0.1"
}
}

解释一下,input 这里设置的apache日志格式是个json格式,这就意味着apache的日志要进行改造,这个方式比用redis,grok等方案更简单,apache的配置见后文。

重点注意:

#/etc/init.d/logstash
...
name=logstash
pidfile="/var/run/$name.pid"

#请把原来用户和用户组logstash改成root,不然没有权限读apache日志
LS_USER=root
LS_GROUP=root
LS_HOME=/var/lib/logstash
LS_HEAP_SIZE="500m"
...

kibana 这个也不用配置,直接可以跑

apache [goto]

# Create a log format called 'logstash_json' that emits, in json, the parts of an http
# request I care about. For more details on the features of the 'LogFormat'
# directive, see the apache docs:
# http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"referrer\": \"%{Referer}i\" } }" logstash_json

LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@message\": \"%r\", \"@fields\": { \"user-agent\": \"%{User-agent}i\", \"client\": \"%a\", \"duration_usec\": %D, \"duration_sec\": %T, \"status\": %s, \"request_path\": \"%U\", \"request\": \"%U%q\", \"method\": \"%m\", \"referrer\": \"%{Referer}i\" } }" logstash_ext_json

# Write our 'logstash_json' logs to logs/access_json.log
CustomLog logs/access_json.log logstash_ext_json

提供的cookbook[goto]里还有让apache同时支持传统raw data和json日志的方法,我没试过。

kibana

Share