Last active
November 30, 2020 05:28
-
-
Save noriki-nakamura/ded1027307397443315121d915047d34 to your computer and use it in GitHub Desktop.
Userdata for MIRACLE ZBX 5.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
MYSQL_PW=password | |
SERVER_IP= | |
PROXY_NAME= | |
# Prompt Setting | |
echo "export PS1='[\u@\h (MIRACLE-ZBX-PRX) \W]\\$ '" >> /etc/profile.d/prompt.sh | |
# Install packages | |
rpm --import https://ftp.miraclelinux.com/zbx/RPM-GPG-KEY-MIRACLE | |
rpm -ihv https://ftp.miraclelinux.com/zbx/5.0/miracle-zbx-release-5.0-1.noarch.rpm | |
yum install -y miracle-zbx-proxy-mysql mariadb-server miracle-zbx-agent miracle-zbx-get miracle-zbx-sender | |
# Configure MariaDB | |
cat - << EOS > /etc/my.cnf.d/zabbix.cnf | |
[mysqld] | |
character-set-server=utf8 | |
skip-character-set-client-handshake | |
innodb_file_per_table | |
innodb_log_buffer_size=16M | |
innodb_buffer_pool_size=512M | |
innodb_log_file_size=256M | |
innodb_log_files_in_group=2 | |
key_buffer_size=200M | |
max_allowed_packet=16MB | |
EOS | |
systemctl enable --now mariadb | |
# Prepare DB | |
echo 'create database zabbix_proxy character set utf8 collate utf8_bin;' | mysql -uroot | |
echo "grant all privileges on zabbix_proxy.* to zabbix@localhost identified by \"$MYSQL_PW\";" | mysql -uroot | |
echo 'flush privileges;' | mysql -uroot | |
zcat /usr/share/doc/miracle-zbx-proxy-mysql-*/schema.sql.gz | mysql -uzabbix -p$MYSQL_PW zabbix_proxy | |
# Prepare Zabbix Proxy | |
sed -i /etc/zabbix/zabbix_proxy.conf -e "206a DBPassword=$MYSQL_PW" | |
sed -i /etc/zabbix/zabbix_proxy.conf -e "13a ProxyMode=1" | |
sed -i /etc/zabbix/zabbix_proxy.conf -e "s/Server=127.0.0.1/Server=$SERVER_IP/g" | |
sed -i /etc/zabbix/zabbix_proxy.conf -e "s/Hostname=Zabbix proxy/Hostname=$PROXY_NAME/g" | |
# Prepare Zabbix Agent | |
sed -i /etc/zabbix/zabbix_agentd.conf -e "s/Hostname=Zabbix server/Hostname=$PROXY_NAME/g" | |
# Start Zabbix daemons | |
systemctl enable --now zabbix-proxy zabbix-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
MYSQL_PW=password | |
# Prompt Setting | |
echo "export PS1='[\u@\h (MIRACLE-ZBX-SRV) \W]\\$ '" >> /etc/profile.d/prompt.sh | |
# Install packages | |
rpm --import https://ftp.miraclelinux.com/zbx/RPM-GPG-KEY-MIRACLE | |
rpm -ihv https://ftp.miraclelinux.com/zbx/5.0/miracle-zbx-release-5.0-1.noarch.rpm | |
amazon-linux-extras enable php7.2 | |
yum clean metadata | |
yum install -y miracle-zbx-server-mysql miracle-zbx-web miracle-zbx-web-mysql miracle-zbx-apache-conf miracle-zbx-web-japanese miracle-zbx-java-gateway miracle-zbx-agent miracle-zbx-get miracle-zbx-sender mariadb-server | |
# Configure MariaDB | |
cat - << EOS > /etc/my.cnf.d/zabbix.cnf | |
[mysqld] | |
character-set-server=utf8 | |
skip-character-set-client-handshake | |
innodb_file_per_table | |
innodb_log_buffer_size=16M | |
innodb_buffer_pool_size=512M | |
innodb_log_file_size=256M | |
innodb_log_files_in_group=2 | |
key_buffer_size=200M | |
max_allowed_packet=16MB | |
EOS | |
systemctl enable --now mariadb | |
# Prepare DB | |
echo 'create database zabbix character set utf8 collate utf8_bin;' | mysql -uroot | |
echo "grant all privileges on zabbix.* to zabbix@localhost identified by \"$MYSQL_PW\";" | mysql -uroot | |
echo 'flush privileges;' | mysql -uroot | |
zcat /usr/share/doc/miracle-zbx-server-mysql-*/create.sql.gz | mysql zabbix -uzabbix -p$MYSQL_PW | |
# Prepare Zabbix Sever | |
sed -i /etc/zabbix/zabbix_server.conf -e "132a DBPassword=$MYSQL_PW" | |
sed -i /etc/zabbix/zabbix_server.conf -e "596a ProxyConfigFrequency=60" | |
systemctl enable --now zabbix-server | |
# Prepare for Zabbix Frontend | |
cat - << EOS > /etc/zabbix/web/zabbix.conf.php | |
<?php | |
// Zabbix GUI configuration file. | |
\$DB['TYPE'] = 'MYSQL'; | |
\$DB['SERVER'] = 'localhost'; | |
\$DB['PORT'] = '0'; | |
\$DB['DATABASE'] = 'zabbix'; | |
\$DB['USER'] = 'zabbix'; | |
\$DB['PASSWORD'] = '$MYSQL_PW'; | |
// Schema name. Used for PostgreSQL. | |
\$DB['SCHEMA'] = ''; | |
// Used for TLS connection. | |
\$DB['ENCRYPTION'] = false; | |
\$DB['KEY_FILE'] = ''; | |
\$DB['CERT_FILE'] = ''; | |
\$DB['CA_FILE'] = ''; | |
\$DB['VERIFY_HOST'] = false; | |
\$DB['CIPHER_LIST'] = ''; | |
// Use IEEE754 compatible value range for 64-bit Numeric (float) history values. | |
// This option is enabled by default for new Zabbix installations. | |
// For upgraded installations, please read database upgrade notes before enabling this option. | |
\$DB['DOUBLE_IEEE754'] = true; | |
\$ZBX_SERVER = 'localhost'; | |
\$ZBX_SERVER_PORT = '10051'; | |
\$ZBX_SERVER_NAME = ''; | |
\$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; | |
// Uncomment this block only if you are using Elasticsearch. | |
// Elasticsearch url (can be string if same url is used for all types). | |
//\$HISTORY['url'] = [ | |
// 'uint' => 'http://localhost:9200', | |
// 'text' => 'http://localhost:9200' | |
//]; | |
// Value types stored in Elasticsearch. | |
//\$HISTORY['types'] = ['uint', 'text']; | |
// Used for SAML authentication. | |
// Uncomment to override the default paths to SP private key, SP and IdP X.509 certificates, and to set extra settings. | |
//\$SSO['SP_KEY'] = 'conf/certs/sp.key'; | |
//\$SSO['SP_CERT'] = 'conf/certs/sp.crt'; | |
//\$SSO['IDP_CERT'] = 'conf/certs/idp.crt'; | |
//\$SSO['SETTINGS'] = []; | |
EOS | |
systemctl enable --now httpd php-fpm | |
# Prepare Zabbix Agent | |
systemctl enable --now zabbix-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment