zabbix-server迁移

因为原有zabbix-server宿主机故障,现将zabbix进行迁移
 
 
一、搭建percona数据库
 
环境介绍: centos7 m5d.4xlarge 16c64g 300ssd mysql版本: Percona-Server-5.7.30-33 mysql-5.7.30
 
1.1、安装依赖的库:
yum install -y gcc-c++ ncurses-devel perl-Data-Dumperpython-devel openssl openssl-devel cmake
1.2、安装boost,mysql5.7的编译需指定boost,只能是1.59.0
wget http://nchc.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz mkdir /usr/local/boost cp boost_1_59_0.tar.gz /usr/local/boost/
安装zlib:
wget https://zlib.net/zlib-1.2.11.tar.gz tar -xf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure --prefix=/usr/local/zlib make && make install
安装jemalloc:内存管理优化
wget https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2 tar -xf jemalloc-5.2.1.tar.bz2 cd jemalloc-5.2.1 ./configure && make && make install echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf ldconfig
编译安装percona
wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.30-33/source/tarball/percona-server-5.7.30-33.tar.gz tar xf percona-server-5.7.30-33.tar.gz cd percona-server-5.7.30-33
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/percona-5.7.30 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DMYSQL_DATADIR=/data/percona/3306/data/ \ -DSYSCONFDIR=/etc \ -DMYSQL_TCP_PORT=3306 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_DEBUG=0 \ -DDEFAULT_CHARSET=utf8mb4 \ -DDEFAULT_COLLATION=utf8mb4_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DMYSQL_MAINTAINER_MODE=0 \ -DWITH_EDITLINE=bundled \ -DWITH_SSL=system \ -DWITH_ZLIB:STRING=bundled \ -DZLIB_LIBRARY:FILEPATH=/usr/local/zlib/lib/ \ -DZLIB_INCLUDE_DIR:PATH=/usr/local/zlib/include/ \ -DCMAKE_EXE_LINKER_FLAGS="-ljemalloc" \ -DENABLE_DOWNLOADS=1 \ -DWITH_BOOST=/usr/local/boost
 
 
make -j 12 && make install
 
yum 方式安装
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm yum install Percona-Server-server-57 Percona-Server-tokudb-57
 
添加主配置文件 my.cnf
 
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
[mysql]
no-auto-rehash
 
[mysqld]
auto_increment_increment = 1
auto_increment_offset =1
autocommit = ON
back_log = 2000
basedir = /usr/local/mysql/percona-5.7.30
bind_address = 0.0.0.0
binlog_error_action = ABORT_SERVER
binlog_format = ROW
binlog_rows_query_log_events = ON
#在binlog格式为row的模式下,也可通过SHOW BINLOG EVENTS in 'binlog.000001';查看完整的sql语句
bulk_insert_buffer_size = 8388608
 
#read_only=1
 
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
connect_timeout = 10
datadir = /data01/percona/3306/data/
default_authentication_plugin = mysql_native_password
default_password_lifetime = 0
default_storage_engine = InnoDB
default_tmp_storage_engine = InnoDB
disconnect_on_expired_password = ON
#gtid_mode = ON
#enforce_gtid_consistency = ON
eq_range_index_dive_limit = 200
event_scheduler = ON
expand_fast_index_creation = OFF
expire_logs_days = 7
explicit_defaults_for_timestamp = 1
general_log = OFF
general_log_file = /var/log/mysql/mysql_general_log.log
 
skip_ssl
 
 
 
innodb_autoinc_lock_mode = 1
innodb_buffer_pool_instances = 8
innodb_buffer_pool_size = 8053063680
innodb_cleaner_lsn_age_factor = high_checkpoint
innodb_corrupt_table_action = assert
innodb_data_file_path = ibdata1:256M:autoextend
innodb_empty_free_list_algorithm = backoff
innodb_fast_shutdown = 1
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_file_per_table = ON
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
innodb_io_capacity = 2000
innodb_io_capacity_max = 4000
innodb_lock_wait_timeout = 20
innodb_log_buffer_size = 8388608
innodb_log_file_size = 536870912
innodb_log_files_in_group = 2
innodb_max_bitmap_file_size = 104857600
innodb_max_changed_pages = 1000000
innodb_max_dirty_pages_pct = 50.000000
innodb_max_dirty_pages_pct_lwm = 0.000000
innodb_max_undo_log_size = 1073741824
 
 
innodb_open_files = 102400
innodb_purge_threads = 4
innodb_read_io_threads = 8
innodb_rollback_on_timeout = OFF
innodb_show_locks_held = 10
innodb_stats_on_metadata = OFF
innodb_temp_data_file_path = ibtmp1:12M:autoextend
innodb_thread_concurrency = 20
innodb_thread_sleep_delay = 0
innodb_use_global_flush_log_at_trx_commit = ON
innodb_write_io_threads = 8
interactive_timeout = 28800
internal_tmp_disk_storage_engine = InnoDB
join_buffer_size = 262144
key_buffer_size = 33554432
kill_idle_transaction = 0
lock_wait_timeout = 86400
 
