环境:CentOS5.8 MySQL5.5.17 实验:搭建MHA高可用架构(非root用户SSH等效性配置)SSH等效性用户配置的是:concert 端口:1314 MHA配置文件 [concert@mhamanager mha]$ more /etc/masterha_default.cnf [server default] user = root password = mysql_admi
环境:CentOS5.8
MySQL5.5.17
实验:搭建MHA高可用架构(非root用户SSH等效性配置)SSH等效性用户配置的是:concert 端口:1314
MHA配置文件
[concert@mhamanager mha]$ more /etc/masterha_default.cnf
[server default]
user = root
password = mysql_admin
ssh_user = concert
ssh_port = 1314
repl_user = repl
repl_password = repl_pwd
ping_interval = 3
ping_type = select
[concert@mhamanager mha]$ more /etc/appl.cnf
[server default]
manager_workdir = /mha/appl
manager_log = /mha/appl/manager.log
remote_workdir = /mha/appl
[server1]
hostname = 192.168.66.88
master_binlog_dir = /data/lib/mysql
candidate_master = 1
[server2]
hostname = 192.168.66.89
master_binlog_dir = /data/lib/mysql
candidate_master = 1
[server3]
hostname = 192.168.66.120
no_master = 1
port = 3307
问题:配置好非root用户SSH等效性后,通过masterha_check_ssh检查没有问题
[concert@mhamanager ~]$ /usr/bin/masterha_check_ssh --conf=/etc/appl.cnf
Tue Sep 2 15:06:01 2014 - [info] Reading default configuratoins from /etc/masterha_default.cnf..
Tue Sep 2 15:06:01 2014 - [info] Reading application default configurations from /etc/appl.cnf..
Tue Sep 2 15:06:01 2014 - [info] Reading server configurations from /etc/appl.cnf..
Tue Sep 2 15:06:01 2014 - [info] Starting SSH connection tests..
Tue Sep 2 15:06:01 2014 - [debug]
Tue Sep 2 15:06:01 2014 - [debug] Connecting via SSH from concert@192.168.66.88(192.168.66.88:1314) to concert@192.168.66.89(192.168.66.89:1314)..
Tue Sep 2 15:06:01 2014 - [debug] ok.
Tue Sep 2 15:06:01 2014 - [debug] Connecting via SSH from concert@192.168.66.88(192.168.66.88:1314) to concert@192.168.66.120(192.168.66.120:1314)..
Tue Sep 2 15:06:01 2014 - [debug] ok.
Tue Sep 2 15:06:02 2014 - [debug]
Tue Sep 2 15:06:01 2014 - [debug] Connecting via SSH from concert@192.168.66.89(192.168.66.89:1314) to concert@192.168.66.88(192.168.66.88:1314)..
Tue Sep 2 15:06:01 2014 - [debug] ok.
Tue Sep 2 15:06:01 2014 - [debug] Connecting via SSH from concert@192.168.66.89(192.168.66.89:1314) to concert@192.168.66.120(192.168.66.120:1314)..
Tue Sep 2 15:06:02 2014 - [debug] ok.
Tue Sep 2 15:06:02 2014 - [debug]
Tue Sep 2 15:06:02 2014 - [debug] Connecting via SSH from concert@192.168.66.120(192.168.66.120:1314) to concert@192.168.66.88(192.168.66.88:1314)..
Tue Sep 2 15:06:02 2014 - [debug] ok.
Tue Sep 2 15:06:02 2014 - [debug] Connecting via SSH from concert@192.168.66.120(192.168.66.120:1314) to concert@192.168.66.89(192.168.66.89:1314)..
Tue Sep 2 15:06:02 2014 - [debug] ok.
Tue Sep 2 15:06:02 2014 - [info] All SSH connection tests passed successfully.
但通过masterha_check_repl检查则不通过
[concert@mhamanager ~]$ /usr/bin/masterha_check_repl --conf=/etc/appl.cnf
Tue Sep 2 17:10:08 2014 - [info] Reading default configuratoins from /etc/masterha_default.cnf..
Tue Sep 2 17:10:08 2014 - [info] Reading application default configurations from /etc/appl.cnf..
Tue Sep 2 17:10:08 2014 - [info] Reading server configurations from /etc/appl.cnf..
Tue Sep 2 17:10:08 2014 - [info] MHA::MasterMonitor version 0.55.
Tue Sep 2 17:10:08 2014 - [info] Dead Servers:
Tue Sep 2 17:10:08 2014 - [info] Alive Servers:
Tue Sep 2 17:10:08 2014 - [info] 192.168.66.88(192.168.66.88:3306)
Tue Sep 2 17:10:08 2014 - [info] 192.168.66.89(192.168.66.89:3306)
Tue Sep 2 17:10:08 2014 - [info] 192.168.66.120(192.168.66.120:3307)
Tue Sep 2 17:10:08 2014 - [info] Alive Slaves:
Tue Sep 2 17:10:08 2014 - [info] 192.168.66.89(192.168.66.89:3306) Version=5.5.17-log (oldest major version between slaves) log-bin:enabled
Tue Sep 2 17:10:08 2014 - [info] Replicating from 192.168.66.88(192.168.66.88:3306)
Tue Sep 2 17:10:08 2014 - [info] Primary candidate for the new Master (candidate_master is set)
Tue Sep 2 17:10:08 2014 - [info] 192.168.66.120(192.168.66.120:3307) Version=5.5.17-log (oldest major version between slaves) log-bin:enabled
Tue Sep 2 17:10:08 2014 - [info] Replicating from 192.168.66.88(192.168.66.88:3306)
Tue Sep 2 17:10:08 2014 - [info] Not candidate for the new Master (no_master is set)
Tue Sep 2 17:10:08 2014 - [info] Current Alive Master: 192.168.66.88(192.168.66.88:3306)
Tue Sep 2 17:10:08 2014 - [info] Checking slave configurations..
Tue Sep 2 17:10:08 2014 - [info] Checking replication filtering settings..
Tue Sep 2 17:10:08 2014 - [info] binlog_do_db= , binlog_ignore_db=
Tue Sep 2 17:10:08 2014 - [info] Replication filtering check ok.
Tue Sep 2 17:10:08 2014 - [info] Starting SSH connection tests..
Tue Sep 2 17:10:10 2014 - [error][/usr/lib/perl5/vendor_perl/MHA/MasterMonitor.pm, ln386] Error happend on checking configurations. SSH Configuration Check Failed!
at /usr/lib/perl5/vendor_perl/MHA/MasterMonitor.pm line 341
Tue Sep 2 17:10:10 2014 - [error][/usr/lib/perl5/vendor_perl/MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.
Tue Sep 2 17:10:10 2014 - [info] Got exit code 1 (Not master dead).
MySQL Replication Health is NOT OK!
解决方案:
1、增加remote_workdir(运行MySQL实例的服务器)的工作目录权限,其中会生成日志文件,将该目录拥有者设为concert
[root@master88 ~]# chown -R concert:concert /mha/
2、添加concert为MySQL同组用户,使其有读取MySQL binary/relay log文件和relay_log.info文件的权限,以及日志目录的写权限
[root@bakmaster ~]# usermod -g mysql concert
再次检查
[concert@mhamanager mha]$ /usr/bin/masterha_check_repl --conf=/etc/appl.cnf
Wed Sep 3 22:27:41 2014 - [info] Reading default configuratoins from /etc/masterha_default.cnf..
Wed Sep 3 22:27:41 2014 - [info] Reading application default configurations from /etc/appl.cnf..
Wed Sep 3 22:27:41 2014 - [info] Reading server configurations from /etc/appl.cnf..
Wed Sep 3 22:27:41 2014 - [info] MHA::MasterMonitor version 0.55.
Wed Sep 3 22:27:41 2014 - [info] Dead Servers:
Wed Sep 3 22:27:41 2014 - [info] Alive Servers:
Wed Sep 3 22:27:41 2014 - [info] 192.168.66.88(192.168.66.88:3306)
Wed Sep 3 22:27:41 2014 - [info] 192.168.66.89(192.168.66.89:3306)
Wed Sep 3 22:27:41 2014 - [info] 192.168.66.120(192.168.66.120:3307)
Wed Sep 3 22:27:41 2014 - [info] Alive Slaves:
Wed Sep 3 22:27:41 2014 - [info] 192.168.66.89(192.168.66.89:3306) Version=5.5.17-log (oldest major version between slaves) log-bin:enabled
Wed Sep 3 22:27:41 2014 - [info] Replicating from 192.168.66.88(192.168.66.88:3306)
Wed Sep 3 22:27:41 2014 - [info] Primary candidate for the new Master (candidate_master is set)
Wed Sep 3 22:27:41 2014 - [info] 192.168.66.120(192.168.66.120:3307) Version=5.5.17-log (oldest major version between slaves) log-bin:enabled
Wed Sep 3 22:27:41 2014 - [info] Replicating from 192.168.66.88(192.168.66.88:3306)
Wed Sep 3 22:27:41 2014 - [info] Not candidate for the new Master (no_master is set)
Wed Sep 3 22:27:41 2014 - [info] Current Alive Master: 192.168.66.88(192.168.66.88:3306)
Wed Sep 3 22:27:41 2014 - [info] Checking slave configurations..
Wed Sep 3 22:27:41 2014 - [info] Checking replication filtering settings..
Wed Sep 3 22:27:41 2014 - [info] binlog_do_db= , binlog_ignore_db=
Wed Sep 3 22:27:41 2014 - [info] Replication filtering check ok.
Wed Sep 3 22:27:41 2014 - [info] Starting SSH connection tests..
Wed Sep 3 22:27:42 2014 - [info] All SSH connection tests passed successfully.
Wed Sep 3 22:27:42 2014 - [info] Checking MHA Node version..
Wed Sep 3 22:27:43 2014 - [info] Version check ok.
Wed Sep 3 22:27:43 2014 - [info] Checking SSH publickey authentication settings on the current master..
Wed Sep 3 22:27:43 2014 - [info] HealthCheck: SSH to 192.168.66.88 is reachable.
Wed Sep 3 22:27:43 2014 - [info] Master MHA Node version is 0.54.
Wed Sep 3 22:27:43 2014 - [info] Checking recovery script configurations on the current master..
Wed Sep 3 22:27:43 2014 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data/lib/mysql --output_file=/mha/appl/save_binary_logs_test --manager_version=0.55 --start_file=mysql-bin.000004
Wed Sep 3 22:27:43 2014 - [info] Connecting to concert@192.168.66.88(192.168.66.88)..
Creating /mha/appl if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /data/lib/mysql, up to mysql-bin.000004
Wed Sep 3 22:27:43 2014 - [info] Master setting check done.
Wed Sep 3 22:27:43 2014 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Wed Sep 3 22:27:43 2014 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=192.168.66.89 --slave_ip=192.168.66.89 --slave_port=3306 --workdir=/mha/appl --target_version=5.5.17-log --manager_version=0.55 --relay_log_info=/data/lib/mysql/relay-log.info --relay_dir=/data/lib/mysql/ --slave_pass=xxx
Wed Sep 3 22:27:43 2014 - [info] Connecting to concert@192.168.66.89(192.168.66.89:1314)..
Checking slave recovery environment settings..
Opening /data/lib/mysql/relay-log.info ... ok.
Relay log found at /data/lib/mysql, up to mysql-relay-bin.000006
Temporary relay log file is /data/lib/mysql/mysql-relay-bin.000006
Testing mysql connection and privileges.. done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
Wed Sep 3 22:27:43 2014 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=192.168.66.120 --slave_ip=192.168.66.120 --slave_port=3307 --workdir=/mha/appl --target_version=5.5.17-log --manager_version=0.55 --relay_log_info=/data/lib/mysqlb/relay-log.info --relay_dir=/data/lib/mysqlb/ --slave_pass=xxx
Wed Sep 3 22:27:43 2014 - [info] Connecting to concert@192.168.66.120(192.168.66.120:1314)..
Checking slave recovery environment settings..
Opening /data/lib/mysqlb/relay-log.info ... ok.
Relay log found at /data/lib/mysqlb, up to mysql-relay-bin.000005
Temporary relay log file is /data/lib/mysqlb/mysql-relay-bin.000005
Testing mysql connection and privileges.. done.
Testing mysqlbinlog output.. done.
Cleaning up test file(s).. done.
Wed Sep 3 22:27:44 2014 - [info] Slaves settings check done.
Wed Sep 3 22:27:44 2014 - [info]
192.168.66.88 (current master)
+--192.168.66.89
+--192.168.66.120
Wed Sep 3 22:27:44 2014 - [info] Checking replication health on 192.168.66.89..
Wed Sep 3 22:27:44 2014 - [info] ok.
Wed Sep 3 22:27:44 2014 - [info] Checking replication health on 192.168.66.120..
Wed Sep 3 22:27:44 2014 - [info] ok.
Wed Sep 3 22:27:44 2014 - [warning] master_ip_failover_script is not defined.
Wed Sep 3 22:27:44 2014 - [warning] shutdown_script is not defined.
Wed Sep 3 22:27:44 2014 - [info] Got exit code 0 (Not master dead).
MySQL Replication Health is OK.
OK!问题解决。

데이터베이스 최적화에서 쿼리 요구 사항에 따라 인덱싱 전략을 선택해야합니다. 1. 쿼리에 여러 열이 포함되고 조건 순서가 수정되면 복합 인덱스를 사용하십시오. 2. 쿼리에 여러 열이 포함되어 있지만 조건 순서가 고정되지 않은 경우 여러 단일 열 인덱스를 사용하십시오. 복합 인덱스는 다중 열 쿼리를 최적화하는 데 적합한 반면 단일 열 인덱스는 단일 열 쿼리에 적합합니다.

MySQL 느린 쿼리를 최적화하려면 SlowQueryLog 및 Performance_Schema를 사용해야합니다. 1. SlowQueryLog 및 Set Stresholds를 사용하여 느린 쿼리를 기록합니다. 2. Performance_schema를 사용하여 쿼리 실행 세부 정보를 분석하고 성능 병목 현상을 찾고 최적화하십시오.

MySQL 및 SQL은 개발자에게 필수적인 기술입니다. 1.MySQL은 오픈 소스 관계형 데이터베이스 관리 시스템이며 SQL은 데이터베이스를 관리하고 작동하는 데 사용되는 표준 언어입니다. 2.MYSQL은 효율적인 데이터 저장 및 검색 기능을 통해 여러 스토리지 엔진을 지원하며 SQL은 간단한 문을 통해 복잡한 데이터 작업을 완료합니다. 3. 사용의 예에는 기본 쿼리 및 조건 별 필터링 및 정렬과 같은 고급 쿼리가 포함됩니다. 4. 일반적인 오류에는 구문 오류 및 성능 문제가 포함되며 SQL 문을 확인하고 설명 명령을 사용하여 최적화 할 수 있습니다. 5. 성능 최적화 기술에는 인덱스 사용, 전체 테이블 스캔 피하기, 조인 작업 최적화 및 코드 가독성 향상이 포함됩니다.

MySQL 비동기 마스터 슬레이브 복제는 Binlog를 통한 데이터 동기화를 가능하게하여 읽기 성능 및 고 가용성을 향상시킵니다. 1) 마스터 서버 레코드는 Binlog로 변경됩니다. 2) 슬레이브 서버는 I/O 스레드를 통해 Binlog를 읽습니다. 3) 서버 SQL 스레드는 데이터를 동기화하기 위해 Binlog를 적용합니다.

