1. 程式人生 > 實用技巧 >大資料運維(49)Linux上安裝部署Zabbix

大資料運維(49)Linux上安裝部署Zabbix

環境準備
OS:CentOS 7
安裝步驟
一,關閉selinux和iptables
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0

二,安裝Zabbix rpm包倉庫
[root@localhost ~]# rpm -vhi http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

三,安裝zabbix-server-mysql和zabbix-web-mysql
[root@localhost ~]# yum install -y zabbix-server-mysql zabbix-web-mysql
四,安裝並且啟動mysql5.6及初始化資料庫資訊


[root@localhost ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
[root@localhost ~]# yum install -y mysql-community-server
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# /sbin/chkconfig mysqld on #開機啟動

[root@localhost ~]# mysql_secure_installation #初始化資料庫資訊

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Sorry, passwords do not match.
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables…
… Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
… Success!
Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
… Success!
By default, MySQL comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y

  • Dropping test database…
    ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
    … Failed! Not critical, keep moving…
  • Removing privileges on test database…
    … Success!
    Reloading the privilege tables will ensure that all changes made so far
    will take effect immediately.
    Reload privilege tables now? [Y/n] y
    … Success!
    All done! If you’ve completed all of the above steps, your MySQL
    installation should now be secure.
    Thanks for using MySQL!
    五,建立zabbix資料庫,建立zabbix賬號
    [root@localhost ~]# mysql -uroot -p

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to ‘zabbix’@‘localhost’ identified by ‘zabbix’; #注意後面密碼帶引號
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> Ctrl-C – exit!
六,匯入預設的zabbix資料庫資訊
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.24/
[root@localhost zabbix-server-mysql-3.0.24]# zcat /usr/share/doc/zabbix-server-mysql-3.0.24/create.sql.gz | mysql zabbix -uzabbix -pzabbix
七,修改zabbix_server.conf的配置檔案
[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

八,修改配置檔案/etc/httpd/conf.d/zabbix.conf,時區改成 Asia/Shanghai
[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
九,啟動apache/zabbix-server服務並設定為開機啟動
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# systemctl start zabbix-server
[root@localhost ~]# systemctl enable zabbix-server
十,訪問網站,例如:http://本機IP/zabbix,如下圖所示:


上圖為配置交換機巨集

十一:解決圖形亂碼問題

解決方法

1.從windows下控制面板->字型->選擇一種中文字型檔例如“楷體” 【複製-粘貼出來,然後拷貝到zabbix伺服器上】

將這個檔案拷貝到zabbix的資料目錄的fonts目錄下

[root@localhost ~]# cd /usr/share/zabbix/fonts/
[root@localhost fonts]# ll
total 12440
lrwxrwxrwx. 1 root root 33 Jan 22 22:49 graphfont.ttf -> /etc/alternatives/zabbix-web-font #發現預設的字型連結到 /etc/alternatives/zabbix-web-font

[root@localhost fonts]# cd /etc/alternatives/
[root@localhost alternatives]# ll
total 0
lrwxrwxrwx. 1 root root 15 Jan 23 2019 ld -> /usr/bin/ld.bfd
lrwxrwxrwx. 1 root root 34 Jan 23 2019 libnssckbi.so.x86_64 -> /usr/lib64/pkcs11/p11-kit-trust.so
lrwxrwxrwx. 1 root root 26 Jan 23 2019 mta -> /usr/sbin/sendmail.postfix
lrwxrwxrwx. 1 root root 40 Jan 23 2019 mta-aliasesman -> /usr/share/man/man5/aliases.postfix.5.gz
lrwxrwxrwx. 1 root root 22 Jan 23 2019 mta-mailq -> /usr/bin/mailq.postfix
lrwxrwxrwx. 1 root root 38 Jan 23 2019 mta-mailqman -> /usr/share/man/man1/mailq.postfix.1.gz
lrwxrwxrwx. 1 root root 27 Jan 23 2019 mta-newaliases -> /usr/bin/newaliases.postfix
lrwxrwxrwx. 1 root root 43 Jan 23 2019 mta-newaliasesman -> /usr/share/man/man1/newaliases.postfix.1.gz
lrwxrwxrwx. 1 root root 23 Jan 23 2019 mta-pam -> /etc/pam.d/smtp.postfix
lrwxrwxrwx. 1 root root 22 Jan 23 2019 mta-rmail -> /usr/bin/rmail.postfix
lrwxrwxrwx. 1 root root 25 Jan 23 2019 mta-sendmail -> /usr/lib/sendmail.postfix
lrwxrwxrwx. 1 root root 41 Jan 23 2019 mta-sendmailman -> /usr/share/man/man1/sendmail.postfix.1.gz
lrwxrwxrwx. 1 root root 29 Jan 22 22:49 zabbix-server -> /usr/sbin/zabbix_server_mysql
lrwxrwxrwx. 1 root root 38 Jan 22 22:49 zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
#發現zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf 連結到DejaVuSans.ttf
[root@localhost alternatives]# cd /usr/share/fonts/dejavu/
[root@localhost dejavu]# ll
total 5288
-rw-r–r--. 1 root root 611212 Feb 27 2011 DejaVuSans-BoldOblique.ttf
-rw-r–r--. 1 root root 672300 Feb 27 2011 DejaVuSans-Bold.ttf
-rw-r–r--. 1 root root 580168 Feb 27 2011 DejaVuSansCondensed-BoldOblique.ttf
-rw-r–r--. 1 root root 631992 Feb 27 2011 DejaVuSansCondensed-Bold.ttf
-rw-r–r--. 1 root root 576004 Feb 27 2011 DejaVuSansCondensed-Oblique.ttf
-rw-r–r--. 1 root root 643852 Feb 27 2011 DejaVuSansCondensed.ttf
-rw-r–r--. 1 root root 345204 Feb 27 2011 DejaVuSans-ExtraLight.ttf
-rw-r–r--. 1 root root 611556 Feb 27 2011 DejaVuSans-Oblique.ttf
-rw-r–r--. 1 root root 720012 Feb 27 2011 DejaVuSans.ttf
[root@localhost dejavu]# cp DejaVuSans.ttf DejaVuSans.ttf-back 備份原字型檔案
[root@localhost dejavu]# ll
total 5992
-rw-r–r--. 1 root root 611212 Feb 27 2011 DejaVuSans-BoldOblique.ttf
-rw-r–r--. 1 root root 672300 Feb 27 2011 DejaVuSans-Bold.ttf
-rw-r–r--. 1 root root 580168 Feb 27 2011 DejaVuSansCondensed-BoldOblique.ttf
-rw-r–r--. 1 root root 631992 Feb 27 2011 DejaVuSansCondensed-Bold.ttf
-rw-r–r--. 1 root root 576004 Feb 27 2011 DejaVuSansCondensed-Oblique.ttf
-rw-r–r--. 1 root root 643852 Feb 27 2011 DejaVuSansCondensed.ttf
-rw-r–r--. 1 root root 345204 Feb 27 2011 DejaVuSans-ExtraLight.ttf
-rw-r–r--. 1 root root 611556 Feb 27 2011 DejaVuSans-Oblique.ttf
-rw-r–r--. 1 root root 720012 Feb 27 2011 DejaVuSans.ttf
-rw-r–r--. 1 root root 720012 Jan 23 01:39 DejaVuSans.ttf-back
[root@localhost dejavu]# mv /usr/share/zabbix/fonts/STKAITI.TTF ./ 將上傳的字型檔案移動到現預設字型的目錄下
[root@localhost dejavu]# ll
total 18432
-rw-r–r--. 1 root root 611212 Feb 27 2011 DejaVuSans-BoldOblique.ttf
-rw-r–r--. 1 root root 672300 Feb 27 2011 DejaVuSans-Bold.ttf
-rw-r–r--. 1 root root 580168 Feb 27 2011 DejaVuSansCondensed-BoldOblique.ttf
-rw-r–r--. 1 root root 631992 Feb 27 2011 DejaVuSansCondensed-Bold.ttf
-rw-r–r--. 1 root root 576004 Feb 27 2011 DejaVuSansCondensed-Oblique.ttf
-rw-r–r--. 1 root root 643852 Feb 27 2011 DejaVuSansCondensed.ttf
-rw-r–r--. 1 root root 345204 Feb 27 2011 DejaVuSans-ExtraLight.ttf
-rw-r–r--. 1 root root 611556 Feb 27 2011 DejaVuSans-Oblique.ttf
-rw-r–r--. 1 root root 720012 Feb 27 2011 DejaVuSans.ttf
-rw-r–r--. 1 root root 720012 Jan 23 01:39 DejaVuSans.ttf-back
-rw-r–r--. 1 root root 12736196 Oct 29 2002 STKAITI.TTF
[root@localhost dejavu]# rm DejaVuSans.ttf 刪除預設字型
rm: remove regular file ‘DejaVuSans.ttf’? y
[root@localhost dejavu]# mv STKAITI.TTF DejaVuSans.ttf 將上傳的字型檔名更改為之前的預設字型檔名

這樣,修改後,zabbix監控圖形中的中文字就不會出現亂碼了!!

歡迎使用Markdown編輯器

你好! 這是你第一次使用 Markdown編輯器 所展示的歡迎頁。如果你想學習如何使用Markdown編輯器, 可以仔細閱讀這篇文章,瞭解一下Markdown的基本語法知識。

新的改變

我們對Markdown編輯器進行了一些功能拓展與語法支援,除了標準的Markdown編輯器功能,我們增加了如下幾點新功能,幫助你用它寫部落格:

  1. 全新的介面設計 ,將會帶來全新的寫作體驗;
  2. 在創作中心設定你喜愛的程式碼高亮樣式,Markdown 將程式碼片顯示選擇的高亮樣式 進行展示;
  3. 增加了 圖片拖拽 功能,你可以將本地的圖片直接拖拽到編輯區域直接展示;
  4. 全新的 KaTeX數學公式 語法;
  5. 增加了支援甘特圖的mermaid語法1 功能;
  6. 增加了 多螢幕編輯 Markdown文章功能;
  7. 增加了 焦點寫作模式、預覽模式、簡潔寫作模式、左右區域同步滾輪設定 等功能,功能按鈕位於編輯區域與預覽區域中間;
  8. 增加了 檢查列表 功能。

功能快捷鍵

撤銷:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜體:Ctrl/Command + I
標題:Ctrl/Command + Shift + H
無序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
檢查列表:Ctrl/Command + Shift + C
插入程式碼:Ctrl/Command + Shift + K
插入連結:Ctrl/Command + Shift + L
插入圖片:Ctrl/Command + Shift + G

合理的建立標題,有助於目錄的生成

直接輸入1次#,並按下space後,將生成1級標題。
輸入2次#,並按下space後,將生成2級標題。
以此類推,我們支援6級標題。有助於使用TOC語法後生成一個完美的目錄。

如何改變文字的樣式

強調文字 強調文字

加粗文字 加粗文字

標記文字

刪除文字

引用文字

H2O is是液體。

210 運算結果是 1024.

插入連結與圖片

連結: link.

圖片:

帶尺寸的圖片:

居中的圖片:

居中並且帶尺寸的圖片:

當然,我們為了讓使用者更加便捷,我們增加了圖片拖拽功能。

如何插入一段漂亮的程式碼片

部落格設定頁面,選擇一款你喜歡的程式碼片高亮樣式,下面展示同樣高亮的 程式碼片.

// An highlighted block
var foo = 'bar';
  • 1
  • 2

生成一個適合你的列表

  • 專案
    • 專案
      • 專案
  1. 專案1
  2. 專案2
  3. 專案3
  • 計劃任務
  • 完成任務

建立一個表格

一個簡單的表格是這麼建立的:

專案Value
電腦 $1600
手機 $12
導管 $1

設定內容居中、居左、居右

使用:---------:居中
使用:----------居左
使用----------:居右

第一列第二列第三列
第一列文字居中 第二列文字居右 第三列文字居左

SmartyPants

SmartyPants將ASCII標點字元轉換為“智慧”印刷標點HTML實體。例如:

TYPEASCIIHTML
Single backticks 'Isn't this fun?' ‘Isn’t this fun?’
Quotes "Isn't this fun?" “Isn’t this fun?”
Dashes -- is en-dash, --- is em-dash – is en-dash, — is em-dash

建立一個自定義列表

Markdown
Text-to- HTML conversion tool
Authors
John
Luke

如何建立一個註腳

一個具有註腳的文字。2

註釋也是必不可少的

Markdown將文字轉換為 HTML

KaTeX數學公式

您可以使用渲染LaTeX數學表示式 KaTeX:

Gamma公式展示 Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ(n)=(n1)!nN 是通過尤拉積分

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t   . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=0tz1etdt.

你可以找到更多關於的資訊 LaTeX 數學表示式here.

新的甘特圖功能,豐富你的文章

Mon 06 Mon 13 Mon 20 已完成 進行中 計劃一 計劃二 現有任務 Adding GANTT diagram functionality to mermaid
  • 關於 甘特圖 語法,參考 這兒,

UML 圖表

可以使用UML圖表進行渲染。 Mermaid. 例如下面產生的一個序列圖::

張三 李四 王五 你好!李四, 最近怎麼樣? 你最近怎麼樣,王五? 我很好,謝謝! 我很好,謝謝! 李四想了很長時間, 文字太長了 不適合放在一行. 打量著王五... 很好... 王五, 你怎麼樣? 張三 李四 王五

這將產生一個流程圖。:

連結 長方形 圓 圓角長方形 菱形
  • 關於 Mermaid 語法,參考 這兒,

FLowchart流程圖

我們依舊會支援flowchart的流程圖:

Created with Raphaël 2.2.0 開始 我的操作 確認? 結束 yes no
  • 關於 Flowchart流程圖 語法,參考 這兒.

匯出與匯入

匯出

如果你想嘗試使用此編輯器, 你可以在此篇文章任意編輯。當你完成了一篇文章的寫作, 在上方工具欄找到 文章匯出 ,生成一個.md檔案或者.html檔案進行本地儲存。

匯入

如果你想載入一篇你寫過的.md檔案或者.html檔案,在上方工具欄可以選擇匯入功能進行對應副檔名的檔案匯入,
繼續你的創作。


  1. mermaid語法說明 ↩︎

  2. 註腳的解釋 ↩︎