너무 오래 걸렸습니다.
1. MySQL MHA 구성 (Oracle Linux 7.3) -- -- 01.DB Package, MHA Package Install -- and DB Config Percona Database: www.percona.com yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm yum install Percona-Server-server-57 Percona-Server-devel-57 Percona-Server-tokudb-57 percona-toolkit percona-xtrabackup-24 jemalloc jemalloc hdparm /* HDD Write Cache Off */ hdparm -W0 /dev/sdb echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag systemctl stop mysqld systemctl disable mysqld /* DB 설정 구성 (복제 구성) */ mha-01 <--> mha-02 | +-> mha-03 +-> mha-04 vi /etc/percona-server.conf.d/mysqld.cnf delete auto.cnf after db copy [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 1024M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. log_bin=mha-bin-log server_id = 51 binlog_cache_size = 8M binlog_format = ROW max_binlog_size = 1024M expire_logs_days = 3 relay-log = mha-relay-log relay_log_purge = 0 replicate_ignore_db = mysql,sys,performance_schema,information_schema log_slave_updates = 1 # read_only = 1 thread_handling=pool-of-threads explicit_defaults_for_timestamp log_timestamps=SYSTEM # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M # user=mysql basedir=/usr datadir=/data/MYSQL tmpdir=/tmp socket=/tmp/mysql.sock port=3306 bind_address=0.0.0.0 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid # tokudb_cache_size=512m mysql.cnf [MYSQL] socket = /tmp/mysql.sock no-auto-rehash show-warnings default-character-set = utf8 prompt =\u@\h:\d\_\R:\m:\\s> pager ="less -n -i -F -X -E" /* systemctl config */ systemctl edit mysql [Service] LimitNOFILE=65535 PIDFile=/var/run/mysqld/mysqld.pid Nice=-2 Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.1" show engines; show plugins; -- -- Config Replication -- /* replication user create */ CREATE USER 'replication'@'192.168.189.%' IDENTIFIED BY 'audtlr2'; GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'replication'@'192.168.189.%' ; CHANGE MASTER TO MASTER_HOST='192.168.189.52', MASTER_USER='replication', MASTER_PASSWORD='audtlr2', MASTER_LOG_FILE='mha-bin-log.000003', MASTER_LOG_POS=154; start slave; stop slave; reset slave; -- -- 02. MHA Config -- (Service VIP 는 HAProxy 를 써서 구성 함) Project Site : https://code.google.com/p/mysql-master-ha/ /* Install Package */ yum install perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager if os = oracle-7.3 then perl-Config-Tiny download end yum install mha4mysql-manager-0.56-0.el6.noarch mha4mysql-node-0.56-0.el6.noarch mkdir /etc/mha mkdir /data/MHA touch app1.cnf mha_master.cnf -- -- ssh 구성 -- (전 서버 SSH 구성) ssh-keygen -t rsa cat id_rsa.pub > authorized_keys -- -- -- /etc/mha/app1.cnf [server default] # mysql user and password user=root password=audtlr2 ssh_user=root ping_interval=3 # working directory on the manager manager_workdir=/data/MHA # manager log file manager_log=/data/MHA/app1.log # working directory on MySQL servers remote_workdir=/data/MHA master_binlog_dir=/data/MYSQL [server1] hostname=192.168.189.51 candidate_master=1 [server2] hostname=192.168.189.52 candidate_master=1 [server3] hostname=192.168.189.53 no_master=1 [server4] hostname=192.168.189.54 no_master=1 [root@mha-03 mha]# more masterha_default.cnf [server default] # 아래 부분은 HA Proxy 에서 처리 #secondary_check_script= masterha_secondary_check -s remote_host1 -s remote_host2 #master_ip_failover_script=/script/masterha/master_ip_failover #shutdown_script= /script/masterha/power_manager #report_script= /script/masterha/send_master_failover_mail -- -- -- /* rc.local 에 등록 */ nohup masterha_manager --conf=/etc/mha/app1.cnf --global-conf=/etc/mha/masterha_default.cnf < /dev/null >> /data/MHA/mha_manager.log 2>&1 & masterha_stop --conf=/etc/mha/app1.cnf --global-conf=/etc/mha/masterha_default.cnf /* 사전 점검 */ masterha_check_status --conf=/etc/mha/app1.cnf --global-conf=/etc/mha/masterha_default.cnf masterha_check_ssh --conf=/etc/mha/app1.cnf --global-conf=/etc/mha/masterha_default.cnf masterha_check_repl --conf=/etc/mha/app1.cnf --global-conf=/etc/mha/masterha_default.cnf -- relay log 삭제 설정 -- /etc/cron.d -- # 0 5 * * * app /usr/bin/purge_relay_logs --user=root --password=audtlr2 --workdir=/data/MYSQL --disable_relay_log_purge >> /data/MHA/purge_relay_logs.log 2>&1
댓글 없음:
댓글 쓰기