zabbix的部署
安装依赖包 [root@localhost lamp]# yum -y install net-snmp-devel libevent-devel 下载二进制软件包 [root@localhost src]# cd /usr/src/ [root@localhost src]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz 解压文件 [root@localhost src]# tar xf zabbix-4.0.3.tar.gz [root@localhost src]# ls debug kernels zabbix-4.0.3 zabbix-4.0.3.tar.gz 创建用户 [root@localhost src]# useradd -r -M -s /sbin/nologin zabbix[root@localhost src]# id zabbix uid=304(zabbix) gid=304(zabbix) 组=304(zabbix) 配置数据库 mysql> create database zabbix character set utf8 collate utf8_bin; #支持中文 Query OK, 1 row affected (0.06 sec) mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!'; #给zabbix权限 Query OK, 0 rows affected, 2 warnings (0.03 sec) mysql> flush privileges; #刷新权限 Query OK, 0 rows affected (0.01 sec) 导入数据内容 [root@localhost src]# cd /usr/src/zabbix-4.0.3/database/mysql/ [root@localhost mysql]# ls data.sql images.sql Makefile.am Makefile.in schema.sql [root@localhost mysql]# mysql -uroot -p123456 zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -uroot -p123456 zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -uroot -p123456 zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. mysql> show databases; mysql> show tables; 144 rows in set (0.00 sec) //编译安装zabbix [root@localhost ~]# cd /usr/src/zabbix-4.0.3/ [root@localhost zabbix-4.0.3]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 [root@localhost zabbix-4.0.3]# make install 如遇报错,则安装缺少的依赖包 [root@localhost zabbix-4.0.3]# yum -y install libxml2-devel [root@localhost zabbix-4.0.3]# yum -y install libcurl-devel zabbix服务端配置 [root@localhost ~]# vim /usr/local/etc/zabbix_server.conf DBPassword=zabbix123! //设置zabbix数据库连接密码 启动服务 [root@localhost ~]# zabbix_server [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:*
zabbix服务端web界面安装与配置
[root@localhost ~]# vim /usr/local/etc/zabbix_agentd.conf #配置客户端 [root@localhost ~]# zabbix_agentd #启动客户端 [root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:10050 0.0.0.0:* LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 0.0.0.0:9000 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* 配置web界面 [root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini #改为16mb [root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini #时间设为300秒 [root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini #最大输入时间300秒 [root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini #修改为上海时区 [root@localhost ~]# service php-fpm restart Redirecting to /bin/systemctl restart php-fpm.service [root@localhost ~]# cd /usr/src/zabbix-4.0.3 [root@localhost zabbix-4.0.3]# mkdir /usr/local/apache/htdocs/zabbix [root@localhost zabbix-4.0.3]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/ #新版的前端名为ui [root@localhost zabbix-4.0.3]# chown -R apache.apache /usr/local/apache/htdocs 配置apache虚拟主机 [root@localhost zabbix-4.0.3]# vim /usr/local/apache/conf/extra/vhosts.conf
//在配置文件的末尾加如下内容
<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htdocs/zabbix"
ServerName zabbix.wm.com
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
临时修改文件配置权限
[root@localhost zabbix-4.0.3]# ll -d conf
drwxr-xr-x. 3 1001 1001 134 12月 20 2018 conf
[root@localhost zabbix-4.0.3]# chmod 777 conf
[root@localhost zabbix-4.0.3]# ll -d conf
drwxrwxrwx. 3 1001 1001 134 12月 20 2018 conf
重启服务
[root@localhost zabbix-4.0.3]# apachectl -t
Syntax OK
[root@localhost zabbix-4.0.3]# apachectl stop
[root@localhost zabbix-4.0.3]# apachectl start
给IP权限通行数据库 [root@localhost conf]# mysql -uroot -p Enter password: mysql> grant all on zabbix.* to zabbix@192.168.170.129 identified by 'zabbix123!'; Query OK, 0 rows affected, 1 warning (0.05 sec) mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) 恢复zabbix/conf目录的权限为755 [root@localhost conf]# chmod 755 /usr/local/apache/htdocs/zabbix/conf
登录zabbix
zabbix默认登录用户名和密码:
| 用户名 | 密码 |
|---|---|
| Admin | zabbix |

浙公网安备 33010602011771号