Centos7.2 安装 zabbix server 3.4


一、安装 zabbix server 3.4

参考连接:

https://www.zabbix.com/download?zabbix=3.4&os_distribution=centos&os_version=7&db=MySQL

https://www.zabbix.com/documentation/3.4/zh/manual/installation/install_from_packages#from_distribution_packages


关闭防火墙

#systemctlstopfirewalld.service#关闭防火墙
#systemctldisablefirewalld.service#开机不启动防火墙

 

关闭selinux

#sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config#在/etc/selinux/config把SELNUX=enforcing换成SELINUX=disabled

#grepSELINUX=disabled/etc/selinux/config#过滤刚刚换的disabled
SELINUX=disabled
#setenforce0#清空selinux的配置


MysqL数据库的安装

tarxvfMysqL-5.7.20-1.el7.x86_64.rpm-bundle.tar
rpm-e--nodepsmariadb-libs
rpm-ivhMysqL-community-client-5.7.20-1.el7.x86_64
rpm-ivhMysqL-community-libs-5.7.20-1.el7.x86_64
rpm-ivhMysqL-community-server-5.7.20-1.el7.x86_64
rpm-ivhMysqL-community-common-5.7.20-1.el7.x86_64
rpm-ivhMysqL-community-libs-compat-5.7.20-1.el7.x86_64

systemctlstartMysqLd#修改密码

cat/var/log/MysqLd.log|greppasswordsystemctlenableMysqLd

alteruserroot@'localhost'identifiedby'';

Zabbix Server 3.4安装及配置

wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm


安装163的yum源,zabbix必须的PHP两个所需模块bcmath和mbstring epel yum 源没有, 只有网易163源中有


wget http://mirrors.163.com/.help/CentOS7-Base-163.repo



# cat /etc/yum.repos.d/CentOS7-Base-163.repo

#CentOS-Base.repo
#
#ThemirrorsystemusestheconnectingIPaddressoftheclientandthe
#updatestatusofeachmirrortopickmirrorsthatareupdatedtoand
#geographicallyclosetotheclient.YoushouldusethisforCentOSupdates
#unlessyouaremanuallypickingothermirrors.
#
#Ifthemirrorlist=doesnotworkforyou,asafallbackyoucantrythe
#remarkedoutbaseurl=lineinstead.
#
#
[base]
name=CentOS-7-Base-163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#releasedupdates
[updates]
name=CentOS-7-Updates-163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additionalpackagesthatmaybeuseful
[extras]
name=CentOS-7-Extras-163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additionalpackagesthatextendfunctionalityofexistingpackages
[centosplus]
name=CentOS-7-Plus-163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7


# yum install zabbix-server-MysqL zabbix-web-MysqL zabbix-agent


# MysqL -uroot -p

# password


MysqL> create database zabbix character set utf8 collate utf8_bin;

MysqL> grant all privileges on zabbix.* to zabbix@localhost identified by 'password';

MysqL> quit;


# zcat /usr/share/doc/zabbix-server-MysqL*/create.sql.gz | MysqL -uzabbix -D zabbix -p



配置zabbix数据库

# vi /etc/zabbix/zabbix_server.conf

DBHost=localhost

dbname=zabbix

DBUser=zabbix

DBPassword=password



# systemctl start zabbix-server zabbix-agent httpd

# systemctl enable zabbix-server zabbix-agent httpd


配置 PHP zabbix 前台


vim /etc/httpd/conf.d/zabbix.conf

# PHP_value date.timezone Europe/Riga

替换为:

PHP_value date.timezone Asia/Shanghai



配置 zabbix前台

Connect to your newly installed Zabbix frontend: http://server_ip_or_name/zabbix

Follow steps described in Zabbix documentation: Installing frontend



zabbix 帮助文档

https://www.zabbix.com/documentation/3.4/manual/quickstart/login



二、zabbix agent 安装


wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm


yum install zabbix-agent

systemctl start zabbix-agent

systemctl enable zabbix-agent


客户端配置:

