[Up]常用資訊

[重點文章] 重點文章 [重點文章] 重點文章

2020年4月13日 星期一

[Debian] 安裝 zabbix server 在 debian 10

[Debian] 安裝 zabbix server 在 debian 10

建立安裝zabbix 安裝流程

中文化
事前準備
設定語系
# locale -a
# dpkg-reconfigure locales (安裝語系)
# apt-get install xfonts-intl-chinese
# apt-get -y install apache2

修改中文語系

sed -i '/zh_TW/s/false/true/' /usr/share/zabbix/include/locales.inc.php

上傳 中文自行檔

目标目录:/usr/share/zabbix/fonts/
cp kaiu.ttf /usr/share/zabbix/fonts/
Debian10 + zabbix 2  字型目錄為 /usr/share/zabbix/assets/fonts/

修改簡體中文語系 亂碼
[root@zabbix ~]# sed -i  's/graphfont/simkai/g'  /usr/share/zabbix/include/defines.inc.php
換成繁體中文字形
[root@zabbix ~]# sed -i 's/graphfont/kaiu/g' /usr/share/zabbix/include/defines.inc.php

上傳 SNMP MIB檔案路徑

/usr/share/snmp/mibs/

a. Install Zabbix repository

# wget https://repo.zabbix.com/zabbix/4.4/debian/pool/main/z/zabbix-release/zabbix-release_4.4-1+buster_all.deb
# dpkg -i zabbix-release_4.4-1+buster_all.deb
# apt update
b. Install Zabbix server, frontend, agent

# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent
c. Create initial database

先設定 root 密碼
基本安全性指令
mysql_secure_installation

出現以下問題:
1、Enter current password for root (enter for none):
(直接enter,預設MariaDB沒有密碼)
2、Switch to unix_socket authentication [Y/n]
(n,切換到unix_socket身份驗證)
3、Change the root password? [Y/n]
(Y,設定ROOT密碼)
4、Remove anonymous users? [Y/n]
(Y,移除匿名登入)
5、Disallow root login remotely? [Y/n]
(n,移除遠端root登入權限)
6、Remove test database and access to it? [Y/n]
(Y,移除測試資料庫及帳號)
7、Reload privilege tables now? [Y/n]
(Y,重新載入權限表)

登入指令
# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';
mysql> quit;
On Zabbix server host import initial schema and data. You will be prompted to enter your newly created password.

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
d. Configure the database for Zabbix server <\br> Edit file /etc/zabbix/zabbix_server.conf

Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password
e. Configure PHP for Zabbix frontend<\br> Edit file /etc/zabbix/apache.conf, uncomment and set the right timezone for you.

# php_value date.timezone Europe/Riga
f. 重新啟動 Zabbix server and agent processes

# systemctl restart zabbix-server zabbix-agent apache2
# systemctl enable zabbix-server zabbix-agent apache2
連接你的 server http://server_ip_or_name/zabbix https://sbcode.net/zabbix/proxy-install/ 安裝 zabbix Proxy 上 的 agent設定

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
SourceIP=zabbix_proxy_IP
Server=zabbix_proxy_IP
ServerActive=zabbix_proxy_IP, zabbix_server_IP
Hostname=zabbix_proxy_IP
Timeout=30
AllowRoot=1
Include=/etc/zabbix/zabbix_agentd.d/

#
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
SourceIP=192.168.96.125  # 我的 Zabbix_proxy 
Server=192.168.96.125    #zabbix_proxy_IP
ServerActive=192.168.96.101, 192.168.96.125  #zabbix_proxy_IP, zabbix_server_IP
Hostname=Debian10-2-Zabbix-4-4-Proxy-01 # 這要設定主機名稱 這樣 zabbix server 的名稱要對應一致才會運作 不然會收不到資料
Timeout=30
AllowRoot=1
Include=/etc/zabbix/zabbix_agentd.d/

## 安裝 Proxy 2


