Новая версия вышла и уже обкаталась как и сообществом, так и мной в песочнице - пришла пора и нам переходить на новые технологии.
Подготовка:
Ну тут все просто - делайте бекапы, господа! Как эо делается - уже было написано, Например тут
Реализация:
Останавливаем zabbix
Код: Выделить всё
stat# /usr/local/etc/rc.d/zabbix_server stop
Stopping zabbix_server.
Waiting for PIDS: 55283 55285 55286 55287 55288 55289 55290 55291 55292 55293 55294 55295 55296 55297 55298 55299 55300 55301 55302 55303 55304 55305 55306 55307 55308 55309 55310 55311 55312 55313 55314 55315 55316 55317 55318 55319 55320 55321 55322 55323 55324 55325 55326 55327 55328 55329 55330 55331 55332 55333 55334 55335 55336 55337 55338 55339 55340 55341 55342 55343 55344 55345 55346 55347 55348 55349 55350 55351 55352 55353 55354 55355 55356 55357 55358 55359 55360 55361 55362 55363 55364 55365 55366 55367 55368 55369 55370 55371 55372 55373 55374 55375 55376 55377 55378 55379 55380 55381 55382 55383 55384 55385 55386 55387 55388 55389 55390 55391 55392 55393 55394 55395 55396 55397 55398 55399 55400 55401 55402 55403 55404 55405 55406 55407 55408 55409 55410 55411 55412 55413 55414, 55283.
stat# /usr/local/etc/rc.d/zabbix_agentd stop
Stopping zabbix_agentd.
Waiting for PIDS: 38845 38846 38847 38848 38849 38850.
stat#
Код: Выделить всё
stat# mysqladmin -uroot -p create zabbix2
Enter password:
stat#
Код: Выделить всё
stat# mysqldump -uroot -p -B "zabbix" --no-data | grep -v 'CREATE[[:blank:]]DATABASE\|USE\|--' | mysql -uroot -p zabbix2
Enter password: Enter password:
stat#
Код: Выделить всё
stat# mysqldump -uroot -p -B "zabbix" --single-transaction --no-create-info --no-create-db --ignore-table="zabbix.acknowledges" --ignore-table="zabbix.alerts" --ignore-table="zabbix.auditlog" --ignore-table="zabbix.auditlog_details" --ignore-table="zabbix.escalations" --ignore-table="zabbix.events" --ignore-table="zabbix.history" --ignore-table="zabbix.history_log" --ignore-table="zabbix.history_str" --ignore-table="zabbix.history_str_sync" --ignore-table="zabbix.history_sync" --ignore-table="zabbix.history_text" --ignore-table="zabbix.history_uint" --ignore-table="zabbix.history_uint_sync" --ignore-table="zabbix.trends" --ignore-table="zabbix.trends_uint" | grep -v 'CREATE[[:blank:]]DATABASE\|USE\|--\|DROP' | mysql -uroot -p zabbix2
Enter password: Enter password:
stat#
Код: Выделить всё
stat# mysql -uroot -p zabbix2
Enter password:
mysql> drop table zabbix2.tmp_nextids; create table zabbix2.tmp_nextids ( `field_name` varchar(255) NOT NULL, `id` bigint(20) unsigned NOT NULL );
ERROR 1051 (42S02): Unknown table 'tmp_nextids'
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO zabbix2.tmp_nextids SELECT 'eventid', max(eventid)+1 FROM `events` ; INSERT INTO zabbix2.tmp_nextids SELECT 'acknowledgeid', max(acknowledgeid)+1 FROM `acknowledges`; INSERT INTO zabbix2.tmp_nextids SELECT 'alertid', max(alertid)+1 FROM `alerts`; INSERT INTO zabbix2.tmp_nextids SELECT 'auditid', max(auditid)+1 FROM `auditlog`; INSERT INTO zabbix2.tmp_nextids SELECT 'auditdetailid', max(auditdetailid)+1 FROM `auditlog_details`; INSERT INTO zabbix2.tmp_nextids SELECT 'escalationid', max(escalationid)+1 FROM `escalations`; -- NEW DATABASE use zabbix2 -- get one eventid for constraints SELECT id into @eventid FROM tmp_nextids where field_name='eventid' limit 1; -- get first userid for constraints SELECT userid into @userid FROM users order by userid asc limit 1; -- get first media for constraints SELECT mediatypeid into @mediatypeid FROM media_type order by mediatypeid asc limit 1; -- get first action for constraints SELECT actionid into @actionid FROM actions order by actionid asc limit 1; -- get one auditlog for constraints SELECT id into @auditid FROM tmp_nextids where field_name='auditid' limit 1; -- Create Fake data INSERT INTO `events` (eventid) SELECT id FROM tmp_nextids where field_name='eventid' ; INSERT INTO `acknowledges` (acknowledgeid,eventid,userid, message) SELECT id, @eventid, @userid, 'Fake ack for 1.8 => 2.0 Migration' FROM tmp_nextids where field_name='acknowledgeid' ;
Query OK, 1 row affected, 1 warning (0.01 sec)
Records: 1 Duplicates: 0 Warnings: 1
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
mysql> INSERT INTO `alerts` ( alertid, actionid, eventid, userid, mediatypeid, message) SELECT id, @actionid, @eventid, @userid, @mediatypeid, 'Fake alert for 1.8 => 2.0 Migration' FROM tmp_nextids where field_name='alertid' ;
Query OK, 1 row affected, 4 warnings (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 4
mysql> INSERT INTO `auditlog` ( auditid, userid, details) SELECT id, @userid, 'Faked auditlogs for 1.8 => 2.0 Migration' FROM tmp_nextids where field_name='auditid' ;
Query OK, 1 row affected, 1 warning (0.02 sec)
Records: 1 Duplicates: 0 Warnings: 1
mysql> INSERT INTO `auditlog_details` ( auditdetailid, auditid, oldvalue, newvalue) SELECT id, @auditid, '', 'Faked audit for 1.8 => 2.0 Migration' FROM tmp_nextids where field_name='auditdetailid' ;
Query OK, 1 row affected, 1 warning (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 1
mysql> where field_name='auditdetailid' ; SELECT id, @actionid FROM tmp_nextids where field_name='escalationid';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where field_name='auditdetailid'' at line 1
+----+-----------+
| id | @actionid |
+----+-----------+
| 0 | NULL |
+----+-----------+
1 row in set (0.00 sec)
mysql> exit