1. 程式人生 > >學習zabbix(二)

學習zabbix(二)

 

 

超大規模入口網站叢集架構:
wKiom1hltqPBmHVsAABHQ5U8NAM606.jpg

運維30%的時間都在監控,監控要多維度;

監控(單機監控(系統監控)、網路監控、應用監控、分散式監控);

 

業務監控(業務指標-->流量分析-->輿論監控):

流量分析:

SEOsearch engine optimization,指通過站內優化(比如網站結構調整、網站內容建設、網站程式碼優化等)以及站外優化(比如網站站外推廣、網站品牌建設等)使網站滿足搜尋引擎收錄排名需求,在搜尋引擎中提高關鍵詞排名,從而吸引精準使用者進入網站,獲得免費流量,產生直接銷售或品牌推廣;嚴謹的定義如下:

SEO是指在瞭解搜尋引擎自然排名機制的基礎之上,對網站進行內部及外部的調整優化,改進網站在搜尋引擎中關鍵詞的自然排名,獲得更多的展現量,吸引更多目標客戶點選訪問網站,從而達到網路營銷及品牌建設的目標;搜尋引擎檢索原則是不斷更改的,檢索原則的更改會直接導致網站關鍵字在搜尋引擎上排名的變化,所以搜尋引擎優化並非一勞永逸);

PRPR值全稱為PageRank,網頁的級別技術,用來表現網頁等級的一個標準,是Google用於評測一個網頁“重要性”的一種方法,取自Google創始人Larry Page,它是Google排名運演算法則(排名公式)的一部分,用來標識網頁的等級/重要性,級別從010級,10級為滿分,

PR值越高說明該網頁越受歡迎(越重要);例如:一個PR值為1的網站表明這個網站不太具有流行度,而PR值為710則表明這個網站非常受歡迎,或者說極其重要);

PVpage view即頁面瀏覽量,通常是衡量一個網路新聞頻道或網站甚至一條網路新聞的主要指標,網頁瀏覽數是評價網站流量最常用的指標之一,監測網站PV的變化趨勢和分析其變化原因是很多站長定期要做的工作,Page Views中的Page一般是指普通的html網頁,也包含phpjsp等動態產生的html內容,來自瀏覽器的一次html內容請求會被看作一個PV,逐漸累計成為PV總數;使用者每1次對網站中的每個網頁訪問均被記錄1次,使用者對同一頁面的多次訪問,訪問量累計);

IP(獨立IP,是指獨立使用者/獨立訪客,指訪問某個站點或點選某條新聞的不同IP地址的人數,在同一天的00:00-24:00內,獨立IP只記錄第一次進入網站的具有獨立IP的訪問者,假如一臺電腦關機了,30分鐘後重啟,再次訪問這個站那就再計算一次ip,在同一天內再次訪問該網站則不計數,獨立IP訪問者提供了一定時間內不同觀眾數量的統計指標,而沒有反應出網站的全面活動,比如你是ADSL撥號上網的,你撥一次號都自動分配一個ip,這樣你進入了本站,那就算一個ip,當你斷線了而沒清理cookie,之後又撥了一次號,又自動分配到一個ip,你再進來了本站,那麼又統計到一個ip,但是UV(獨立訪客)沒有變,因為2次都是你進入了本站);

UVunique visitor,是指通過網際網路訪問、瀏覽這個網頁的自然人,網站獨立訪客);

 

注:piwik.org(做統計分析,可定製、可開發、可架構;piwik is the leading open-source analytics platform that gives youmore than just powerful analytics:free open-source software;100% data ownership;user privacy protection;user-centric insights;customisable andextensible

 

網路監控:

監控寶http://www.jiankongbao.com/);

smokepingrrdtool作者寫的,支援分散式,是一款用於網路效能監測的監控軟體,通過它可以在自己公司IDC的網路狀況,如延時,丟包率,是否BGP多線等,通過rrdtool製圖方式,圖形化地展示網路的時延情況,進而能夠清楚的判斷出網路的即時通訊情況)

 

 

應用監控(httpdnginxmemcachedredis):

httpd狀態監控:

[[email protected] ~]# rpm -qa httpd

httpd-2.2.15-54.el6.centos.x86_64

[[email protected] ~]# vim /etc/httpd/conf/httpd.conf

LoadModule status_module modules/mod_status.so

LoadModule info_module modules/mod_info.so

ExtendedStatus On

<Location /server-status>

    SetHandler server-status

    Order deny,allow

    Deny from all

    Allow from 10.96.20.89

</Location>

<Location /server-info>

    SetHandler server-info

    Order deny,allow

    Deny from all

    Allow from 10.96.20.89

</Location>

測試:http://10.96.20.118/server-status

wKioL1hlt0CAnKnyAAEFywXBUj0182.jpg

wKiom1hlt0zwbDvsAAB0sXkGl_s894.jpg

 

nginx狀態監控:

[[email protected] ~]# vim /etc/nginx/nginx.conf

http {

……

    server {

……

        location /nginx-status {

            stub_status on;

            access_log off;

            allow 10.96.20.89;

            deny all;

        }

    }

測試:http://10.96.20.113/nginx-status

wKiom1hlt6rzso9eAAA_3lCOEQA703.jpg

active connections   #(當前nginx正處理的活動連線數)

server accepts handled requests   #(總共處理了$1個連線;成功建立$2次握手(證明中間沒有失敗的);總共處理了$3個請求)

reading  #nginx當讀取到clientheader資訊數)

writing  #nginx當前返回給clientheader資訊數)

waiting  #(開啟keepalive的情況下,這個值=active-(reading+writing),為nginx已經處理完正在等候下一次請求指令的駐留連線)

注:生產中要開長連線keppalive,否則連線數過多會有很多TIME_WAITnginx用作LBupstream要作keepalive,預設不開啟;nginxbackend server要作keepaliveapp serverphppdo)要與MySQL server要作keepalivephpredis之間要作keepalivephpmemcached之間要作keepalive,還要有壓縮功能;

 

redis狀態監控:

#redis-cli info [server|clients|memory|persistence|stats|replication|cpu|cluster|keyspace]

[[email protected] ~]# redis-cli info

# Server

redis_version:3.0.7

redis_git_sha1:00000000

redis_git_dirty:0

redis_build_id:a54b0b3a63c1c32b

redis_mode:standalone

os:Linux 2.6.32-431.el6.x86_64 x86_64

arch_bits:64

multiplexing_api:epoll

gcc_version:4.4.7

process_id:2806

run_id:e9ce8a9e21c8ba87b46fd1d75d8078f26745ca3e

tcp_port:6379

uptime_in_seconds:19

uptime_in_days:0

hz:10

lru_clock:14918416

config_file:/etc/redis.conf

# Clients

connected_clients:1

client_longest_output_list:0

client_biggest_input_buf:0

blocked_clients:0

# Memory

used_memory:879256

used_memory_human:858.65K

used_memory_rss:2441216

used_memory_peak:879256

used_memory_peak_human:858.65K

used_memory_lua:36864

mem_fragmentation_ratio:2.78

mem_allocator:jemalloc-3.6.0

# Persistence

loading:0

rdb_changes_since_last_save:15003

rdb_bgsave_in_progress:0

rdb_last_save_time:1474536189

rdb_last_bgsave_status:ok

rdb_last_bgsave_time_sec:-1

rdb_current_bgsave_time_sec:-1

aof_enabled:1

aof_rewrite_in_progress:0

aof_rewrite_scheduled:0

aof_last_rewrite_time_sec:-1

aof_current_rewrite_time_sec:-1

aof_last_bgrewrite_status:ok

aof_last_write_status:ok

aof_current_size:519180

aof_base_size:519180

aof_pending_rewrite:0

aof_buffer_length:0

aof_rewrite_buffer_length:0

aof_pending_bio_fsync:0

aof_delayed_fsync:0

# Stats

total_connections_received:1

total_commands_processed:0

instantaneous_ops_per_sec:0

total_net_input_bytes:14

total_net_output_bytes:0

instantaneous_input_kbps:0.00

instantaneous_output_kbps:0.00

rejected_connections:0

