zabbix 服務搭建 3.4

1.更改主機名
root@localhost ~]# hostnamectl set-hostname zabbix-server
2.刪除歷史yum源
[root@zabbix-server ~]# rm -rf /etc/yum.repos.d/*
3.使用阿里的yum源
4[root@zabbix-server ~]# cat /etc/yum.repos.d/ali.repo
[ali]
name=ali
baseurl=https://mirrors.aliyun.com/centos/7.5.1804/os/x86_64/
enabled=1
gpgcheck=1
4.使用zabbix官網yum源
[root@zabbix-server ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

[zabbix.repo]
name=zabbix.repo
baseurl=http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/
enabled=1
gpgcheck=1
5.yum repolist
源標識 源名稱 狀態
ali ali 9,911
zabbix/x86_64 Zabbix Official Repository - x86_64 184
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86 4
repolist: 10,099
6.安裝zabbix-server zabbix-agent zabbix-web
[root@zabbix-server ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
7.安裝mariadb數據庫,php軟件包
[root@zabbix-server ~]# yum -y install yum -y install php php-mysql mariadb mariadb-devel mariadb-server
8.啓動mysql
[root@zabbix-server ~]# systemctl restart mariadb
[root@zabbix-server ~]# mysql
創建 zabbix數據庫
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
創建zabbix賬戶及密碼
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
9.導入zabbix數據包到zabbix數據庫
[root@zabbix-server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
10.修改zabbix-server配置文件
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
ListenPort=10051 修改端口
SourceIP=192.168.1.80 修改主機IP
LogFile=/var/log/zabbix/zabbix_server.log 默認日誌文件目錄
DBHost=localhost 本機
DBName=zabbix 數據庫名字
DBUser=zabbix 數據庫賬戶
DBPassword=zabbix
:wq #保存退出
11.httpd配置文件修改
[root@zabbix-server ~]# vim /etc/httpd/conf.d/zabbix.conf
<VirtualHost 192.168.1.80:80> #添加的內容<頭文件>
servername zabbix-server #服務器名字
DocumentRoot /usr/share/zabbix #網頁文件存放位置
Alias /zabbix /usr/share/zabbix #給網頁文件目錄設置一個別名

<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted

<IfModule mod_php5.c>
    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   #把默認時區打開改爲亞洲/上海
</IfModule>

</Directory>

<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>

<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
</VirtualHost> #</添加結束位置>
12.zabbix 服務端,客戶端軟件,httpd起服務設置開機自啓
[root@zabbix-server ~]# systemctl restart zabbix-server.service zabbix-agent.service httpd.service
[root@zabbix-server ~]# systemctl enable zabbix-server.service zabbix-agent.service httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
13.查詢zabbix服務監控軟件工作狀態
[root@zabbix-server ~]# netstat -antup | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0: LISTEN 2073/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:
LISTEN 2080/zabbix_server
tcp6 0 0 :::10050 ::: LISTEN 2073/zabbix_agentd
tcp6 0 0 :::10051 :::
LISTEN 2080/zabbix_server
14.注意Firewall及selinux 禁用
15.然後打開瀏覽器輸入網址查看
http://192.168.1.80/zabbix/
zabbix 服務搭建 3.4

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章