安装percona-server 源
https://www.percona.com/doc/percona-server/5.7/installation/yum_repo.html
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
安装依赖
yum list | grep percona
yum install epel-release -y
yum install jemalloc -y
TokuDB storage engine requires libjemalloc library 3.3.0 or greater. If the version in the distribution repository is lower than that you can use one from Percona Software Repositories or download it from somewhere else.
If the libjemalloc wasn’t installed and enabled before it will be automatically installed when installing the TokuDB storage engine package by using the apt` or yum package manager, but Percona Server instance should be restarted for libjemalloc to be loaded. This way libjemalloc will be loaded with LD_PRELOAD. You can also enable libjemalloc by specifying malloc-lib variable in the [mysqld_safe] section of the my.cnf file:
[mysqld_safe]
malloc-lib= /path/to/jemalloc
+++++++++++++++++++++++++++++++++++++++
yum install Percona-Server-tokudb-57.x86_64 -y
关闭大页内存
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
+++++++++++++++++++++++++++++++++++
TokuDB won’t be able to start if the transparent huge pages are enabled. Transparent huge pages is feature available in the newer kernel versions. You can check if the Transparent huge pages are enabled with:
$ cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
If transparent huge pages are enabled and you try to start the TokuDB engine you’ll get the following message in you error.log:
Transparent huge pages are enabled, according to /sys/kernel/mm/redhat_transparent_hugepage/enabled
Transparent huge pages are enabled, according to /sys/kernel/mm/transparent_hugepage/enabled
You can disable transparent huge pages permanently by passing transparent_hugepage=never to the kernel in your bootloader (NOTE: For this change to take an effect you’ll need to reboot your server).
You can disable the transparent huge pages by running the following command as root (NOTE: Setting this will last only until the server is rebooted):
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
++++++++++++++++++++++++++++++++++++++++
启动设置密码
systemctl start mysqld
grep password /var/log/mysqld.log
mysql -uroot -plA+dDQo:p9ks
SET PASSWORD = PASSWORD('Yy**1234');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
加载插件
ps_tokudb_admin --enable -uroot -pPassw0rd
mysql -uroot -p"Yy**1234"
INSTALL PLUGIN tokudb SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_file_map SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_fractal_tree_info SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_fractal_tree_block_map SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_trx SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_locks SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_lock_waits SONAME 'ha_tokudb.so';
INSTALL PLUGIN tokudb_background_job_status SONAME 'ha_tokudb.so';
show engines;
mysql> show engines;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| InnoDB | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| TokuDB | YES | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
SELECT @@tokudb_version;
添加zabbix用户
grant all on zabbix.* to zabbix@'localhost' identified by 'Zabbix_pass123';
创建数据库:避免下面报错
create database zabbix character set utf8 collate utf8_bin;
Zabbix 安装
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent
Zabbix 配置
[root@localhost ~]# rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-4.0.27
/usr/share/doc/zabbix-server-mysql-4.0.27/AUTHORS
/usr/share/doc/zabbix-server-mysql-4.0.27/COPYING
/usr/share/doc/zabbix-server-mysql-4.0.27/ChangeLog
/usr/share/doc/zabbix-server-mysql-4.0.27/NEWS
/usr/share/doc/zabbix-server-mysql-4.0.27/README
/usr/share/doc/zabbix-server-mysql-4.0.27/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix
cd /usr/share/doc/zabbix-server-mysql-4.0.27/
guzip create.sql.gz
注意:如果使用tokudb,需要将sql脚本中的InnoDB替换为tokudb
grep 'InnoDB' create.sql
替换数据 引擎并导入
sed -i 's#ENGINE=InnoDB#ENGINE=tokudb#g' create.sql
cat create.sql |mysql -uzabbix -p'Zabbix_pass123' zabbix
vim /etc/zabbix/zabbix_server.conf
DBPassword=Zabbix_pass123
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl enable zabbix-server zabbix-agent httpd
systemctl start zabbix-server httpd
zabbix连接数据库的时候报错:Unsupported charset or collation for tables
解决:
https://www.zabbix.com/documentation/4.0/manual/appendix/install/db_charset_coll
wget https://support.zabbix.com/secure/attachment/113858/113858_utf8_convert.sql
MariaDB [zabbix]> alter database zabbix character set utf8 collate utf8_bin;
确认是否修改成功
MariaDB [zabbix]> SELECT @@character_set_database, @@collation_database;
+--------------------------+----------------------+
| @@character_set_database | @@collation_database |
+--------------------------+----------------------+
| utf8 | utf8_bin |
+--------------------------+----------------------+
mysql -uroot -p'Yy**1234' zabbix < utf8_convert.sql
mysql -uroot -p'Yy**1234'
MariaDB [mysql]> use zabbix
MariaDB [zabbix]> set innodb_strict_mode = OFF;
Query OK, 0 rows affected (0.00 sec)
MariaDB [zabbix]> SET @ZABBIX_DATABASE = 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [zabbix]> CALL zbx_convert_utf8();
Query OK, 0 rows affected, 1 warning (1 hours 53 min 17.85 sec)
MariaDB [zabbix]> set innodb_strict_mode = ON;
Query OK, 0 rows affected (0.00 sec)
MariaDB [zabbix]> drop procedure zbx_convert_utf8;
Query OK, 0 rows affected (0.04 sec)
解决问题 可以正常连接
中文图形乱码
打开windows 中C:\Windows\Fonts 任意一个中文字体 上传
[root@localhost zabbix]# rpm -ql zabbix-web |grep fonts
/usr/share/zabbix/assets/fonts
mv SIMKAI.TTF graphfont.ttf 替换即可
创建报警媒介
图片.pnghttps://www.zabbix.com/documentation/4.0/zh/manual/appendix/macros/supported_by_location
[root@localhost alertscripts]# vim zabbix_wxchat.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
import sys
import urllib,urllib2
#需要三个变量corpid、corpsecret、agentid
agentid = 'xxxx'
corpid = 'xxx'
corpsecret = 'xxxx'
#获取tocken,存在my_token里面
gettoken_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + corpsecret
token_file = urllib2.urlopen(gettoken_url)
token_data = token_file.read().decode('utf-8')
token_json = json.loads(token_data)
my_token = token_json['access_token']
#利用获取到的tocken发送微信信息
touser=sys.argv[1] #发送给谁,多个用分号分享,例如'zhangsan|wangwu'
content=sys.argv[2] #发送的内容
post_content = {
"touser":touser,
"agentid":agentid,
"msgtype": "text",
"text":{
"content":content,
}
}
json_content = json.dumps(post_content)
url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + my_token
response = urllib2.urlopen(url,json_content)
print(response.read().decode('utf-8'))
mv zabbix_wxchat.py /usr/lib/zabbix/alertscripts/
chmod +x zabbix_wxchat.py
更新 完成
设置用户的接收级别
图片.png设置触发动作
图片.png图片.png
动作信息模板
故障{TRIGGER.STATUS},服务器:{HOSTNAME1}发生: {TRIGGER.NAME}故障!
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
恢复{TRIGGER.STATUS}, 服务器:{HOSTNAME1}: {TRIGGER.NAME}已恢复!
告警主机:{HOSTNAME1}
告警时间:{EVENT.DATE} {EVENT.TIME}
告警等级:{TRIGGER.SEVERITY}
告警信息: {TRIGGER.NAME}
告警项目:{TRIGGER.KEY1}
问题详情:{ITEM.NAME}:{ITEM.VALUE}
当前状态:{TRIGGER.STATUS}:{ITEM.VALUE1}
事件ID:{EVENT.ID}
自定义监控项
图片.png图片.png
图片.png
为了效果 调整为10s
网友评论