trellix-enterprise / mysql-audit

AUDIT Plugin for MySQL. See wiki and readme for description. If you find the plugin useful, please star us on GitHub. We love stars and it's a great way to show your feedback.
Other
232 stars 57 forks source link

Feature Request: working for Mysql Shell and Group Replication (Innodb Cluster) #164

Open go-to-k opened 7 years ago

go-to-k commented 7 years ago

The currect behavior for audit-plugin-mysql-5.7-1.1.2-691-linux-x86_64

【Version】

Mysql Version: 5.7.18 Mysql Shell Version: 1.0.9 mysql-audit Version: audit-plugin-mysql-5.7-1.1.2-691-linux-x86_64 Linux Version: CentOS Linux release 7.3.1611 (Core) Linux Kernel Version: 3.10.0-514.6.2.el7.x86_64

【Preparation (to confirm offsets)】

[goto@test ~]$ sudo sh offset-extract.sh /usr/sbin/mysqld //offsets for: /usr/sbin/mysqld (5.7.18) {"5.7.18","f5c0ba3bfece263f5f84235f0c3717b0", 7800, 7848, 3624, 4776, 456, 360, 0, 32, 64, 160, 536, 7964, 4352, 3648, 3656, 3660, 6048, 2072, 8, 7032, 7072, 7056},

【my.cnf】

[client] port = 3306 socket=/var/lib/mysql/mysqld/mysql.sock loose-default-character-set = utf8

[mysqld] datadir = /var/lib/mysql/mysqld tmpdir = /tmp socket = /var/lib/mysql/mysqld/mysql.sock port = 3306 symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid log-timestamps = system explicit_defaults_for_timestamp = 1 log_slave_updates = ON server_id = 4177244190 relay_log_info_repository = TABLE master_info_repository = TABLE transaction_write_set_extraction = XXHASH64 binlog_format = ROW disabled_storage_engines = MyISAM,BLACKHOLE,FEDERATED,CSV,ARCHIVE report_port = 3306 binlog_checksum = NONE enforce_gtid_consistency = ON log_bin gtid_mode = ON group_replication_start_on_boot = OFF group_replication = ON

loose-group_replication_ip_whitelist = "172.20.0.0/24"

plugin-load=AUDIT=libaudit_plugin.so audit_json_file=1 audit_json_log_file=/var/log/mysql/mysql-audit.json audit_force_record_logins=ON audit_whitelist_cmds="Prepare, Close stmt, Execute" audit_header_msg=OFF

audit_json_file_bufsize

audit_json_file_retry=60 audit_sess_connect_attrs=ON audit_client_capabilities=OFF audit_socket_creds=ON

audit_offsets=7800, 7848, 3624, 4776, 456, 360, 0, 32, 64, 160, 536, 7964, 4352, 3648, 3656, 3660, 6048, 2072, 8, 7032, 7072, 7056

【Events】

do configureLocalInstance() by mysqlshell

[goto@test ~]$ mysqlsh

Welcome to MySQL Shell 1.0.9

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries. mysql-js> mysql-js> dba.configureLocalInstance(); Please provide the password for 'root@localhost:3306':

Detecting the configuration file... Found configuration file at standard location: /etc/my.cnf Do you want to modify this file? [Y|n]: Y MySQL user 'root' cannot be verified to have access to other hosts in the network.

1) Create root@% with necessary grants 2) Create account with different name 3) Continue without creating account 4) Cancel Please select an option [1]: 2 Please provide an account name (e.g: icroot@%) to have it created with the necessary privileges or leave empty and press Enter to cancel. Account Name: ic@"172.20.0.0/255.255.255.0" Password for new account: Confirm password: Validating instance...

The instance 'localhost:3306' is valid for Cluster usage You can now use it in an InnoDB Cluster.

{ "status": "ok" } mysql-js> \q Bye! [goto@test ~]$

restart mysqld for reflecting the configureLocalInstance()

[goto@test ~]$ sudo service mysqld restart Redirecting to /bin/systemctl restart mysqld.service [goto@test ~]$

do checkInstanceConfiguration() by mysqlshell

[goto@test ~]$ mysqlsh Welcome to MySQL Shell 1.0.9

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries. mysql-js> mysql-js> dba.checkInstanceConfiguration('root@localhost:3306'); Please provide the password for 'root@localhost:3306': Validating instance...

The instance 'localhost:3306' is valid for Cluster usage { "status": "ok" } mysql-js> \q Bye! [goto@test ~]$

connect to mysqld by mysqlshell, and create a cluster. But failed to create. (Lost connection to MySQL server during query. Aborted)

[goto@test ~]$ mysqlsh Welcome to MySQL Shell 1.0.9

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type '\help', '\h' or '\?' for help, type '\quit' or '\q' to exit.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries. mysql-js> mysql-js> \connect ic@172.20.0.1:3306 Creating a Session to 'ic@172.20.0.1:3306' Enter password: Classic Session successfully established. No default schema selected. mysql-js> mysql-js> var cluster = dba.createCluster('Test_Cluster'); A new InnoDB cluster will be created on instance 'ic@172.20.0.1:3306'.

