centos zabbix安装部署
时间: 2023-09-29 19:06:50 浏览: 149
Zabbix安装部署手册(CentOS8-zabbix5.2).pdf
1. 安装依赖包
```
yum install -y gcc gcc-c++ make wget net-snmp net-snmp-devel curl curl-devel perl-DBI php-gd php-xml php-bcmath php-mbstring php-ldap php-mysql php-pdo php-odbc php-pear php-devel php-mcrypt php-xmlrpc yajl yajl-devel libevent libevent-devel libxml2 libxml2-devel libcurl libcurl-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel libmcrypt libmcrypt-devel libxslt libxslt-devel freetype freetype-devel libxpm libxpm-devel gd gd-devel GeoIP GeoIP-devel
```
2. 安装数据库
```
yum install -y mariadb-server mariadb
```
启动并设置开机自启动
```
systemctl start mariadb
systemctl enable mariadb
```
设置root密码
```
mysql_secure_installation
```
3. 安装PHP
```
yum install -y php php-mysql php-mbstring php-gd php-xml php-ldap php-pear php-devel php-xmlrpc php-bcmath php-process php-snmp
```
4. 安装Apache
```
yum install -y httpd
```
启动并设置开机自启动
```
systemctl start httpd
systemctl enable httpd
```
5. 安装Zabbix
下载Zabbix源码包
```
wget https://cdn.zabbix.com/zabbix/sources/stable/5.2/zabbix-5.2.7.tar.gz
```
解压并进入目录
```
tar -zxvf zabbix-5.2.7.tar.gz
cd zabbix-5.2.7
```
编译并安装
```
./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2 --with-net-snmp --with-openipmi --with-openssl --with-jabber --with-iconv --with-ldap --with-libevent --with-ssh2 --with-unixodbc --with-openssl --prefix=/usr/local/zabbix
make install
```
6. 创建Zabbix数据库
```
mysql -uroot -p
```
输入密码后进入MySQL命令行
```
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
exit;
```
7. 导入Zabbix数据库结构
```
cd /usr/local/zabbix
mysql -uzabbix -p zabbix < database/mysql/schema.sql
mysql -uzabbix -p zabbix < database/mysql/images.sql
mysql -uzabbix -p zabbix < database/mysql/data.sql
```
8. 配置Zabbix Server
复制配置文件模板
```
cp /usr/local/zabbix/conf/zabbix_server.conf /usr/local/zabbix/conf/zabbix_server.conf.bak
```
修改配置文件
```
vi /usr/local/zabbix/conf/zabbix_server.conf
```
修改以下内容
```
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
```
9. 配置Zabbix Web
复制配置文件模板
```
cp /usr/local/zabbix-fronted/php/conf/zabbix.conf.php.example /usr/local/zabbix-fronted/php/conf/zabbix.conf.php
```
修改配置文件
```
vi /usr/local/zabbix-fronted/php/conf/zabbix.conf.php
```
修改以下内容
```
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = 'localhost';
$DB['PORT'] = '0';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'zabbix';
```
10. 配置防火墙
```
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
firewall-cmd --reload
```
11. 启动Zabbix Server 和 Agent
```
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd
```
12. 启动Apache
```
systemctl start httpd
```
打开浏览器,在地址栏输入服务器IP,进入Zabbix Web界面。初始用户名和密码为Admin/zabbix。
阅读全文