zoukankan      html  css  js  c++  java
  • How to install Zabbix4.0 LTS version with Yum on the Oracle Linux 7.3 system?

    1.精简网卡属性
    
    > /etc/sysconfig/network-scripts/ifcfg-ens33
    echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo NAME=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo DEVICE=eth0 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo IPADDR=192.168.2.139 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo #GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    echo DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens33
    mac=`ifconfig ens33|grep ether|awk '{print $2}'`
    sed -i '/BOOTPROTO/aHWADDR='$mac'' /etc/sysconfig/network-scripts/ifcfg-ens33
    more /etc/sysconfig/network-scripts/ifcfg-ens33
    mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
    
    
    > /etc/sysconfig/network-scripts/ifcfg-ens34
    echo TYPE=Ethernet >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo BOOTPROTO=none >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo NAME=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo DEVICE=eth1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo ONBOOT=yes >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo IPADDR=192.168.2.139 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo PREFIX=24 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo #GATEWAY=192.168.2.1 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    echo DNS1=114.114.114.114 >> /etc/sysconfig/network-scripts/ifcfg-ens34
    mac=`ifconfig ens34|grep ether|awk '{print $2}'`
    sed -i '/BOOTPROTO/aHWADDR='$mac'' /etc/sysconfig/network-scripts/ifcfg-ens34
    more ifcfg-ens34
    mv /etc/sysconfig/network-scripts/ifcfg-ens34 /etc/sysconfig/network-scripts/ifcfg-eth1
    
    
    sed -i 's/rhgb/net.ifnames=0 biosdevname=0 &/' /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg
    
    
    2.Oracle 7 Yum源下载
    wget http://public-yum.oracle.com/public-yum-ol7.repo
    
    3.SecureCRT保存日志设置
    
    Options-->Global Options-->General-->Default Session-->Edit Default Settings-->Terminal-->Log File-->
    Log File Name Path:
    D:SecureCRT_logsession-%S-%Y%M%D-%h%m%s.log
    Options
    Start log upon connect Overwrite file
    Start new log at midnight (must use %D in log file name)
    Upon connect: [%Y%M%D_%h:%m:%s]
    On each line: [%h:%m:%s]
    
    4.安装mysql5.7数据库
    
    yum install wget -y
    vi /etc/yum.repos.d/mysql.repo
    /etc/yum.repos.d/mysql.repo 
    # Enable to use MySQL 5.7
    [mysql57-community]
    name=MySQL 5.7 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    :wq!
    
    wget http://repo.mysql.com/RPM-GPG-KEY-mysql -O /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    yum makecache
    yum repolist all |grep mysql
    rpm -qa|grep mysql
    yum install mysql-community-server -y
    
    5.初始化mysql5.7数据库
    
    grep "password" /var/log/mysqld.log     //临时密码
    2020-07-07T20:05:45.601403Z 1 [Note] A temporary password is generated for root@localhost: !j8UWxW_jd.g
    mysql>
    set global validate_password_policy=0;
    set global validate_password_length=1;
    alter user 'root'@'localhost' identified by '2wsxzaq1';
    flush privileges;
    quit
    
    6.创建Zabbix4.02 Yum源文件和下载php7.2 yum源
    
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    rpm -Uvh >/etc/yum.repos.d/zabbix.repo
    cat <<EOF > /etc/yum.repos.d/zabbix.repo 
    [zabbix]
    name=Zabbix Official Repository - $basearch
    baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
    
    [zabbix-non-supported]
    name=Zabbix Official Repository non-supported - $basearch 
    baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
    gpgcheck=1
    EOF
    
    curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
    curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
    
    mkdir -p /etc/yum.repos.d.bak
    mv /etc/yum.repos.d/mysql.repo /etc/yum.repos.d.bak/
    
    7.安装php7.2
    
    rpm -qa|grep php*
    yum -y remove php*
    yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
    systemctl enable --now php-fpm
    php -v
    
    
    8.主机名永久更改
    hostnamectl set-hostname zabbix
    
    9.常用小软件安装
    
    yum install -y tree vim wget bash-completion   bash-completion-extras  lrzsz net-tools sysstat iotop iftop htop unzip  telnet  ntpdate net-snmp-utils lvm2 lsof
    yum provides '*/applydeltarpm'
    yum install deltarpm -y
    yum install gcc gcc-c++ ncurses-devel.x86_64 lrzsz.x86_64 cmake.x86_64 libaio.x86_64 bison.x86_64 gcc-c++.x86_64 bind-utils wget curl curl-devel perl openssh-clients setuptool sysstat make redhat-lsb* -y
    yum install https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm -y
    yum install http://rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/glibmm24-devel-2.56.0-1.el7.x86_64.rpm
    yum install http://mirror.centos.org/centos/7/os/x86_64/Packages/glibmm24-2.56.0-1.el7.x86_64.rpm
    yum install http://mirror.centos.org/centos/7/os/x86_64/Packages/freetype-devel-2.8-14.el7.x86_64.rpm
    yum install http://mirror.centos.org/centos/7/os/x86_64/Packages/libevent-devel-2.0.21-4.el7.x86_64.rpm
    yum install http://mirror.centos.org/centos/7/os/x86_64/Packages/libxslt-devel-1.1.28-5.el7.x86_64.rpm
    yum install http://rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/libxslt-devel-1.1.28-5.el7.x86_64.rpm
    yum install http://www.rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/libgcrypt-devel-1.5.3-14.el7.x86_64.rpm
    yum install http://rpmfind.net/linux/centos/7.8.2003/os/x86_64/Packages/libxml2-devel-2.9.1-6.el7.4.x86_64.rpm
    
    yum install libevent libevent-devel libaio gcc libxml* unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre* -y
    yum -y install mysql-devel libcurl-devel net-snmp-devel php-bcmath php-ldap php-mbstring php-xmlwriter libevent-devel libevent pcre* bzip2 bzip2-devel libjpeg-turbo-devel libpng-devel libxslt-devel libgcrypt-devel libgpg-error-devel freetype-devel gmp-devel libicu-devel 
    
    
    10.设置VIM显行数
    echo 'set nu' >> /etc/vimrc
    echo 'set tabstop=4' >> /etc/vimrc
    source /etc/profile
    
    11.优化SSH连接速度
    sed -i s#'GSSAPIAuthentication yes'#'GSSAPIAuthentication no'#g /etc/ssh/sshd_config
    sed -i s#'#UseDNS yes'#'UseDNS no'#g /etc/ssh/sshd_config  
    grep GSSAPIAuthentication /etc/ssh/sshd_config
    grep UseDNS /etc/ssh/sshd_config
    systemctl restart sshd
    
    12.优化命令行显示
    echo 'PS1="[[e[34;1m]u@[e[0m][e[32;1m]H[e[0m] [e[31;1m]w[e[0m]]\$ "' >> /etc/bashrc
    source /etc/profile
    
    13.关闭selinux和创建防火墙策略
    sed -i s#SELINUX=enforcing#SElINUX=disabled#g /etc/selinux/config
    grep =disabled /etc/selinux/config
    setenforce 0
    getenforce
    firewall-cmd --permanent --add-port=80/tcp --add-port=443/tcp --add-port=10050/tcp --add-port=10051/tcp --add-port=10050/udp --add-port=10051/udp
    firewall-cmd --reload
    firewall-cmd --list-all
    
    14.时间同步
    crontab -e
    0 0 * * * /sbin/hwclock -w
    :wq!
    crontab -l
    检查执行情况,查看日志路径为/var/log/cron
    
    15.安装httpd
    
    yum install httpd -y
    systemctl start httpd
    
    16.安装zabbix组件
    yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
    
    17.导入zabbix数据库
    mysql -uroot -p
    mysql>
    set global validate_password_policy=0;
    set global validate_password_length=1;
    create database zabbix character set utf8 collate utf8_bin;
    grant all on zabbix.* to zabbix@localhost identified by '2wsxzaq1';
    flush privileges;
    zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
    
    18.配置zabbix配置文件中的DB密码
    vi /etc/zabbix/zabbix.conf DBPassword
    =2wsxzaq1 19.变更php配置文件属性 vim /etc/php.ini #php_value date.timezone Europe/Riga php_value date.timezone Asia/Shanghai :wq! vim /etc/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone =Asia/Shanghai memory_limit = 256M chown apache.apache -R /var/lib/php 20.中文乱码处理 scp /Users/Vincent/Downloads/msyh.ttf root@192.168.2.143:/root/ find / -name DejaVuSans.ttf cp /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak rm -rf /usr/share/fonts/dejavu/DejaVuSans.ttf mv msyh.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf systemctl restart php-fpm httpd zabbix-server zabbix-agent systemctl enable php-fpm httpd zabbix-server zabbix-agent mysqld 21.启动zabbix相关服务进程 systemctl restart zabbix-server zabbix-agent httpd php-fpm systemctl enable zabbix-server zabbix-agent httpd php-fpm 22.分区和LVM磁盘创建 mkdir -p /data parted -l parted /dev/sdb mklabel gpt mkpart data 0 -1 I p quit mkfs.xfs /dev/sdb1 pvcreate /dev/sdb1 vgcreate datavg /dev/sdb1 lvcreate -l 100%free -n lvdata datavg mkfs.xfs /dev/datavg/lvdata mount /dev/datavg/lvdata /data echo '/dev/datavg/lvdata /data xfs defaults 0 0' >> /etc/fstab df -h df -T 23.停止服务,准备变更数据库目录 systemctl stop zabbix-server zabbix-agent httpd php-fpm mysqladmin -uroot -p shutdown Enter password: 24.复制数据文件到新目录 cp -ra /var/lib/mysql /data cp -ra /etc/my.cnf /etc/my.cnf.bak 25.修改与数据库关联配置文件 vim /etc/my.cnf [mysqld_safe] socket=/data/mysql/mysql.sock [mysqld] datadir=/data/mysql socket=/data/mysql/mysql.sock vim /etc/zabbix/zabbix_server.conf DBSocket=/data/mysql/mysql.sock :wq! vim /etc/php.ini mysqli.default_socket = /data/mysql/mysql.sock :wq! 26.重启生效 先重启mysql,才重启zabbix-servere/Zabbix-agent/php-fpm/httpd

    27.数据库的mysql.sock可能连不上的最便捷解决方法

    ln -s /data/mysql/mysql.sock /var/lib/mysql/mysql.sock
  • 相关阅读:
    MongoDB笔记
    mysql笔记
    08-下载中间件
    ubuntu1804安装pycharm2018.3.x
    02-CSS基础
    14-eval 函数
    13-文件
    12-模块和包
    11-异常
    有关dir和 unittest
  • 原文地址:https://www.cnblogs.com/vincent-liang/p/13276907.html
Copyright © 2011-2022 走看看