Zabbix系列教程之手动安装篇
Posted 运维讲堂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix系列教程之手动安装篇相关的知识,希望对你有一定的参考价值。
安装yum源:
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
下载需要的软件:
[root@localhost ~]# yum -y install wget gzip nginx php php-fpm php-cli php-common php-gd php-mbstring php-mcrypt php-mysql php-pdo php-devel php-xmlrpc php-xml php-bcmath php-dba php-enchant mariadb-server zabbix-server zabbix-get zabbix-agent zabbix-server-mysql zabbix-web-mysql
配置nginx文件:
[root@localhost ~]# echo > /etc/nginx/nginx.conf
[root@localhost ~]# vi /etc/nginx/nginx.conf
user zabbix;
worker_processes 8;
pid /var/run/nginx.pid;
worker_rlimit_nofile 65535;
events {
worker_connections 65535;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
open_file_cache max=65535 inactive=60s;
open_file_cache_valid 80s;
open_file_cache_min_uses 1;
tcp_nopush on;
tcp_nodelay on;
proxy_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
client_header_buffer_size 4k;
server_names_hash_bucket_size 64;
server_name_in_redirect off;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
log_format main '$server_name $remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '$ssl_protocol $ssl_cipher $upstream_addr $request_time $upstream_response_time';
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml text/javascript;
include /etc/nginx/conf.d/*.conf;
}
配置zabbix虚拟主机
[root@localhost ~]# vi /etc/nginx/conf.d/zabbix.conf
server{
listen 80;
server_name _;
index index.php;
root /usr/share/zabbix/;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
include fastcgi_params;
}
}
配置mariadb:
先启动mariadb:
[root@localhost ~]# systemctl start mariadb
解压zabbix的数据库文件:
[root@localhost ~]# gzip -d /usr/share/doc/zabbix-server-mysql-3.4.8/create.sql.gz
给root用户设置密码:
[root@localhost ~]# mysqladmin -u root password root的密码
进入mariadb:
[root@localhost ~]# mysql -u root -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-3.4.8/create.sql
MariaDB [zabbix]> exit
Bye
修改php.ini配置:
[root@localhost ~]# vi /etc/php.ini
post_max_size = 16M
default_charset = "UTF-8"
expose_php = off
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
date.timezone = Asia/Shanghai
修改zabbix server文件配置:
[root@localhost ~]# vi /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
启动服务:
[root@localhost ~]# systemctl enable nginx
[root@localhost ~]# systemctl start nginx.service
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable zabbix-server
[root@localhost ~]# systemctl start zabbix-server
[root@localhost ~]# systemctl enable zabbix-agent
[root@localhost ~]# systemctl start zabbix-agent
下一步,验证安装包和配置是否正确:
下一步,连接数据库:
下一步,zabbix服务器信息:
下一步,确认安装信息:
最后一步,显示安装成功:
点击Finish后出现登录界面,
默认用户名:Admin
密码:zabbix
点击Sign in就可以进入到监控主界面。
.
以上是关于Zabbix系列教程之手动安装篇的主要内容,如果未能解决你的问题,请参考以下文章