[Zabbix] Zabbix 基礎安裝

首先先看官網: https://www.zabbix.com/download

官網可以根據你的作業系統與zabbix版本, 給出對應的指令

我選擇的是 zabbix 3.4版
作業系統為 Ubuntu 16.04
使用MySQL, 換成MariaDB也可

安裝zabbix


wget https://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
dpkg -i zabbix-release_3.4-1+xenial_all.deb
apt update
apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent

# 登入MySQL/MariaDB
mysql -uroot -p
password
# 建立預設的 zabbix 資料庫
mysql> create database zabbix character set utf8 collate utf8_bin;
# 建立 zabbix 用戶, 密碼設成 password (可把password換成自己想要的)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
# 使用zabbix用戶將預設的table匯入zabbix資料庫內
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix


安裝MySQL

可以參考: digital ocean


sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation

# 觀看 mysql 是否真的有在 running
systemctl status mysql.service


安裝PHP

可以參考我這篇: 安裝PHP


add-apt-repository ppa:ondrej/php && apt-get update
apt-get install -y php5.6 \
php5.6-xml \
php5.6-dev \
php5.6-fpm \
php5.6-mysql \
php5.6-mbstring \
php5.6-curl \
php5.6-gd \
php-imagick \
php5.6-bcmath

# 將php5.6-fpm內的設定修改 listen = 127.0.0.1:9000
vi /etc/php/5.6/fpm/pool.d/www.conf
sudo service php5.6-fpm restart
vi /etc/php/5.6/fpm/php.ini


修改php.ini


max_execution_time = 300
max_input_time = 300
post_max_size = 16M
upload_max_filesize = 16M
date.timezone = Asia/Taipei



設定nginx


cd /etc/ngnix/site_avaialble && vi zabbix.conf

server {
        listen 8088;
        server_name 主機IP或是Domain;
#       access_log /var/log/nginx/zabbix.log main; 
        root /usr/share/zabbix;
        index index.php;

location /{
       try_files $uri $uri/ /index.php?$args;

}
location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PHP_VALUE "newrelic.appname=zabbix";
        include        fastcgi_params;
    }


}

ln -s /etc/nginx/site-available/zabbix.conf /etc/nginx/site-enable
nginx -s reload


編輯/etc/zabbix/zabbix_server.conf


## 記得修改zabbix_server.conf, 這樣才連的到資料庫
vim /etc/zabbix/zabbix_server.conf
DBPassword=password


# 啟動 zabbix server
systemctl start zabbix-server
systemctl enable zabbix-server

# 校正主機時間為台灣時間
cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime


之後就可以透過 ip or 網址, ex:
http://xxx.xxx.xxx.xxx:8088
連進去zabbix的設定頁了!
設定完之後預設帳號密碼為
Username: admin
Password: zabbix

安裝Grafana套件


wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.2.1_amd64.deb
sudo dpkg -i grafana_5.2.1_amd64.deb
systemctl daemon-reload
systemctl enable grafana-server
# 啟動 grafana
systemctl start grafana-server
# 檢查grafana 是否有正常運行
systemctl status grafana-server
# 移除下載的 grafana_5.2.1_amd64.deb
rm -f grafana_5.2.1_amd64.deb 

# 安裝 Grafana Zabbix 套件
grafana-cli plugins install alexanderzobnin-zabbix-app
service grafana-server restart


裝好之後就可以在
http://xxx.xxx.xxx.xxx:3000
看到grafana的頁面囉, 有需要隱藏port號的人在自行用 Nginx 處理囉!

更快可以開始使用 - docker

使用 docker

留言

這個網誌中的熱門文章

[翻譯] 介紹現代網路負載平衡與代理伺服器

Grafana K6

Linux 事件驅動筆記