# cat /etc/zabbix/zabbix_agentd.conf | grep -v "^#"| grep -v '^$'

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.51
ServerActive=192.168.1.51:10051
HostnameItem=system.run[ifconfig|grep"inet"|grep-E-o"(2[0-4][0-9]|25[0-5]|1[0-9][0-9]|[1-9]?[0-9])(.(2[0-4][0-9]|25[0-5]|1[0-9][0-9]|[1-9]?[0-9])){3}"|grep"192.168.1"|head-1]
RefreshActiveChecks=120
Include=/etc/zabbix/zabbix_agentd.d/*.conf




三、zabbix做分区

MysqL>usezabbix;
MysqL>altertabletrendsrenametrends_bak;
QueryOK,0rowsaffected(0.04sec)
MysqL>CREATETABLE`trends`(
`itemid`bigint(20)unsignednOTNULL,`clock`int(11)NOTNULLDEFAULT'0',`num`int(11)NOTNULLDEFAULT'0',`value_min`double(16,4)NOTNULLDEFAULT'0.0000',`value_avg`double(16,`value_max`double(16,PRIMARYKEY(`itemid`,`clock`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8COLLATE=utf8_bin
PARTITIONBYRANGE(clock)
(
PARTITIONp2018_02VALUESLEsstHAN(UNIX_TIMESTAMP("2018-03-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_03VALUESLEsstHAN(UNIX_TIMESTAMP("2018-04-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_04VALUESLEsstHAN(UNIX_TIMESTAMP("2018-05-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_05VALUESLEsstHAN(UNIX_TIMESTAMP("2018-06-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_06VALUESLEsstHAN(UNIX_TIMESTAMP("2018-07-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_07VALUESLEsstHAN(UNIX_TIMESTAMP("2018-08-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_08VALUESLEsstHAN(UNIX_TIMESTAMP("2018-09-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_09VALUESLEsstHAN(UNIX_TIMESTAMP("2018-10-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_10VALUESLEsstHAN(UNIX_TIMESTAMP("2018-11-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_11VALUESLEsstHAN(UNIX_TIMESTAMP("2018-12-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_12VALUESLEsstHAN(UNIX_TIMESTAMP("2019-01-0100:00:00"))ENGINE=InnoDB);
QueryOK,0rowsaffected(0.11sec)


MysqL>altertabletrends_uintrenametrends_uint_bak;
QueryOK,0rowsaffected(0.02sec)

MysqL>CREATETABLE`trends_uint`(
`itemid`bigint(20)unsignednOTNULL,`value_min`bigint(20)unsignednOTNULLDEFAULT'0',`value_avg`bigint(20)unsignednOTNULLDEFAULT'0',`value_max`bigint(20)unsignednOTNULLDEFAULT'0',`clock`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8COLLATE=utf8_bin
PARTITIONBYRANGE(clock)
(PARTITIONp2017_11VALUESLEsstHAN(UNIX_TIMESTAMP("2017-12-0100:00:00"))ENGINE=InnoDB,PARTITIONp2017_12VALUESLEsstHAN(UNIX_TIMESTAMP("2018-01-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_01VALUESLEsstHAN(UNIX_TIMESTAMP("2018-02-0100:00:00"))ENGINE=InnoDB,PARTITIONp2018_02VALUESLEsstHAN(UNIX_TIMESTAMP("2018-03-0100:00:00"))ENGINE=InnoDB,0rowsaffected(0.13sec)


MysqL>altertablehistoryrenamehistory_bak;
QueryOK,0rowsaffected(0.02sec)
MysqL>altertablehistory_uintrenamehistory_uint_bak;
QueryOK,0rowsaffected(0.00sec)
MysqL>altertablehistory_textrenamehistory_text_bak;
QueryOK,0rowsaffected(0.01sec)
MysqL>altertablehistory_strrenamehistory_str_bak;
QueryOK,0rowsaffected(0.01sec)
MysqL>altertablehistory_logrenamehistory_log_bak;
QueryOK,0rowsaffected(0.01sec)



MysqL>CREATETABLE`history`(
`itemid`bigint(20)unsignednOTNULL,`value`double(16,`ns`int(11)NOTNULLDEFAULT'0',KEY`history_index`(`itemid`,`clock`,`value`,`ns`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8COLLATE=utf8_bin
PARTITIONBYRANGE(clock)
(PARTITIONp2018_02_01VALUESLEsstHAN(1517500800)ENGINE=InnoDB,PARTITIONp2018_02_02VALUESLEsstHAN(1517587200)ENGINE=InnoDB,PARTITIONp2018_02_03VALUESLEsstHAN(1517673600)ENGINE=InnoDB,PARTITIONp2018_02_04VALUESLEsstHAN(1517760000)ENGINE=InnoDB,PARTITIONp2018_02_05VALUESLEsstHAN(1517846400)ENGINE=InnoDB,PARTITIONp2018_02_06VALUESLEsstHAN(1517932800)ENGINE=InnoDB,PARTITIONp2018_02_07VALUESLEsstHAN(1518019200)ENGINE=InnoDB,PARTITIONp2018_02_08VALUESLEsstHAN(1518105600)ENGINE=InnoDB,PARTITIONp2018_02_09VALUESLEsstHAN(1518192000)ENGINE=InnoDB,PARTITIONp2018_02_10VALUESLEsstHAN(1518278400)ENGINE=InnoDB,PARTITIONp2018_02_11VALUESLEsstHAN(1518364800)ENGINE=InnoDB,PARTITIONp2018_02_12VALUESLEsstHAN(1518451200)ENGINE=InnoDB,PARTITIONp2018_02_13VALUESLEsstHAN(1518537600)ENGINE=InnoDB,PARTITIONp2018_02_14VALUESLEsstHAN(1518624000)ENGINE=InnoDB,PARTITIONp2018_02_15VALUESLEsstHAN(1518710400)ENGINE=InnoDB,PARTITIONp2018_02_16VALUESLEsstHAN(1518796800)ENGINE=InnoDB,PARTITIONp2018_02_17VALUESLEsstHAN(1518883200)ENGINE=InnoDB,PARTITIONp2018_02_18VALUESLEsstHAN(1518969600)ENGINE=InnoDB,PARTITIONp2018_02_19VALUESLEsstHAN(1519056000)ENGINE=InnoDB,PARTITIONp2018_02_20VALUESLEsstHAN(1519142400)ENGINE=InnoDB,PARTITIONp2018_02_21VALUESLEsstHAN(1519228800)ENGINE=InnoDB,PARTITIONp2018_02_22VALUESLEsstHAN(1519315200)ENGINE=InnoDB,PARTITIONp2018_02_23VALUESLEsstHAN(1519401600)ENGINE=InnoDB,PARTITIONp2018_02_24VALUESLEsstHAN(1519488000)ENGINE=InnoDB,PARTITIONp2018_02_25VALUESLEsstHAN(1519574400)ENGINE=InnoDB,PARTITIONp2018_02_26VALUESLEsstHAN(1519660800)ENGINE=InnoDB,PARTITIONp2018_02_27VALUESLEsstHAN(1519747200)ENGINE=InnoDB,PARTITIONp2018_02_28VALUESLEsstHAN(1519833600)ENGINE=InnoDB,PARTITIONp2018_03_01VALUESLEsstHAN(1519920000)ENGINE=InnoDB,PARTITIONp2018_03_02VALUESLEsstHAN(1520006400)ENGINE=InnoDB,PARTITIONp2018_03_03VALUESLEsstHAN(1520092800)ENGINE=InnoDB,PARTITIONp2018_03_04VALUESLEsstHAN(1520179200)ENGINE=InnoDB,PARTITIONp2018_03_05VALUESLEsstHAN(1520265600)ENGINE=InnoDB,PARTITIONp2018_03_06VALUESLEsstHAN(1520352000)ENGINE=InnoDB,PARTITIONp2018_03_07VALUESLEsstHAN(1520438400)ENGINE=InnoDB,PARTITIONp2018_03_08VALUESLEsstHAN(1520524800)ENGINE=InnoDB,PARTITIONp2018_03_09VALUESLEsstHAN(1520611200)ENGINE=InnoDB,PARTITIONp2018_03_10VALUESLEsstHAN(1520697600)ENGINE=InnoDB,PARTITIONp2018_03_11VALUESLEsstHAN(1520784000)ENGINE=InnoDB,PARTITIONp2018_03_12VALUESLEsstHAN(1520870400)ENGINE=InnoDB,PARTITIONp2018_03_13VALUESLEsstHAN(1520956800)ENGINE=InnoDB,PARTITIONp2018_03_14VALUESLEsstHAN(1521043200)ENGINE=InnoDB,PARTITIONp2018_03_15VALUESLEsstHAN(1521129600)ENGINE=InnoDB,PARTITIONp2018_03_16VALUESLEsstHAN(1521216000)ENGINE=InnoDB,PARTITIONp2018_03_17VALUESLEsstHAN(1521302400)ENGINE=InnoDB,PARTITIONp2018_03_18VALUESLEsstHAN(1521388800)ENGINE=InnoDB,PARTITIONp2018_03_19VALUESLEsstHAN(1521475200)ENGINE=InnoDB,PARTITIONp2018_03_20VALUESLEsstHAN(1521561600)ENGINE=InnoDB,PARTITIONp2018_03_21VALUESLEsstHAN(1521648000)ENGINE=InnoDB,PARTITIONp2018_03_22VALUESLEsstHAN(1521734400)ENGINE=InnoDB,PARTITIONp2018_03_23VALUESLEsstHAN(1521820800)ENGINE=InnoDB,PARTITIONp2018_03_24VALUESLEsstHAN(1521907200)ENGINE=InnoDB,PARTITIONp2018_03_25VALUESLEsstHAN(1521993600)ENGINE=InnoDB,PARTITIONp2018_03_26VALUESLEsstHAN(1522080000)ENGINE=InnoDB,PARTITIONp2018_03_27VALUESLEsstHAN(1522166400)ENGINE=InnoDB,PARTITIONp2018_03_28VALUESLEsstHAN(1522252800)ENGINE=InnoDB);
QueryOK,0rowsaffected(0.67sec)



MysqL>CREATETABLE`history_uint`(
`itemid`bigint(20)unsignednOTNULL,`value`bigint(20)unsignednOTNULLDEFAULT'0',KEY`history_uint_index`(`itemid`,0rowsaffected(0.60sec)



MysqL>CREATETABLE`history_str`(
`itemid`bigint(20)unsignednOTNULL,`value`varchar(255)COLLATEutf8_binNOTNULLDEFAULT'',KEY`history_str_1`(`itemid`,`clock`)
)ENGINE=InnoDBDEFAULTCHARSET=utf8COLLATE=utf8_bin
PARTITIONBYRANGE(clock)
(PARTITIONp2018_02_01VALUESLEsstHAN(1517500800)ENGINE=InnoDB,0rowsaffected(0.60sec)



MysqL>CREATETABLE`history_log`(
`itemid`bigint(20)unsignednOTNULL,`timestamp`int(11)NOTNULLDEFAULT'0',`source`varchar(64)COLLATEutf8_binNOTNULLDEFAULT'',`severity`int(11)NOTNULLDEFAULT'0',`value`textCOLLATEutf8_binNOTNULL,`logeventid`int(11)NOTNULLDEFAULT'0',KEY`history_log_1`(`itemid`,0rowsaffected(0.62sec)



MysqL>CREATETABLE`history_text`(
`itemid`bigint(20)unsignednOTNULL,KEY`history_text_1`(`itemid`,0rowsaffected(0.62sec)


配置分区策略,采用外部分区的方式


yum install perl-Sys-Syslog

yum install per-DateTime

yum install perl-DateTime

yum install perl-dbd-mysql


vim /etc/rsyslog.conf

local6.*/var/log/zabbix-partition.log


