本文共 4389 字,大约阅读时间需要 14 分钟。
setenforce 0sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/configgrep SELINUX /etc/selinux/config//添加防火墙配置systemctl start firewalld.service && systemctl enable firewalld.servicefirewall-cmd --zone=public --add-port=10050/tcp --permanent firewall-cmd --zone=public --add-port=10051/tcp --permanentfirewall-cmd --zone=public --add-port=3306/tcp --permanentfirewall-cmd --zone=public --add-port=22/tcp --permanentfirewall-cmd --zone=public --add-port=5432/tcp --permanentfirewall-cmd --zone=public --add-port=80/tcp --permanentfirewall-cmd --reloadfirewall-cmd --zone=public --list-ports安装YUM源:cd /etc/yum.repos.d/wget http://mirrors.163.com/.help/CentOS7-Base-163.repoyum clean allyum makecache一:安装LAMP:1:mysqlyum install -y mariadb mariadb-serversystemctl start mariadb && systemctl enable mariadb安全初始化,设置root密码等mysql_secure_installationmysql -uroot -p1234562:安装apacheyum -y install httpdsystemctl start httpd.service && systemctl enable httpd.service//检查一下状态systemctl status httpd.service3:安装phpyum -y install php//安装php-mysql,php-mysql是一个用于让PHP程序使用MySQL数据库的模块。要安装该模块yum -y install php-mysqlsystemctl restart httpd4:测试lamp安装完成后,PHP会生成配置文件/etc/httpd/conf.d/php.conf,因为该配置文件在/etc/httpd/conf.d目录下,所以它会被Apache所读取。PHP还会生成配置文件/etc/httpd/conf.modules.d/10-php.conf,该配置文件也会被Apache所读取,它的设定让Apache可以加载PHP模块。不过,PHP软件本身的配置文件其实是/etc/php.ini。可以测试: 为了测试Apache能不能正常调用PHP,在/var/www/html目录下新建一个phpinfo.php文档,内容如下所示:echo " " >/var/www/html/phpinfo.php二:安装zabbix安装包下载地址:http://www.zabbix.com/download.php1.官方文档:https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages2.导入源:rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm3.安装zabbix包yum -y install zabbix-server-mysql zabbix-web-mysql//Agentyum -y install zabbix-agent5.初始化数据库mysql> create database zabbix character set utf8 collate utf8_bin;mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; //授权,密码是 zabbix进入到这个目录cd /usr/share/doc/zabbix-server-mysql-3.2.1zcat create.sql.gz | mysql -uroot -p123456 zabbix //导入至zabbix库6.启动zabbix server服务vim /etc/zabbix/zabbix_server.confDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix实际上我的配置文件修改的是DBHost和DBPassword去掉前面的#号。启动zabbix服务,设置开机自启动systemctl start zabbix-serversystemctl enable zabbix-server7.编辑zabbix前端的PHP配合配置php_value max_execution_time 300php_value memory_limit 128Mphp_value post_max_size 16Mphp_value upload_max_filesize 2Mphp_value max_input_time 300php_value always_populate_raw_post_data -1php_value date.timezone Asia/Shanghai //主要去掉# 改成上海调整时间同步:yum -y install ntpdate ntpdate cn.pool.ntp.org启动apache服务,设置开机自启动systemctl restart httpd8.登陆zabbixhttp://IP/zabbix/ 或者 http://IP/zabbix/setup.php默认用户名/密码:Admin/zabbix三:配置客户端rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpmyum -y install zabbix-agentvi /etc/zabbix/zabbix_agentd.conf修改此文件中的下面三个值Server=192.168.92.8 //安装zabbix服务端的机器的IPServerActive=192.168.92.8 //安装zabbix服务端的机器的IPHostname=09 //随便起,我这以被监控的机器的ip作为Hostnamesystemctl start zabbix-agent && firewall-cmd --zone=public --add-port=10050/tcp --permanent && firewall-cmd --reload && firewall-cmd --zone=public --list-ports四:zabbix结合微信apimkdir -p /usr/lib/zabbix/alertscripts/cd /usr/lib/zabbix/alertscripts/wget http://dl.cactifans.org/tools/zabbix_weixin.x86_64.tar.gztar zxvf zabbix_weixin.x86_64.tar.gzmv zabbix_weixin/weixin .chmod a+x weixinmv zabbix_weixin/weixincfg.json /etc/rm -rf zxvf zabbix_weixin.x86_64.tar.gzrm -rf zabbix_weixin/vim /etc/weixincfg.json{"corp": { "corpid": "wxxxxxx", "secret": "Vn6dxxxx", "agentid": 1 }}测试:/usr/lib/zabbix/alertscripts/weixin xxx subject bodyxxx 账号subject 告警主题boyd 告警闲情//zabbix页面配置脚本参数:{ALERT.SENDTO}{ALERT.SUBJECT}{ALERT.MESSAGE}自定义动作:告警主题:[{TRIGGER.SEVERITY}]服务器:{HOSTNAME1}发生:{TRIGGER.NAME}故障!告警内容:告警主机: {HOSTNAME1}主机分组: {TRIGGER.HOSTGROUP.NAME}告警时间: {EVENT.DATE} {EVENT.TIME}告警等级: {TRIGGER.SEVERITY}告警信息: {TRIGGER.NAME}告警项目: {TRIGGER.KEY1}问题详情: {ITEM.NAME}:{ITEM.VALUE}当前状态: {TRIGGER.STATUS}事件ID: {EVENT.ID}恢复主题:[{TRIGGER.SEVERITY}]服务器:{HOSTNAME1}发生:{TRIGGER.NAME}已恢复!恢复内容:告警主机: {HOSTNAME1}主机分组: {TRIGGER.HOSTGROUP.NAME}告警时间: {EVENT.DATE} {EVENT.TIME}告警等级: {TRIGGER.SEVERITY}告警信息: {TRIGGER.NAME}告警项目: {TRIGGER.KEY1}问题详情: {ITEM.NAME}:{ITEM.VALUE}当前状态: {TRIGGER.STATUS}事件ID: {EVENT.ID}
转载于:https://blog.51cto.com/topping/1962766