wget https://repo.zabbix.com/zabbix/4.4/raspbian/pool/main/z/zabbix-release/zabbix-release_4.4-1+buster_all.deb
wget https://repo.zabbix.com/zabbix/4.4/debian/pool/main/z/zabbix-release/zabbix-release_4.4-1+buster_all.deb
sudo dpkg -i zabbix-release_4.4-1+buster_all.deb

sudo apt update

sudo apt install -y zabbix-proxy-sqlite3 zabbix-agent zabbix-sender zabbix-get
apt install -y zabbix-get

https://sbcode.net/zabbix/proxy-install/

Zabbix Proxy 4.4 version (supported until 2020, but has the latest features)
sudo wget https://repo.zabbix.com/zabbix/4.4/debian/pool/main/z/zabbix-release/zabbix-release_4.4-1+$(lsb_release -sc)_all.deb
sudo dpkg -i zabbix-release_4.4-1+$(lsb_release -sc)_all.deb
sudo apt update
sudo apt -y install zabbix-proxy-mysql

wget https://repo.zabbix.com/zabbix/4.4/debian/pool/main/z/zabbix-release/zabbix-release_4.4-1+buster_all.deb

我的安裝方式 我使用 mariardb

apt install -y zabbix-proxy-mysql zabbix-agent zabbix-sender zabbix-get

apt install -y zabbix-agent zabbix-sender

systemctl restart zabbix-proxy zabbix-agent 
systemctl enable zabbix-proxy zabbix-agent 
mysql_secure_installation

mysql -uroot -p'rootDBpass' -e "create database zabbix_proxy character set utf8 collate utf8_bin;"
mysql -uroot -p'rootDBpass' -e "grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbixDBpass';"

參考網址

https://sbcode.net/zabbix/proxy-install/

備註

zabbix 需要 匯入 SNMP MIB檔案 才能會認到snmp 設備的指定路徑 不然只能使用default snmp 欄位

#

zabbix server & proxy 溝通(防火牆設定)
zabbix server 主機hosts設定
vim /etc/hosts
    zabbix server 主機IP
zabbix server 主機防火牆
vi /etc/sysconfig/iptables
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp -s [zabbix proxy 主機IP]/32 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    -A INPUT -p udp -m udp --dport 162 -j ACCEPT
    -A INPUT -p udp -m udp --dport 161 -j ACCEPT
    -A INPUT -p tcp --dport 10051 -j ACCEPT
    -A INPUT -p tcp --dport 10050 -j ACCEPT
    -A INPUT -p udp --dport 10050 -j ACCEPT
    -A INPUT -p udp --dport 10051 -j ACCEPT
    COMMIT
/etc/init.d/iptables restart


vim /etc/sysconfig/selinux
SELINUX=disabled
reboot
zabbix proxy 主機hosts設定
vim /etc/hosts
    zabbix proxy 主機IP
zabbix proxy 主機防火牆
vi /etc/sysconfig/iptables
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp -s [zabbix server 主機IP]/32 -j ACCEPT
    -A INPUT -p tcp -m state --state NEW --dport 23 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    -A INPUT -p udp -m udp --dport 162 -j ACCEPT
    -A INPUT -p udp -m udp --dport 161 -j ACCEPT
    -A INPUT -p tcp --dport 10051 -j ACCEPT
    -A INPUT -p tcp --dport 10050 -j ACCEPT
    -A INPUT -p udp --dport 10050 -j ACCEPT
    -A INPUT -p udp --dport 10051 -j ACCEPT
    COMMIT
/etc/init.d/iptables restart

vim /etc/sysconfig/selinux
SELINUX=disabled
reboot


zabbix zabbix_get -s 192.168.96.125 -p 10050 -k agent.version

Debian10_2_Zabbix_4_4_03_Proxy_01

DC01

python zabbix_screen_host.py 'F5-BT-VE-02-For-Proxy'

Debian10_2_Zabbix_4_4_03_Agent_01
Debian10-2-Zabbix-4-4-03-Agent-01


https://github.com/vim-scripts/Risto-Color-Scheme.git

colorscheme risto

Debian102Zabbix4403Agent01 名稱盡量不要使用 橫槓或底線

沒有留言:

張貼留言