Creating InnoDB cluster 'Test_Cluster' on 'ic@172.20.0.1:3306'... terminate called after throwing an instance of 'shcore::Exception' what(): Lost connection to MySQL server during query Aborted (core dumped)

【Error log (around the crash)】

02:56:13 UTC - mysqld got signal 11 ; This could be because you hit a bug. It is also possible that this binary or one of the libraries it was linked against is corrupt, improperly built, or misconfigured. This error can also be caused by malfunctioning hardware. Attempting to collect some information that could help diagnose the problem. As this is a crash and something is definitely wrong, the information collection process might fail.

key_buffer_size=8388608 read_buffer_size=131072 max_used_connections=5 max_threads=151 thread_count=8 connection_count=5 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68190 K bytes of memory Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f94cc00a380 Attempting backtrace. You can use the following information to find out where mysqld died. If you see no messages after this, something went terribly wrong... stack_bottom = 7f94f4ab3770 thread_stack 0x40000 /usr/sbin/mysqld(my_print_stacktrace+0x3b)[0xef79db] /usr/sbin/mysqld(handle_fatal_signal+0x461)[0x7af651] /lib64/libpthread.so.0(+0xf370)[0x7f952cfc0370] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0x131b1)[0x7f9517e4d1b1] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0x115e8)[0x7f9517e4b5e8] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0x12617)[0x7f9517e4c617] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0x12771)[0x7f9517e4c771] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0xebc0)[0x7f9517e48bc0] /usr/lib64/mysql/plugin/libaudit_plugin.so(+0xeec6)[0x7f9517e48ec6] /usr/sbin/mysqld(_Z18mysql_audit_notifyP3THD33mysql_event_connection_subclass_tPKci+0x1c9)[0x7b0549] /usr/sbin/mysqld(_ZN11Srv_session6attachEv+0x1bc)[0x7b359c] /usr/sbin/mysqld(_ZN11Srv_session25Session_backup_and_attachC1EPS_b+0x14e)[0x7b385e] /usr/sbin/mysqld(_ZN11Srv_session15execute_commandE19enum_server_commandPK8COM_DATAPK15charset_info_stPK22st_command_service_cbs17cs_text_or_binaryPv+0xcb)[0x7b3ccb] /usr/lib64/mysql/plugin/group_replication.so(_ZN21Sql_service_interface16execute_internalEP13Sql_resultset17cs_text_or_binaryPK15charset_info_st8COM_DATA19enum_server_command+0xa6)[0x7f94f53c6646] /usr/lib64/mysql/plugin/group_replication.so(_ZN21Sql_service_interface13execute_queryESsP13Sql_resultset17cs_text_or_binaryPK15charset_info_st+0x4b)[0x7f94f53c67db] /usr/lib64/mysql/plugin/group_replication.so(_ZN19Sql_service_command24get_server_gtid_executedERSs+0x11a)[0x7f94f53cae1a] /usr/lib64/mysql/plugin/group_replication.so(_ZNK25Plugin_gcs_events_handler21get_exchangeable_dataEv+0x1c5)[0x7f94f53a29a5] /usr/lib64/mysql/plugin/group_replication.so(_ZN16Gcs_xcom_control24xcom_receive_global_viewE9synode_noP14Gcs_xcom_nodesb+0x4b7)[0x7f94f53641b7] /usr/lib64/mysql/plugin/group_replication.so(_Z30do_cb_xcom_receive_global_view9synode_noS_P14Gcs_xcom_nodes+0x9b)[0x7f94f538b5fb] /usr/lib64/mysql/plugin/group_replication.so(_ZN24Global_view_notification10do_executeEv+0x47)[0x7f94f5395747] /usr/lib64/mysql/plugin/group_replication.so(_ZN26Parameterized_notificationILb0EEclEv+0xa)[0x7f94f539622a] /usr/lib64/mysql/plugin/group_replication.so(_ZN15Gcs_xcom_engine7processEv+0x76)[0x7f94f5395af6] /usr/lib64/mysql/plugin/group_replication.so(_Z27process_notification_threadPv+0x9)[0x7f94f5395b49] /lib64/libpthread.so.0(+0x7dc5)[0x7f952cfb8dc5] /lib64/libc.so.6(clone+0x6d)[0x7f952ba7573d]

Trying to get some variables. Some pointers may be invalid and cause the dump to abort. Query (0): Connection ID (thread ID): 133 Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains information that should help you find out what is causing the crash.

aharonrobbins commented 7 years ago

Thanks for the info and recipe to reproduce. We will investigate.

pratibhadeepti commented 6 years ago

Hi I need to build an ansible playbook for MySQL 5.7 Innodb cluster, I feel you are the right person who can help me out, please sir help me out. I'm very new to ansible.