1.源码包下载及创建用户
cd /usr/src/
wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.6.tar.gz
tar xvf zabbix-6.0.2.tar.gz
ln -s zabbix-6.0.2 zabbix
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
2.mysql8数据库
cd /usr/local/
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
tar xvf mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.27-linux-glibc2.12-x86_64 mysql
useradd mysql
vim /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
vim /etc/my.cnf
[client]
socket=/data/mysql/3306/data/mysql.sock
[mysqld]
#server configuration
user=mysql
datadir=/data/mysql/3306/data
basedir=/usr/local/mysql
port=3306
socket=/data/mysql/3306/data/mysql.sock
log_timestamps=system
log_error=/data/mysql/3306/data/mysqld.err
skip_name_resolve
#Replication Framework
server_id=1
master_info_repository=TABLE
relay_log_info_repository=TABLE
log_slave_updates=ON
log_bin=mysql-bin
binlog_format=ROW
#启动数据库
mkdir -p /data/mysql/3306/data/
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &
#进数据库mysql -uroot -p 直接回车
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user 'zabbix_admin'@'%' identified with mysql_native_password by 'zabbix_pass';
mysql> grant all privileges on zabbix.* to 'zabbix_admin'@'%';
#导入zabbix源码包里的数据
cd /usr/src/zabbix/database/mysql/
mysql -h127.0.0.1 -uzabbix_admin -pzabbix_pass zabbix < schema.sql
mysql -h127.0.0.1 -uzabbix_admin -pzabbix_pass zabbix < images.sql
mysql -h127.0.0.1 -uzabbix_admin -pzabbix_pass zabbix < data.sql
#准备编译zabbix
yum install gcc mysql-devel libevent-devel libcurl-devel libxml2-devel net-snmp-devel
ln -s /usr/local/mysql-8.0.27-linux-glibc2.12-x86_64/lib/private/libssl.so.1.1 /usr/lib64
ln -s /usr/local/mysql-8.0.27-linux-glibc2.12-x86_64/lib/private/libcrypto.so.1.1 /usr/lib64
cd /usr/src/zabbix
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make install
#编译完成后,看看 /usr/local/zabbix/ 目录的内容是否齐全
3.配置zabbix的配置文件
vi /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix_admin
DBPassword=zabbix_pass
DBPort=3306
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
CacheSize=2048M
vi /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
#配置服务端启动文件
vi /usr/src/zabbix/misc/init.d/fedora/core5/zabbix_server
...
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_server"
CONFIG_FILE="/usr/local/zabbix/etc/zabbix_server.conf"
...
start() {
echo -n $"Starting $prog: "
daemon $ZABBIX_BIN -c $CONFIG_FILE
cp /usr/src/zabbix/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
#配置客户端启动文件
vi /usr/src/zabbix/misc/init.d/fedora/core5/zabbix_agentd
...
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd"
CONFIG_FILE="/usr/local/zabbix/etc/zabbix_agentd.conf"
...
start() {
echo -n $"Starting $prog: "
daemon $ZABBIX_BIN -c $CONFIG_FILE
...
cp /usr/src/zabbix/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
#启动服务
ln -s /usr/local/mysql/lib/libmysqlclient.so.21 /usr/lib64
service zabbix_server start
service zabbix_agentd start
chkconfig zabbix_server on
chkconfig zabbix_agentd on
4.配置web组件(php)
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php72
yum install httpd php72w-cli php72w-common php72w-gd php72w-ldap php72w-mbstring php72w-mysqlnd php72w-xml php72w-bcmath mod_php72w -y
#检查php的版本是不是7.2(务必确认)
php -v
mkdir -p /var/www/html/zabbix
cp -r /usr/src/zabbix/ui/* /var/www/html/zabbix
chown -R apache.apache /var/www/html/
vi /etc/php.ini
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
date.timezone = Asia/Shanghai
service httpd start
chkconfig httpd on
5.配置zabbix向导(最后)
浏览器中输入 http://192.168.0.127/zaabix
image.pngimage.png
6.客户端配置连接至zabbix
rpm -ivh zabbix-agent2-6.0.6-1.el7.x86_64.rpm
(下载地址:http://repo.zabbix.com/zabbix/6.0/rhel/7/x86_64/zabbix-agent2-6.0.6-1.el7.x86_64.rpm)
vi /etc/zabbix/zabbix-agent2.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.0.127 #服务端地址
ServerActive=127.0.0.1
Hostname=192.168.0.128. #客户端地址
systemctl restart zabbix-agent2
#查看日志排错
tail -f /var/log/zabbix/zabbix.agent2.log
网友评论