MySQL은 오픈 소스 관계형 데이터베이스 관리 시스템입니다. 1) 데이터베이스 및 테이블 작성 : CreateAbase 및 CreateTable 명령을 사용하십시오. 2) 기본 작업 : 삽입, 업데이트, 삭제 및 선택. 3) 고급 운영 : 가입, 하위 쿼리 및 거래 처리. 4) 디버깅 기술 : 확인, 데이터 유형 및 권한을 확인하십시오. 5) 최적화 제안 : 인덱스 사용, 선택을 피하고 거래를 사용하십시오.

MySQL의 설치 및 기본 작업에는 다음이 포함됩니다. 1. MySQL 다운로드 및 설치, 루트 사용자 비밀번호를 설정하십시오. 2. SQL 명령을 사용하여 CreateAbase 및 CreateTable과 같은 데이터베이스 및 테이블을 만듭니다. 3. CRUD 작업을 실행하고 삽입, 선택, 업데이트, 명령을 삭제합니다. 4. 성능을 최적화하고 복잡한 논리를 구현하기 위해 인덱스 및 저장 절차를 생성합니다. 이 단계를 사용하면 MySQL 데이터베이스를 처음부터 구축하고 관리 할 수 있습니다.

innodbbufferpool은 데이터와 색인 페이지를 메모리에로드하여 MySQL 데이터베이스의 성능을 향상시킵니다. 1) 데이터 페이지가 버퍼 풀에로드되어 디스크 I/O를 줄입니다. 2) 더러운 페이지는 정기적으로 디스크로 표시되고 새로 고침됩니다. 3) LRU 알고리즘 관리 데이터 페이지 제거. 4) 읽기 메커니즘은 가능한 데이터 페이지를 미리로드합니다.

MySQL은 설치가 간단하고 강력하며 데이터를 쉽게 관리하기 쉽기 때문에 초보자에게 적합합니다. 1. 다양한 운영 체제에 적합한 간단한 설치 및 구성. 2. 데이터베이스 및 테이블 작성, 삽입, 쿼리, 업데이트 및 삭제와 같은 기본 작업을 지원합니다. 3. 조인 작업 및 하위 쿼리와 같은 고급 기능을 제공합니다. 4. 인덱싱, 쿼리 최적화 및 테이블 파티셔닝을 통해 성능을 향상시킬 수 있습니다. 5. 데이터 보안 및 일관성을 보장하기위한 지원 백업, 복구 및 보안 조치.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

WebStorm Mac 버전
유용한 JavaScript 개발 도구

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기