log_error = /var/log/mysql/mysql.err
log_output = FILE
log_timestamps = SYSTEM
log_error_verbosity = 3
#1 错误信息;2 错误信息和告警信息; 3:错误信息、告警信息和通知信息
long_query_time = 5.000000
lower_case_table_names = 1
 
 
max_allowed_packet = 1024M
max_connect_errors = 1000000
max_connections = 2000
max_heap_table_size = 1024M
max_relay_log_size = 0
max_seeks_for_key = 18446744073709551615
max_write_lock_count = 18446744073709551615
myisam_recover_options = OFF
myisam_sort_buffer_size = 8388608
net_buffer_length = 8192
net_read_timeout = 30
net_write_timeout = 60
open_files_limit = 1000000
performance_schema = OFF
 
pid_file = /data01/percona/3306/data/percona.pid
port = 3306
query_alloc_block_size = 8192
query_cache_limit = 1048576
query_cache_size = 0
query_cache_type = OFF
query_prealloc_size = 8192
read_buffer_size = 262144
read_rnd_buffer_size = 524288
 
 
server_id = 14
 
skip_name_resolve = ON
skip_networking = OFF
slave_max_allowed_packet = 1073741824
slave_net_timeout = 60
 
 
 
slow_query_log_always_write_time = 10.000000
slow_query_log_file = /var/log/mysql/slow.log
socket = /var/lib/mysql/mysql.sock
sort_buffer_size = 524288
sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO
 
 
 
sync_binlog = 0
table_definition_cache = 464
table_open_cache = 128
table_open_cache_instances = 16
thread_cache_size = 50
thread_pool_idle_timeout = 60
thread_pool_max_threads = 100000
thread_pool_oversubscribe = 3
thread_pool_size = 48
thread_stack = 262144
tmpdir = /data01/percona/3306/tmp
wait_timeout = 28800
 
[mysqldump]
quick
max_allowed_packet = 1024M
 
 
==========================================
初始化配置Percona-server
mkdir -p /data/percona/3306/data/ /var/lib/mysql /var/log/mysql /data/percona/3306/binlog /data/percona/3306/tmp /usr/local/mysql chown -R mysql.mysql /usr/local/mysql/ /data/percona/3306/data/ /var/lib/mysql /var/log/mysql /data/percona/3306/binlog /data/percona/3306/tmp echo 'export PATH=$PATH:/usr/local/mysql/percona-5.7.30/bin' >> /etc/profile source /etc/profile mysqld --initialize --user=mysql --basedir=/usr/local/mysql/percona-5.7.30 --datadir=/data/percona/3306/data (初始化时注意屏幕输出的信息,里面随机生成了一个root密码) 2020-08-01T15:16:00.997051Z 1 [Note] A temporary password is generated for root@localhost: :uJBgppPk8>G
配置启动文件
cp /usr/local/mysql/percona-5.7.30/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' /usr/local/mysql/percona-5.7.30/bin/mysqld_safe
echo "/usr/local/mysql/percona-5.7.30/lib" >> /etc/ld.so.conf
/etc/init.d/mysqld start
mysql -uroot -p':uJBgppPk8>G' mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
mysql> flush privileges;
 
添加 TokuDB 存储引擎 Transparent huge pages
echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
Enabling the TokuDB Storage Engine Manually
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';
mysql> SHOW ENGINES; ... | TokuDB | YES | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology | YES ˓→| YES | YES | ...
 
二、安装zabbix-server
 
1、安装repos源
[root@cndh1321-6-14 yum.repos.d]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-deprecated]
name=Zabbix Official Repository deprecated - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/deprecated
enabled=0
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
 
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=0
2、安装zabbix-server
yum install -y zabbix-server
3、安装php及相关依赖
yum -y install php-devel php-fpm php-mbstring php-xml php-pdo php-mysql php-bcmath php php-gd php-common php-cli openldap-devel
PHP-ldap
 
4、安装httpd
yum install -y  pcre-devel pcre libxml2-devel libpng libpng-devel  freetype-devel fontconfig-devel  jpeg-devel   libjpeg-devel  libXpm-devel libvpx-devel libtiff-devel gettext-devel libgcrypt-devel httpd
 
 
5、拷贝文件到新主机
zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
/etc/httpd/
 
 
6、将原来的数据库进行备份 恢复到新的数据库中
 
自此zabbix-server恢复完成,所有的数据不会丢失

posted @ 2020-08-19 14:26  巴黎斜塔  阅读(735)  评论(0编辑  收藏  举报