Now, this is basically a dump of my notes during the install. Don't expect it to be a line by line walkthrough of exactly what you need to do/change/type/etc.
# ##########################
# This is the basic information of my server
# ##########################
# uname -a
# Linux Pi-Zabbix 5.4.0-1069-raspi #79-Ubuntu SMP PREEMPT Thu Aug 18 18:18:46 UTC 2022 armv7l armv7l armv7l GNU/Linux
# cat /etc/*elea*
# DISTRIB_ID=Ubuntu
# DISTRIB_RELEASE=20.04
# DISTRIB_CODENAME=focal
# DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"
# NAME="Ubuntu"
# VERSION="20.04.6 LTS (Focal Fossa)"
# ID=ubuntu
# ID_LIKE=debian
# PRETTY_NAME="Ubuntu 20.04.6 LTS"
# VERSION_ID="20.04"
# VERSION_CODENAME=focal
# UBUNTU_CODENAME=focal
# ##########################
# NOTE; it's possible locations change with versions (very likely!) so /etc/php/7.4/ and similiar references may not be the same as your system in the future!
# ##########################
# Download the installation software from:
# http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz
# Transfer the gz file to the Raspberry Pi 2 putting it in the /opt folder.
# Become root or use sudo in front of each of these commands
sudo su
groupadd zabbix
useradd -g zabbix zabbix
passwd zabbix
# Install dependencies
apt-get install make apache2 libapache2-mod-php php-mysql mysql-server mysql-common libiksemel-dev libiksemel-utils libxml2-dev libxml2-utils libxml2 snmp libsnmp-dev libsnmp-perl libssh2-1-dev libssh2-1 libcurl4 libghc-curl-dev libmysql++-dev php-gd php-bcmath php-mbstring php-xml -y
# The mysql-utilities package may be needed but is not available natively (I'll see about coming back to this)
# Verify mysql is running
service mysql status
# Verify you are in the zabbix installation directory (example: /opt/zabbix-2.4.6)
# Run the installation/configure of Zabbix
./configure --enable-server --enable-agent --with-mysql --with-libxml2 --with-net-snmp --with-ssh2 --with-libcurl
# --with-jabber was removed as it created an error during the configure. It's optional as it's a feature of Zabbix that allows users to send notifications via Jabber.
# Complete the install; note there could be many warnings about "<sys/sysctl.h> header" which are ok to ignore.
# Warning: This could take a very long time.
make install
# Copy init scripts
cp /opt/zabbix-2.4.6/misc/init.d/debian/* /etc/init.d/
# Setup the web pages
mkdir /var/www/zabbix/
cp -r /opt/zabbix-2.4.6/frontends/php/* /var/www/zabbix/
chown -R www-data:www-data /var/www/zabbix/
# Create the database
# Note; the IDENTIFIED BY in single quotes below is the password.
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;
# Import the SQL data for the database
# Note; this utilizes the default password from above
# Warning: This could take a very long time.
mysql -uzabbix -pzabbix zabbix < /opt/zabbix-2.4.6/database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < /opt/zabbix-2.4.6/database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < /opt/zabbix-2.4.6/database/mysql/data.sql
# Verify database installation
mysql
show databases;
#+--------------------+
#| Database |
#+--------------------+
#| information_schema |
#| mysql |
#| performance_schema |
#| sys |
#| zabbix |
#+--------------------+
use zabbix;
show tables;
select * from users;
quit;
# Prepare file system folders
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
mkdir -p /var/zabbix/alertscripts
mkdir -p /var/zabbix/externalscripts
chown -R zabbix:zabbix /var/zabbix/
mkdir /var/www/html/zabbix
cd ~/zabbix-2.4.6/frontends/php
cp -a . /var/www/html/zabbix/
chown -R www-data:www-data /var/www/html/zabbix
chmod +x /var/www/html/zabbix/conf/
# Adjust the config file to match below lines (change password if different than default)
nano /usr/local/etc/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBUser=zabbix
DBPassword=zabbix
AlertScriptsPath=/var/zabbix/alertscripts
ExternalScripts=/var/zabbix/externalscripts
# Adjust the php settings
nano /etc/php/7.4/apache2/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone =
# Bypass a version check as the newer PHP versions take care of this issue but the UI errors
nano /var/www/html/zabbix/include/classes/setup/CFrontendSetup.php
# #################
# Original Code:
// check for deprecated PHP 5.6.0 option 'always_populate_raw_post_data'
if (version_compare(PHP_VERSION, '[B]5.6[/B]', '>=')) {
$result[] = $this->checkPhpAlwaysPopulateRawPostData();
# After making the change:
// check for deprecated PHP 5.6.0 option 'always_populate_raw_post_data'
if (version_compare(PHP_VERSION, '[B]7.5[/B]', '>=')) {
$result[] = $this->checkPhpAlwaysPopulateRawPostData();
# ##################
nano /var/www/html/zabbix/include/func.inc.php
# ##################
# Original Code:
function str2mem($val) {
$val = trim($val);
$last = strtolower(substr($val, -1));
switch ($last) {
case 'g':
$val *= 1024;
/* falls through */
case 'm':
$val *= 1024;
/* falls through */
case 'k':
$val *= 1024;
}
return $val;
}
# After making the change:
function str2mem($val) {
$val = trim($val);
$last = strtolower(substr($val, -1));
$val = substr_replace($val, "", -1);
switch ($last) {
case 'g':
$val *= $val * 1024;
/* falls through */
case 'm':
$val *= $val * 1024;
/* falls through */
case 'k':
$val *= $val * 1024;
}
return $val;
}
# ##################
# ##########################
# Create startup file for the server
# Note; this will get it going on boot but needs improved for functioning with other commands.
# ##########################
nano /etc/systemd/system/zabbix-server.service
[Unit]
Description=zabbix-server
[Service]
Type=forking
ExecStart=/etc/init.d/zabbix-server start
[Install]
WantedBy=multi-user.target
# Create startup file for the agent
# Note; this will get it going on boot but needs improved for functioning with other commands.
nano /etc/systemd/system/zabbix-agent.service
[Unit]
Description=zabbix-agent
[Service]
Type=forking
ExecStart=/etc/init.d/zabbix-agent start
[Install]
WantedBy=multi-user.target
# Set permissions on the startup files
chmod 644 /etc/systemd/system/zabbix-*
# Temporarily move the control scripts
mv /etc/init.d/zabbix-* /.
# Setup the services
systemctl daemon-reload
systemctl enable zabbix-server zabbix-agent apache2
# Move files back to their original location
mv /zabbix-* /etc/init.d/.
systemctl restart zabbix-server zabbix-agent apache2
# Open Zabbix UI web page
# The default URL for Zabbix UI when using Apache web server is http://host/zabbix
# The default user/password is Admin/zabbix
# ##########################
# This is where I played around with uninstalling MySQL 8 and trying to get 5.7
# It wouldn't pull 5.7 due to no ARM support
# ##########################
sudo systemctl stop mysql
sudo apt autoremove
sudo apt autoclean
wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
In the prompt, choose Ubuntu Bionic and click Ok
The next prompt shows MySQL 8.0 chosen by default. Choose the first option and click OK
In the next prompt, select MySQL 5.7 server and click OK.
The next prompt selects MySQL5.7 by default. Choose the last otpion Ok and click OK
gpg --keyserver repo.mysql.com --recv-keys B7B3B788A8D3785C
gpg --export --armor B7B3B788A8D3785C | sudo apt-key add -
sudo apt-get update
sudo apt-cache policy mysql-server
No comments:
Post a Comment