sync_full:0

sync_partial_ok:0

sync_partial_err:0

expired_keys:0

evicted_keys:0

keyspace_hits:0

keyspace_misses:0

pubsub_channels:0

pubsub_patterns:0

latest_fork_usec:0

migrate_cached_sockets:0

# Replication

role:master

connected_slaves:0

master_repl_offset:0

repl_backlog_active:0

repl_backlog_size:1048576

repl_backlog_first_byte_offset:0

repl_backlog_histlen:0

# CPU

used_cpu_sys:0.03

used_cpu_user:0.00

used_cpu_sys_children:0.00

used_cpu_user_children:0.00

# Cluster

cluster_enabled:0

# Keyspace

db0:keys=4,expires=0,avg_ttl=0

[[email protected] ~]# redis-cli info stats

# Stats

total_connections_received:3

total_commands_processed:1

instantaneous_ops_per_sec:0

total_net_input_bytes:54

total_net_output_bytes:2142

instantaneous_input_kbps:0.00

instantaneous_output_kbps:0.00

rejected_connections:0

sync_full:0

sync_partial_ok:0

sync_partial_err:0

expired_keys:0

evicted_keys:0

keyspace_hits:0

keyspace_misses:0

pubsub_channels:0

pubsub_patterns:0

latest_fork_usec:0

migrate_cached_sockets:0

 

memcached狀態監控:

[[email protected] ~]# memcached -m 64 -n 48 -f 1.1 -vv -u nobody -d

[[email protected] ~]# netstat -tnulp | grep:11211

tcp       0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      9983/memcached     

tcp       0      0 :::11211                    :::*                        LISTEN      9983/memcached     

udp       0      0 0.0.0.0:11211               0.0.0.0:*                               9983/memcached     

udp       0      0 :::11211                    :::*                                   9983/memcached     

[[email protected] ~]# telnet 10.96.20.113 11211

Trying 10.96.20.113...

<36 new auto-negotiating client connection

Connected to 10.96.20.113.

Escape character is '^]'.

stats

36: Client using the ascii protocol

<36 stats

STAT pid 9983

STAT uptime 212

STAT time 1474537274

STAT version 1.4.25

STAT libevent 2.0.22-stable

STAT pointer_size 64

STAT rusage_user 0.003999

STAT rusage_system 0.003999

STAT curr_connections 10

STAT total_connections 11

STAT connection_structures 11

STAT reserved_fds 20

STAT cmd_get 0

STAT cmd_set 0

STAT cmd_flush 0

STAT cmd_touch 0

STAT get_hits 0

STAT get_misses 0

STAT delete_misses 0

STAT delete_hits 0

STAT incr_misses 0

STAT incr_hits 0

STAT decr_misses 0

STAT decr_hits 0

STAT cas_misses 0

STAT cas_hits 0

STAT cas_badval 0

STAT touch_hits 0

STAT touch_misses 0

STAT auth_cmds 0

STAT auth_errors 0

STAT bytes_read 7

STAT bytes_written 0

STAT limit_maxbytes 67108864

STAT accepting_conns 1

STAT listen_disabled_num 0

STAT time_in_listen_disabled_us 0

STAT threads 4

STAT conn_yields 0

STAT hash_power_level 16

STAT hash_bytes 524288

STAT hash_is_expanding 0

STAT malloc_fails 0

STAT bytes 0

STAT curr_items 0

STAT total_items 0

STAT expired_unfetched 0

STAT evicted_unfetched 0

STAT evictions 0

STAT reclaimed 0

STAT crawler_reclaimed 0

STAT crawler_items_checked 0

STAT lrutail_reflocked 0

END

^]

telnet> quit

Connection closed.

<36 connection closed.

[[email protected] ~]#

 

 

單機監控:

IPMI是智慧型平臺管理介面(Intelligent Platform Management Interface),是管理基於 Intel結構的企業系統中所使用的外圍裝置採用的一種工業標準,該標準由英特爾、惠普、NEC、美國戴爾電腦和SuperMicro等公司制定,使用者可以利用IPMI監視伺服器的物理健康特徵,如溫度、電壓、風扇工作狀態、電源狀態等,而且更為重要的是IPMI是一個開放的免費標準;自1998年,IPMI論壇建立了IPMI標準以來,其已經得到了170 多家供應商的支援,這使得其逐漸成為了一個完整地包括伺服器和其他系統(如儲存裝置、網路和通訊裝置)的硬體管理規範,目前該標準最新版本為IPMI 2.0,該版本在原有基礎上有了不少的改進,包括可以通過串列埠、Modem以及Lan等遠端環境管理伺服器系統(包括遠端開關機),以及在安全、VLAN 和刀片支援等方面的提高;IPMI針對大量監控、控制和自動回覆伺服器的作業,提供了智慧型的管理方式,此標準適用於不同的伺服器拓撲學,以及WindowsLinux SolarisMac或是混合型的作業系統,此外,由於IPMI可在不同的屬性值下運作,即使伺服器本身的運作不正常,或是由於任何原因而無法提供服務,IPMI仍可正常運作;

[[email protected] ~]# yum -y install OpenIPMI

 

根據服務型別確定監控指標;確定性能基準線;

 

cpumemoryiodisk ionetwork io):

cpu

cpu scheduler

cscontext switchcs的數目直接關係到cpu的利用率,如果cpu利用率保持在一定的均衡狀態,大量的cs是正常的);

run queues執行佇列(每個processor執行佇列不超過過1-3個執行緒,一個雙處理器runqueues不要超過6個執行緒);

cpu utilization(如果一個cpu被充分使用,利用率分類之間均衡的比例應該是:65%-70%user space30%-35%kernel space0%-5%idle time);

 

注:GSLB Global Server Load Balance,全域性負載均衡,作用:實現在廣域網(包括網際網路)上不同地域的伺服器間的流量調配,保證使用最佳的伺服器服務離自己最近的客戶,從而確保訪問質量;分類(基於DNS實現、基於重定向實現、基於路由協議實現);特點(能通過判斷伺服器的負載,包括CPU佔用、頻寬佔用等資料,決定伺服器的可用性,同時能判斷使用者(訪問者)與伺服器間的鏈路狀況,選擇鏈路狀況最好的伺服器,因此GSLB是對伺服器和鏈路進行綜合判斷來決定由哪個地點的伺服器來提供服務,實現異地伺服器群服務質量的保證;使用範圍(有有多個站點的系統,最常見的是在CDN系統中作為核心的流量排程系統);

 

電商架構:

browserbrowser對單個域名的內容下載是有限制的,用多域名解決;browser有三種快取協商方法:最後修改時間If-Modified-SinceLast-Modifiedetag、過期時間;優化browser快取;減少http請求數(合併css、合併js、圖片用背景偏移技術、前端用懶載入(yahoo的懶載入12條軍規)));

CDN(動態域名解析,智慧DNS,反向代理快取squid|varnish|GSLB);

LVS間高可用,其後用三個haproxy

LB(元件分離,如static.example.compic.example.comjs.example.comjob用於訪問後端動態內容生成靜態頁面;nginxopenfilesendfilekeepalivegzip),nginx+tomcat|php(連線頻率;lua+xss+sql注入+ua限制+頻率限制));

靜態頁面主備server間用rsync同步;

共享儲存(NFS|GlusterFS|MooseFS);

內部LBSOAuserprice、運費、購物車、規則);

ELK搜尋;

JS(智慧推薦,js+hadoop+mapreduce+mahout+MySQL);

mail(觸發式郵件、智慧營銷類郵件);

SMS(觸發類、營銷類;億美軟通);

分散式快取(memcached|redis);

MQrabbitMQ|ActiveMQ);

DAL+MySQL|MongoDB|hadoop

 

[[email protected] ~]# which ethtool

/sbin/ethtool

[[email protected] ~]# ethtool eth0