systemctl restart rsyslog


cat /var/lib/MysqL/MysqL_partition.pl


#!/usr/bin/perl
usestrict;
useData::Dumper;
useDBI;
useSys::Syslogqw(:standard:macros);
useDateTime;
usePOSIXqw(strftime);
openlog("MysqL_zbx_part","ndelay,pid",LOG_LOCAL6);
my$db_schema='zabbix';
my$dsn='DBI:MysqL:'.$db_schema.':MysqL_socket=/data/MysqL/MysqL.sock';
my$db_user_name='zabbix';
my$db_password='i5$4)Ci10(sn';
my$tables={'history'=>{'period'=>'day','keep_history'=>'60'},'history_log'=>{'period'=>'day','history_str'=>{'period'=>'day','history_text'=>{'period'=>'day','history_uint'=>{'period'=>'day','trends'=>{'period'=>'month','keep_history'=>'3'},'trends_uint'=>{'period'=>'month',#commentnext5linesifyoupartitionzabbixdatabasestartingfrom2.2
#theyusuallyusedforzabbixdatabasebefore2.2
#'ackNowledges'=>{'period'=>'month','keep_history'=>'23'},#'alerts'=>{'period'=>'month','keep_history'=>'6'},#'auditlog'=>{'period'=>'month','keep_history'=>'24'},#'events'=>{'period'=>'month','keep_history'=>'12'},#'service_alarms'=>{'period'=>'month',};
my$amount_partitions=30;
my$curr_tz='Asia/Shanghai';
my$part_tables;
my$dbh=DBI->connect($dsn,$db_user_name,$db_password);
unless(check_have_partition()){
print"YourinstallationofMysqLdoesnotsupporttablepartitioning.\n";
syslog(LOG_CRIT,'YourinstallationofMysqLdoesnotsupporttablepartitioning.');
exit1;
}
my$sth=$dbh->prepare(qq{SELECTtable_name,partition_name,lower(partition_method)aspartition_method,rtrim(ltrim(partition_expression))aspartition_expression,partition_description,table_rows
FROMinformation_schema.partitions
WHEREpartition_nameISNOTNULLANDtable_schema=?});
$sth->execute($db_schema);
while(my$row=$sth->fetchrow_hashref()){
$part_tables->{$row->{'table_name'}}->{$row->{'partition_name'}}=$row;
}
$sth->finish();
foreachmy$key(sortkeys%{$tables}){
unless(defined($part_tables->{$key})){
syslog(LOG_ERR,'Partitioningfor"'.$key.'"isnotfound!Thetablemightbenotpartitioned.');
next;
}
create_next_partition($key,$part_tables->{$key},$tables->{$key}->{'period'});
remove_old_partitions($key,$tables->{$key}->{'period'},$tables->{$key}->{'keep_history'})
}
delete_old_data();
$dbh->disconnect();
subcheck_have_partition{
my$result=0;
#MysqL5.5
#my$sth=$dbh->prepare(qq{SELECtvariable_valueFROMinformation_schema.global_variablesWHEREvariable_name='have_partitioning'});
#MysqL5.6
my$sth=$dbh->prepare(qq{SELECTplugin_statusFROMinformation_schema.pluginsWHEREplugin_name='partition'});
$sth->execute();
my$row=$sth->fetchrow_array();
$sth->finish();
#MysqL5.5
#return1if$roweq'YES';
#MysqL5.6
return1if$roweq'ACTIVE';
}
subcreate_next_partition{
my$table_name=shift;
my$table_part=shift;
my$period=shift;
for(my$curr_part=0;$curr_part<$amount_partitions;$curr_part++){
my$next_name=name_next_part($tables->{$table_name}->{'period'},$curr_part);
my$found=0;
foreachmy$partition(sortkeys%{$table_part}){
if($next_nameeq$partition){
syslog(LOG_INFO,"Nextpartitionfor$table_naMetablehasalreadybeencreated.Itis$next_name");
$found=1;
}
}
if($found==0){
syslog(LOG_INFO,"Creatingapartitionfor$table_naMetable($next_name)");
my$query='ALTERTABLE'."$db_schema.$table_name".'ADDPARTITION(PARTITION'.$next_name.
'VALUESlessthan(UNIX_TIMESTAMP("'.date_next_part($tables->{$table_name}->{'period'},$curr_part).'")div1))';
syslog(LOG_DEBUG,$query);
$dbh->do($query);
}
}
}
subremove_old_partitions{
my$table_name=shift;
my$table_part=shift;
my$period=shift;
my$keep_history=shift;
my$curr_date=DateTime->Now;
$curr_date->set_time_zone($curr_tz);
if($periodeq'day'){
$curr_date->add(days=>-$keep_history);
$curr_date->add(hours=>-$curr_date->strftime('%H'));
$curr_date->add(minutes=>-$curr_date->strftime('%M'));
$curr_date->add(seconds=>-$curr_date->strftime('%s'));
}
elsif($periodeq'week'){
}
elsif($periodeq'month'){
$curr_date->add(months=>-$keep_history);
$curr_date->add(days=>-$curr_date->strftime('%d')+1);
$curr_date->add(hours=>-$curr_date->strftime('%H'));
$curr_date->add(minutes=>-$curr_date->strftime('%M'));
$curr_date->add(seconds=>-$curr_date->strftime('%s'));
}
foreachmy$partition(sortkeys%{$table_part}){
if($table_part->{$partition}->{'partition_description'}<=$curr_date->epoch){
syslog(LOG_INFO,"Removingold$partitionpartitionfrom$table_naMetable");
my$query="ALTERTABLE$db_schema.$table_nameDROPPARTITION$partition";
syslog(LOG_DEBUG,$query);
$dbh->do($query);
}
}
}
subname_next_part{
my$period=shift;
my$curr_part=shift;
my$name_template;
my$curr_date=DateTime->Now;
$curr_date->set_time_zone($curr_tz);
if($periodeq'day'){
my$curr_date=$curr_date->truncate(to=>'day');
$curr_date->add(days=>1+$curr_part);
$name_template=$curr_date->strftime('p%Y_%m_%d');
}
elsif($periodeq'week'){
my$curr_date=$curr_date->truncate(to=>'week');
$curr_date->add(days=>7*$curr_part);
$name_template=$curr_date->strftime('p%Y_%m_w%W');
}
elsif($periodeq'month'){
my$curr_date=$curr_date->truncate(to=>'month');
$curr_date->add(months=>1+$curr_part);
$name_template=$curr_date->strftime('p%Y_%m');
}
return$name_template;
}
subdate_next_part{
my$period=shift;
my$curr_part=shift;
my$period_date;
my$curr_date=DateTime->Now;
$curr_date->set_time_zone($curr_tz);
if($periodeq'day'){
my$curr_date=$curr_date->truncate(to=>'day');
$curr_date->add(days=>2+$curr_part);
$period_date=$curr_date->strftime('%Y-%m-%d');
}
elsif($periodeq'week'){
my$curr_date=$curr_date->truncate(to=>'week');
$curr_date->add(days=>7*$curr_part+1);
$period_date=$curr_date->strftime('%Y-%m-%d');
}
elsif($periodeq'month'){
my$curr_date=$curr_date->truncate(to=>'month');
$curr_date->add(months=>2+$curr_part);
$period_date=$curr_date->strftime('%Y-%m-%d');
}
return$period_date;
}
subdelete_old_data{
$dbh->do("DELETEFROMsessionsWHERElastaccess<UNIX_TIMESTAMP(Now()-INTERVAL1MONTH)");
$dbh->do("TruncATEhousekeeper");
$dbh->do("DELETEFROMauditlog_detailsWHERENOTEXISTS(SELECTNULLFROMauditlogWHEREauditlog.auditid=auditlog_details.auditid)");
}

chmod +x MysqL_partition.pl


yum install ntpdate


crontab -l

*/5 * * * * /usr/sbin/ntpdate ntp.api.bz

20 11 * * * /var/lib/MysqL/scripts/MysqL_partition.pl



定期备份配置数据

MysqLdump-uroot-p--single-transaction-R--default-character-set=utf8--triggers--events--hex-blob--databaseszabbix--ignore-table=zabbix.history--ignore-table=zabbix.history_uint--ignore-table=zabbix.history_log--ignore-table=zabbix.history_str--ignore-table=zabbix.history_text--ignore-table=zabbix.trends--ignore-table=zabbix.trends_uint>zabbix_`date`.sql


关闭 housekeeper ,防止出现select itemid,min(clock) from history_uint group by itemid 语句 ,改语句执行非常的慢,对数据库的插入性能,系统的负载等有非常大影响


关闭方法:

Administration -> General -> Housekeeping.

关闭history ,trends表的清理策略


systemctl restart zabbix-server


zabbix的端口


tcp6 0 0 :::10050 :::* LISTEN 1248/zabbix_agentd

tcp6 0 0 :::10051 :::* LISTEN 1974/zabbix_server



zabbix的日志

# ll /var/log/zabbix/* #日志体系

-rw-rw-r-- 1 zabbix zabbix 18578 Feb 28 18:46 /var/log/zabbix/zabbix_agentd.log

-rw-rw-r--. 1 zabbix zabbix 79759 Feb 28 18:18 /var/log/zabbix/zabbix_server.log


参考:


http://www.zabbix.org/wiki/Docs/howto/mysql_partitioning

http://www.zabbix.org/wiki/Docs/howto/mysql_partition



常用的语句:

select partition_name part,partition_expression expr,partition_description descr,table_rows from information_schema.partitions where table_schema = schema() and table_name='history';

Centos7.2 安装 zabbix server 3.4 及初始化工作的更多相关文章

  1. three.js模拟实现太阳系行星体系功能

    这篇文章主要介绍了three.js模拟实现太阳系行星体系功能,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下

  2. HTML5页面无缝闪开的问题及解决方案

    这篇文章主要介绍了HTML5页面无缝闪开方案,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  3. 关于h5中的fetch方法解读(小结)

    这篇文章主要介绍了关于h5中的fetch方法解读(小结),fetch身为H5中的一个新对象,他的诞生,是为了取代ajax的存在而出现,有兴趣的可以了解一下

  4. 视频流 – 使用视频工具箱解码iOS 8中的h264

    需要解码h264流并获取像素缓冲区我知道iOS8上的视频工具箱可能1.如何将h264流转换为CMSampleBufferRef?

  5. ios – 为什么,将nil作为参数从Objc C发送到swift类初始化器,用新对象替换nil参数

    除非属性本身被声明为nonnull:

  6. 对于NSManagedObject,Xcode 9构建了Date vs NSDate的问题

    Xcode9为模拟器与设备中的实体的Date类型属性生成不同的代码.我在coredata中将类设置为类别/扩展名下的codegen功能.直到Xcode8.3(最新)它一切正常.下面是Xcode9为属性自动生成的代码–在设备上:–和,在模拟器上:–有谁遇到过这个问题?对于一个有50个成员的项目来解决这个问题的最佳解决方案是什么,直到Xcode更新修复它?

  7. iOS兼容输入类型日期 – 设置最小值最大值

    我试图在UIWebViewiOS应用程序中使用jQueryMobile设置日期,值设置正确但最小和最大属性日期设置不起作用.和当我在模拟器上运行它时,当选择日期字段时,日期选择器可见,但未设置最小,最大日期.解决方法模拟器的safari不支持设置输入类型=“日期”的最小值和最大值.您可以通过导航到thissite并尝试控制来测试它.它(可能)可以在桌面浏览器上运行,但不会在模拟器的浏览器或UIWebView中运行.

  8. ios – 设置NSDataDetector的上下文日期

    假设今天是2014年1月20日.如果我使用NSDataDetector从“明天下午4点”字符串中提取日期,我将得到2014-01-21T16:00.大.但是,假设我希望NSDataDetector假装当前日期是2014年1月14日.这样,当我解析“明天下午4点”时,我将得到2014-01-15T16:00.如果我在设备上更改系统时间,我会得到我想要的.但是,有没有办法以编程方式指定它?

  9. ios – 访问文件属性与访问sqlite记录

    >看到上述结果后,我决定选择attributesOfItemAtPath方法.还有什么我不是考虑传递sqlite?

  10. ios – 在Swift中对MKCircle进行子类化

    我想通过添加另一个String属性来继承MKCircle,我们称之为“代码”.这个属性不是可选的和常量的,所以我必须从初始化器设置它,对吧?有没有办法定义一个单一的便利初始化器,在这种情况下需要3个参数?本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请发送邮件至dio@foxmail.com举报,一经查实,本站将立刻删除。

随机推荐

  1. 在airgapped(离线)CentOS 6系统上安装yum软件包

    我有一个CentOS6系统,出于安全考虑,它已经被空气泄漏.它可能从未连接到互联网,如果有,它很长时间没有更新.我想将所有.rpm软件包放在一个驱动器上,这样它们就可以脱机安装而无需查询互联网.但是,我在测试VM上遇到的问题是,即使指定了本地路径,yum仍然会挂起并尝试从在线存储库进行更新.另外,有没有办法使用yum-utils/yumdownloader轻松获取该包的所有依赖项和所有依赖项?目前

  2. centos – 命名在日志旋转后停止记录到rsyslog

    CentOS6.2,绑定9.7.3,rsyslog4.6.2我最近设置了一个服务器,我注意到在日志轮换后,named已停止记录到/var/log/messages.我认为这很奇怪,因为所有日志记录都是通过rsyslog进行的,并且named不会直接写入日志文件.这更奇怪,因为我在更新区域文件后命名了HUPed,但它仍然没有记录.在我停止并重新启动命名后,记录恢复.这里发生了什么?

  3. centos – 显示错误的磁盘大小

    对于其中一个磁盘,Df-h在我的服务器上显示错误的空白区域:Cpanel表明它只有34GB免费,但还有更多.几分钟前,我删除了超过80GB的日志文件.所以,我确信它完全错了.fdisk-l/dev/sda2也显示错误:如果没有格式化,我该怎么做才能解决这个问题?并且打开文件描述符就是它需要使用才能做到这一点.所以…使用“lsof”并查找已删除的文件.重新启动写入日志文件的服务,你很可能会看到空间可用.

  4. 如何在centos 6.9上安装docker-ce 17?

    我目前正在尝试在centOS6.9服务器上安装docker-ce17,但是,当运行yuminstalldocker-ce时,我收到以下错误:如果我用跳过的标志运行它我仍然得到相同的消息,有没有人知道这方面的方法?

  5. centos – 闲置工作站的异常负载平均值

    我有一个新的工作站,具有不寻常的高负载平均值.机器规格是:>至强cpu>256GB的RAM>4x512GBSSD连接到LSI2108RAID控制器我从livecd安装了CentOS6.564位,配置了分区,网络,用户/组,并安装了一些软件,如开发工具和MATLAB.在启动几分钟后,工作站负载平均值的值介于0.5到0.9之间.但它没有做任何事情.因此我无法理解为什么负载平均值如此之高.你能帮我诊断一下这个问题吗?

  6. centos – Cryptsetup luks – 检查内核是否支持aes-xts-plain64密码

    我在CentOS5上使用cryptsetupluks加密加密了一堆硬盘.一切都很好,直到我将系统升级到CentOS6.现在我再也无法安装磁盘了.使用我的关键短语装载:我收到此错误:在/var/log/messages中:有关如何装载的任何想法?找到解决方案问题是驱动器使用大约512个字符长的交互式关键短语加密.出于某种原因,CentOS6中的新内核模块在由旧版本创建时无法正确读取512个字符的加密密钥.似乎只会影响内核或cryptsetup的不同版本,因为在同一系统上创建和打开时,512字符的密钥将起作用

  7. centos – 大量ssh登录尝试

    22个我今天登录CentOS盒找到以下内容这是过去3天内的11次登录尝试.WTF?请注意,这是我从我的提供商处获得的全新IP,该盒子是全新的.我还没有发布任何关于此框的内容.为什么我会进行如此大量的登录尝试?是某种IP/端口扫描?基本上有4名匪徒,其中2名来自中国,1名来自香港,1名来自Verizon.这只发生在SSH上.HTTP上没有问题.我应该将罪魁祸首子网路由吗?你们有什么建议?

  8. centos – kswap使用100%的CPU,即使有100GB的RAM也可用

    >Linux内核是否应该足够智能,只需从内存中清除旧缓存页而不是启动kswap?

  9. centos – Azure将VM从A2 / 3调整为DS2 v2

    我正在尝试调整前一段时间创建的几个AzureVM,从基本的A3和标准A3到标准的DS2v2.我似乎没有能力调整到这个大小的VM.必须从头开始重建服务器会有点痛苦.如果它有所不同我在VM中运行CentOS,每个都有一个带有应用程序和操作系统的磁盘.任何人都可以告诉我是否可以在不删除磁盘的情况下删除VM,创建新VM然后将磁盘附加到新VM?

  10. centos – 广泛使用RAM时服务器计算速度减慢

    我在非常具体的情况下遇到服务器速度下降的问题.事实是:>1)我使用计算应用WRF>2)我使用双XeonE5-2620v3和128GBRAM(NUMA架构–可能与问题有关!

返回
顶部