• zabbix5.0+grafana 使用脚本安装


    #/bin/sh

    #卸载mariadb

    rpm -e --nodeps `rpm -qa|grep mariadb*`


    #a. Install Zabbix repository
    rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
    yum clean all

    #替换阿里云镜像源
    sed -i 's/repo.zabbix.com/mirrors.aliyun.com/zabbix/g' /etc/yum.repos.d/zabbix.repo

    #b. Install Zabbix server and agent
    yum install -y zabbix-server-mysql zabbix-agent

    #c. Install Zabbix frontend
    #Enable Red Hat Software Collections
    yum install -y centos-release-scl


    #编辑配置文件 /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
    sed -i '11s/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo

    #Install Zabbix frontend packages.
    yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl


    #安装mysql数据库
    #配置清华大学yum源,默认安装最新,安装指定版本可以将其他版本的enabled修改为0


    #下载GPG-KEY导入rpm,防止报错
    curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql https://repo.mysql.com/RPM-GPG-KEY-mysql
    rpm --import /etc/pki/rpm-gpg/RPM*
    cat > /etc/yum.repos.d/mysql-community.repo <<EOF
    [mysql-connectors-community]
    name=MySQL Connectors Community
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

    [mysql-tools-community]
    name=MySQL Tools Community
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


    [mysql-5.6-community]
    name=MySQL 5.6 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.6-community-el7-$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

    [mysql-5.7-community]
    name=MySQL 5.7 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

    [mysql-8.0-community]
    name=MySQL 8.0 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    EOF

    yum makecache

    #数据库默认安装mysql8.0

    yum -y install mysql-server

    systemctl start mysqld
    systemctl enable mysqld

    echo "mysql安装完成"

    #数据库操作,更改root密码
    #获取安装时的临时密码赋值给mysql_pwd

    old_pwd=`grep 'temporary password' /var/log/mysqld.log |rev|cut -c-12|rev`
    #mysql_pwd=Zabbix@12345
    new_pwd=Zabbix@123
    #修改root密码
    mysql --connect-expired-password -uroot -p"$old_pwd" -e "alter user 'root'@'localhost' identified by '$new_pwd';" 2> /dev/null
    mysql --connect-expired-password -uroot -p$new_pwd -e "flush privileges;" 2> /dev/null

    #创建数据库zabbix
    mysql --connect-expired-password -uroot -p$new_pwd -e "create database zabbix character set utf8 collate utf8_bin;" 2> /dev/null
    #创建zabbix用户
    mysql --connect-expired-password -uroot -p$new_pwd -e "create user zabbix@localhost identified by 'Zabbix@12345';" 2> /dev/null
    #赋予权限
    mysql --connect-expired-password -uroot -p$new_pwd -e "grant all privileges on zabbix.* to zabbix@localhost;" 2> /dev/null

    mysql --connect-expired-password -uroot -p$new_pwd -e "flush privileges;" 2> /dev/null

    echo "数据库账号设置完成"


    #导入初始架构
    #编辑/usr/share/doc/zabbix-server-mysql*/create.sql.gz在首行添加use zabbix;
    zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pZabbix@12345 zabbix 2> /dev/null

    echo "数据导入完成"

    #编辑配置文件 /etc/zabbix/zabbix_server.conf
    sed -i '/DBPassword=/aDBPassword=Zabbix@12345' /etc/zabbix/zabbix_server.conf

    #为Zabbix前端配置PHP
    sed -i 's#^.*date.timezone.*$#php_value[date.timezone] = Asia/Shanghai#g' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

    #启动Zabbix server和agent进程,并为它们设置开机自启
    systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm

    systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm


    配置清华大学grafana源
    cat > /etc/yum.repos.d/grafana.repo << EOF
    [grafana]
    name=grafana
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm
    repo_gpgcheck=0
    enabled=1
    gpgcheck=0
    EOF

    yum makecache

    yum -y install grafana

    #安装zabbix插件
    grafana-cli plugins install alexanderzobnin-zabbix-app

    #启动grafana
    systemctl start grafana-server
    systemctl enable grafana-server

    #登录地址zabbix http://ip/zabbix/
    #登录地址grafana http://ip:3000
    #zabbix默认账号Admin/zabbix
    #grafana默认账号admin/admin

  • 相关阅读:
    AD预测论文研读系列2
    hdu 5795
    sg函数的应用
    二分查找
    快速幂
    筛选法素数打表
    多校hdu-5775 Bubble sort(线段树)
    多校hdu5754(博弈)
    多校hdu5738 寻找
    多校hdu5726 线段树+预处理
  • 原文地址:https://www.cnblogs.com/coolruo/p/14252218.html
Copyright © 2020-2023  润新知