Settings for eth0:

         Supportedports: [ TP ]

         Supportedlink modes:   10baseT/Half 10baseT/Full

                                 100baseT/Half100baseT/Full

                                 1000baseT/Full

         Supportedpause frame use: No

         Supportsauto-negotiation: Yes

         Advertisedlink modes:  10baseT/Half 10baseT/Full

                                 100baseT/Half100baseT/Full

                                 1000baseT/Full

         Advertisedpause frame use: No

         Advertisedauto-negotiation: Yes

         Speed:1000Mb/s

         Duplex:Full

         Port:Twisted Pair

         PHYAD:0

         Transceiver:internal

         Auto-negotiation:on

         MDI-X:Unknown

         SupportsWake-on: d

         Wake-on:d

         Currentmessage level: 0x00000007 (7)

                                   drv probe link

         Linkdetected: yes

 

[[email protected] ~]# yum -y install iftop   #display bandwidthusage on an interface by host,檢視網路流量,在clientserver之間互動的流量)

[[email protected] ~]# which iftop

/usr/sbin/iftop

[[email protected] ~]# iftop -n

 

 

tcp狀態11種(重點LISTENESTABLISHEDTIME_WAITCLOSE_WAIT):

[[email protected] ~]# netstat-ant | awk '/^tcp/{STATE[$NF]++}END{for (KEY in STATE) print KEY,STATE[KEY]}'

ESTABLISHED 5

LISTEN 16

[[email protected] ~]# which ss   #another utility toinvestigate sockets

/usr/sbin/ss

[[email protected] ~]# ss -ant | awk 'NR>1{STATE[$1]++}END{for (KEY in STATE) print KEY,STATE[KEY]}'

ESTAB 5

LISTEN 16

 

 

nmon,幫助在一個螢幕上顯示所有重要的效能優化資訊,並動態地對其進行更新;分析 AIX Linux 效能的免費工具,這個高效的工具可以工作於任何啞螢幕、telnet 會話、甚至撥號線路,另外它並不會消耗大量的 CPU 週期,通常低於百分之二,在更新的計算機上,其CPU使用率將低於百分之一;使用啞螢幕,在螢幕上對資料進行顯示,並且每隔兩秒鐘對其進行更新,然而,您可以很容易地將這個時間間隔更改為更長或更短的時間段,如果您拉伸視窗,並在X WindowsVNCPuTTY 或類似的視窗中顯示這些資料,nmon 工具可以同時輸出大量的資訊;nmon 工具還可以將相同的資料捕獲到一個文字檔案,便於以後對報告進行分析和繪製圖形,輸出檔案採用電子表格的格式.csv

http://nmon.sourceforge.net/pmwiki.php?n=Site.Download

[[email protected] ~]# chmod 755 nmon16e_x86_rhel65

[[email protected] ~]#./nmon16e_x86_rhel65 --help

./nmon16e_x86_rhel65: invalid option -- '-'

Hint for nmon16e_x86_rhel65 version 16e

         FullHelp Info : nmon16e_x86_rhel65 -h

         On-screenStats: nmon16e_x86_rhel65

         DataCollection: nmon16e_x86_rhel65 -f [-s <seconds>] [-c <count>][-t|-T]

         CapacityPlan  : nmon16e_x86_rhel65 -x

Interactive-Mode:

         Readthe Welcome screen & at any time type: "h" for more help

         Type"q" to exit nmon

For Data-Collect-Mode

         -f            Must be the first option on theline (switches off interactive mode)

                       Saves data to a CSV Spreadsheetformat .nmon file in then local directory

                       Note: -f sets a defaults -s300-c288    which you can then modify

         FurtherData Collection Options:

         -s<seconds>  time between datasnapshots

         -c<count>    of snapshots beforeexiting

         -t            Includes Top Processes stats (-Talso collects command arguments)

         -x            Capacity Planning=15 min snapshotsfor 1 day. (nmon -ft -s 900 -c 96)

---- End of Hints

 

[[email protected] ~]# ./nmon16e_x86_rhel65

wKioL1hlurjRe1R3AABz5KowsP4223.jpg

m

wKioL1hlusXSV-ZRAABNiNvoOBg445.jpg

 

 

[[email protected] ~]# yum -y install screen   #screen manager with VT100/ANSI terminal emulation

具體使用(在編譯核心或執行指令碼時,在需要很長時間的情況下,用來防止終端意外終止導致核心編譯中斷或執行的指令碼自動停止):

