No menu items!
No menu items!
More

    [Zabbix] Script cài đặt Zabbix tự động

    Bài viết này mình không nói nhiều, đây là 1 file cài Zabbix 6.0.2 tự động chỉ cần điền thông tin ip server, zabbixdb và zabbixdb password và bấm enter là xong. Script mình đã test thành công trên hệ điều hành Ubuntu, theo thời gian sẽ có nhiều thay đổi ví dụ như link phần mềm, các repo nên có thể sẽ không cài đặt được ở 1 thời gian nào đó. Nếu bạn không chạy được xin để lại comment để mình fix nhé.

    #!/bin/bash
    zabbix_dbname='zabbixdb'
    zabbix_dbpasswd='Hoanghd164'
    
    sudo apt update
    sudo apt upgrade -y
    
    sudo wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu$(lsb_release -rs)_all.deb
    sudo dpkg -i zabbix-release_6.0-1+ubuntu$(lsb_release -rs)_all.deb
    sudo apt update
    sudo apt -y install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent
    
    sudo apt install software-properties-common -y
    sudo curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
    sudo bash mariadb_repo_setup --mariadb-server-version=10.6
    sudo apt update
    sudo apt -y install mariadb-common mariadb-client-10.6 mariadb-server-10.6 
    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    sudo mysql -u root -e  "ALTER USER 'root'@'localhost' IDENTIFIED BY '$zabbix_dbpasswd';"
    sudo mysql -u root -p$zabbix_dbpasswd -e "create database $zabbix_dbname character set utf8mb4 collate utf8mb4_bin;"
    sudo mysql -u root -p$zabbix_dbpasswd -e "grant all privileges on $zabbix_dbname.* to zabbix@localhost identified by '$zabbix_dbpasswd';"
    sudo mysql -u root -p$zabbix_dbpasswd -e "FLUSH PRIVILEGES;"
    sudo zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uroot -p$zabbix_dbpasswd $zabbix_dbname 
    
    sudo echo "DBPassword=$zabbix_dbpasswd" >> /etc/zabbix/zabbix_server.conf
    sudo sed -i "s/DBName=.*/DBName=$zabbix_dbname/" /etc/zabbix/zabbix_server.conf
    sudo sed -i "s/DBUser=.*/DBUser=zabbix/" /etc/zabbix/zabbix_server.conf
    sudo sed -i 's|# php_value date.timezone.*|php_value date.timezone Asia/Ho_Chi_Minh|' /etc/zabbix/apache.conf
    
    ufw disable
    systemctl stop ufw
    systemctl disable ufw
    
    sudo systemctl restart zabbix-server zabbix-agent apache2
    sudo systemctl enable zabbix-server zabbix-agent apache2

    Bài viết gần đây

    spot_img

    Related Stories

    Leave A Reply

    Please enter your comment!
    Please enter your name here

    Đăng ký nhận thông tin bài viết qua email