[[email protected] ~]# screen   #(會自動跳至一個全新的視窗)

[[email protected] ~]# ./test.sh   #(在新生成的視窗中執行指令碼或編譯核心,然後直接ctrl+a,d退出到上一個窗口裡)

[[email protected] ~]# screen-list   #(使用-list-ls,檢視當前開了幾個視窗;若要恢復某個使用-r

There is a screen on:

         30483pxs-0.test1   (Detached)

1 Socket in /var/run/screen/S-root.

[[email protected] ~]# screen -r 22862   #(恢復22862,剛執行指令碼的那個視窗)

[[email protected] ~]# pstree   #(查出當前在哪個bash下,若不用哪一個bash直接ctrl+d

……

     ├─screen───bash───pstree

     ├─sshd───sshd───bash───screen

 

#top

#vmstat 1 10

#mpstat 1 10

 

[[email protected] ~]# free -m

            total       used       free    shared    buffers     cached

Mem:           474        437         37          0         12         63

-/+ buffers/cache:        361        113

Swap:        1983        344       1639

[[email protected] ~]# sync

[[email protected] ~]# echo 1 > /proc/sys/vm/drop_caches   #to free pagecache

[[email protected] ~]# echo 2 > /proc/sys/vm/drop_caches   #to free dentries and inodes

[[email protected] ~]# echo 3 > /proc/sys/vm/drop_caches   #to free pagecachedentriesinodes

[[email protected] ~]# free -m

            total       used       free    shared    buffers     cached

Mem:           474        368        105          0          0         11

-/+ buffers/cache:        357        117

Swap:         1983        344       1639

 

[[email protected] ~]# yum -y install iotop

[[email protected] ~]# iotop

Total DISK READ: 0.00 B/s | Total DISKWRITE: 0.00 B/s

 TID  PRIO  USER    DISK READ  DISK WRITE  SWAPIN    IO>    COMMAND          

 2560be/4 root        0.00 B/s    0.00 B/s 0.00 %  0.00 % python2.6~-master-d

    1be/4 root        0.00 B/s    0.00 B/s 0.00 %  0.00 % init

    2be/4 root        0.00 B/s    0.00 B/s 0.00 %  0.00 % [kthreadd]

    3rt/4 root        0.00 B/s    0.00 B/s 0.00 %  0.00 % [migration/0]

    4be/4 root        0.00 B/s    0.00 B/s 0.00 %  0.00 % [ksoftirqd/0]

……

 

 

 

zabbix安裝:

test1192.168.23.129server-sideand agent-side);

test2192.168.23.130agent-side);

[[email protected] ~]# uname -rm

2.6.32-431.el6.x86_64 x86_64

[[email protected] ~]# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.5(Santiago)

[[email protected] ~]# ls /etc/yum.repos.d   #(準備163yum源)

CentOS6-Base-163.repo        epel-testing.repo

epel-release-6-8.noarch.rpm  rhel-source.repo.backup_20161102

epel.repo

 

test1

[[email protected] ~]# yum -y install zabbix22-server zabbix22-web zabbix22-web-mysql zabbix22-dbfiles-mysql zabbix22-agent mysql-server mysql php php-devel php-mysql

[[email protected] ~]# service mysqld start

[[email protected] ~]# mysql

mysql> CREATE DATABASE zabbix CHARACTER SET utf-8;   #(字符集要是utf8

mysql> SHOW CREATE DATABASE zabbix;

+----------+-----------------------------------------------------------------+

| Database | Create Database                                                 |

+----------+-----------------------------------------------------------------+

| zabbix  | CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 */ |

+----------+-----------------------------------------------------------------+

1 row in set (0.00 sec)

mysql> GRANT ALL ON zabbix.* TO 'zabbix'@'192.168.23.129' IDENTIFIED BY 'zabbix';

Query OK, 0 rows affected (0.00 sec)

[[email protected] ~]# cd /usr/share/zabbix-mysql/; ls   #schema.sql各種表結構;images.sql基本資料;data.sql自帶模板;這三個DB指令碼匯入時有先後順序,先schema.sqlimages.sql最後data.sql

data.sql  images.sql schema.sql  upgrades

[[email protected] zabbix-mysql]# mysql -u root -p zabbix < schema.sql   #(預設密碼為空)

Enter password:

[[email protected] zabbix-mysql]# mysql -u root -p zabbix < images.sql

Enter password:

[[email protected] zabbix-mysql]# mysql -u root -p zabbix < data.sql

Enter password:

[[email protected] zabbix-mysql]# mysql -e 'USE zabbix;SHOW TABLES;'

……

[[email protected] zabbix-mysql]# vim /etc/zabbix_server.conf

DBHost=192.168.23.129

DBPassword=zabbix

[[email protected] zabbix-mysql]# vim /etc/zabbix_agentd.conf   #(更改/etc/zabbix_agentd.conf/etc/zabbix_agent.conf是模板檔案)

Server=192.168.23.129

[[email protected] zabbix-mysql]# grep '^[a-Z]' /etc/zabbix_server.conf

LogFile=/var/log/zabbixsrv/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbixsrv/zabbix_server.pid

DBName=zabbix

DBUser=zabbix

DBHost=192.168.23.129

DBPassword=zabbix

DBSocket=/var/lib/mysql/mysql.sock

AlertScriptsPath=/var/lib/zabbixsrv/alertscripts

ExternalScripts=/var/lib/zabbixsrv/externalscripts

TmpDir=/var/lib/zabbixsrv/tmp

[[email protected] zabbix-mysql]# grep '^[a-Z]' /etc/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=192.168.23.129

ServerActive=127.0.0.1

Hostname=Zabbix server

[[email protected] zabbix-mysql]# service zabbix-server start

Starting Zabbix server:                                    [  OK  ]

[[email protected] zabbix-mysql]# service zabbix-agentd start

Starting Zabbix agent:                                     [  OK  ]

[[email protected] zabbix-mysql]# ps aux | grep zabbix

……

[[email protected] zabbix-mysql]# netstat -tnulp | grep zabbix

tcp       0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      24172/zabbix_agentd

tcp       0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      24202/zabbix_server

tcp       0      0 :::10050                    :::*                        LISTEN      24172/zabbix_agentd

tcp       0      0 :::10051                    :::*                        LISTEN      24202/zabbix_server

[[email protected] zabbix-mysql]# ls /etc/httpd/conf.d   #(檢視有zabbix.conf

mod_dnssd.conf  php.conf README  welcome.conf  zabbix.conf

[[email protected] zabbix-mysql]# service httpd start

Starting httpd: httpd: Could not reliablydetermine the server's fully qualified domain name, using 192.168.23.129 forServerName

                                                          [  OK  ]

 

 

test2

[[email protected] ~]# yum -y install zabbix22-agent

[[email protected] ~]# vim /etc/zabbix_agentd.conf 

Server=192.168.23.129

[[email protected] ~]# service zabbix-agentd start

Starting Zabbix agent:                                     [  OK  ]

[[email protected] ~]# netstat -tnulp | grep zabbix

tcp       0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      95294/zabbix_agentd

tcp       0      0 :::10050                    :::*                        LISTEN      95294/zabbix_agentd

 

 

訪問http://192.168.23.129/zabbix

wKioL1hlvvXTfrSrAABbZm96xfw024.jpg

Next

wKiom1hlvwjyFOONAACKoC3y9z0450.jpg

[[email protected] zabbix-mysql]# vim /etc/php.ini   #(此處,改跳紅的部分;PRCpeople'srepublic of china

[PHP]

post_max_size = 16M

max_execution_time = 300

max_input_time = 300

[Date]

date.timezone = RPC

[[email protected] zabbix-mysql]# service httpd restart

Stopping httpd:                                            [ OK  ]

Starting httpd: httpd: Could not reliablydetermine the server's fully qualified domain name, using 192.168.23.129 forServerName

                                                          [  OK  ]

wKioL1hlvxXSUQTNAACD1MYDsok363.jpg

wKioL1hlvyCQbYERAAB2f1VyynU089.jpg

Database host192.168.23.129

Database port0表示預設,即3306

Userzabbix

Passwordzabbix

Test connection-->Next

wKiom1hlvzDjckDnAABlw9c1K9A915.jpg

Host192.168.23.129

Port10051

Nameu

Next

wKioL1hlv0HzMtGbAAB74c0AzRk569.jpg

Next

wKiom1hlv1PxVnZRAABYqKkVLRU787.jpg

Finish

[[email protected] zabbix-mysql]# ll /etc/zabbix/web/zabbix.conf.php

-rw-r--r--. 1 apache apache 427 Nov  5 20:42 /etc/zabbix/web/zabbix.conf.php

wKioL1hlv2PTmmBGAAA_r2nfV2c889.jpg

UsernameAdmin

Passwordzabbix

 

若切至中文有亂碼,解決辦法:

1、檢視/etc/httpd/conf.d/zabbix.conf得知zabbix網頁目錄為/usr/share/zabbix/

2、檢視/usr/share/zabbix/include/defines.inc.php得知字型目錄位置:

define('ZBX_FONTPATH',                          '/usr/share/fonts/dejavu');// where to search for font (GD > 2.0.18)

define('ZBX_GRAPH_FONT_NAME',           'DejaVuSans'); // font file name

3、將win中的任意字型(控制面板-->字型,例如仿宋或華文雅黑)複製到/usr/share/fonts/dejavu/下並覆蓋改名為DejaVuSans.ttf

 

wKiom1hl4zmBFU3XAAERyZqnvK8180.jpg

 

關閉guest使用者,改Admin密碼:

Administration-->Users-->GuestsDisabled selectedGo(1),確定

Administration-->Users-->Members列的Admin(Zabbix administrators),點Change password

 

注:下圖,監控中、資產記錄、報表、組態、管理;

wKiom1hl42KChZcdAAAmecwX1wk554.jpg

Administrationsuper admin才能看到,標籤有:

一般;

分佈管理;

認證(internalldaphttp);

使用者(重要,許可權是根據使用者組設的,生產中不同的部門為不同的使用者組);

示警媒介型別(預設三種emailjabbersms,若用email本地要啟動相關的服務還要認證,通常使用自定義指令碼);

指令碼;

審計(誰幹了什麼事);

佇列;

警報;

安裝;

 

右上角Profile,可改languagetheme

wKioL1hl44XxQUAuAACFyRzhYko349.jpg

 

注:不允許監控項中的觸發器是關閉狀態,可先設為“維護模式”

 

wKioL1hl46bRgYeWAAAgw6yeOak554.jpg

組態中,標籤有:

主機群組;

模板;

主機;

維修;

動作;

篩選;

簡報片展示;

拓撲圖;

搜尋;

IT服務;

 

Configuration-->Hosts中,若Availability為紅色的Z,點開其NameIP改為192.168.23.129

 

新增主機:

Configuration-->HostsCreatehost-->

Host nametest2

Visable nametest2

New groupdemo

IP address192.168.23.130

Port10050

StatusMonitored

wKiom1hl48KyGeWvAABBqhftEH8754.jpg

Host標籤旁的Templates,在Link new templates中搜索linux,選Template OS LinuxAdd-->Save

 

Macros(巨集,即變數,若用中文版為巨集)

Host inventory(主機資產記錄,手動、自動)

 

Monitoring中,標籤有:

DashBoard儀表板;

總覽;

web

最近資料;

觸發器(事件管理、故障管理、問題管理;

事件;

圖形(GroupHostGraph;若字符集有問題,將win的微軟雅黑copyzabbix server);

篩選(常用,點右上角“+”,在儀表板中檢視“常用的篩選”,在“組態”中選“篩選配置”);

拓撲圖;

探索;

IT服務;

wKiom1hl5FyTfzK-AAAkJPNrZJY472.jpg

Monitoring-->Dashboard-->PERSONALDASHBOARD

system status

host status

web monitoring

last 20 issues(最近20個議題,最近發生的事件)

wKioL1hl5G7yXqHPAADhoghO4Ic038.jpg

 

 

 

新增報警:

注:報警針對使用