问题描述:配置CDH 配置Mysql高可用,并实现和cdh无缝对接。
主从和keepalived配置步骤:网上很多,这里就不多赘述了!
配置常用命令:
查询mysql连接使用的是那台服务器:
show variables like "%hostname%";
service keepalived restart
service mysqld restart
service mysqld stop
ps -ef |grep keepalived
问题一:scm无法连接虚拟IP问题。
grant all on *.* to 'scm'@'%' identified by 'scm' with grant option;
flush privileges;
问题二:表无法找到!table not exits,由于主从复制没有区分表名的大小写导致。
配置myslq不区分大小写:vi /etc/my.cnf
lower_case_table_names = 1 #不区分大小写问题!
问题三:怎么配置my.cnf
vim my.cnf
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
validate_password=off
log-bin=MySQL-bin
relay-log=relay-bin
relay-log-index=relay-bin-index
server-id=2
binlog-do-db=hive
replicate-do-db=hive
binlog-do-db=oozie
replicate-do-db=oozie
binlog-do-db=hue
replicate-do-db=hue
slave-net-timeout=60
binlog-do-db=temp
replicate-do-db=temp
binlog-do-db=mysql
replicate-do-db=mysql
#replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=information_schema.%
replicate-wild-ignore-table=sys.%
replicate-wild-ignore-table=performance_schema.%
lower_case_table_names = 1
问题四:怎么配置
! Configuration File for keepalived
global_defs {
router_id mysql-ha
}
vrrp_instance VI_1 {
state BACKUP
interface ens32
virtual_router_id 202
#优先级,高优先级竞选为master
priority 90
advert_int 1
#设置为不抢占 注:这个配置只能设置在backup主机上,而且这个主机优先级要比另外一台高,另一台不要设置这个选项
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
172.17.10.155
}
}
virtual_server 172.17.10.155 3306 {
delay_loop 2
lb_algo rr
lb_kind DR
persistence_timeout 60
protocol TCP
real_server 172.17.10.153 3306 {
weight 1
notify_down /root/shutdown.sh
TCP_CHECK {
connect_port 3306
connect_timeout 3
nb_get_retry 2
delay_before_retry 1
}
}
}
cat /etc/keepalived/keepalived.conf
问题五:配置完毕后,怎么对接cdh集群呢?
修改集群的配置:
后台配置文件修改:主节点
cat /opt/cloudera-manager/cm-5.8.0/etc/cloudera-scm-server/db.properties
com.cloudera.cmf.db.type=mysql
com.cloudera.cmf.db.host=172.17.10.155#改为虚拟IP!!!
com.cloudera.cmf.db.name=temp
com.cloudera.cmf.db.user=scm
com.cloudera.cmf.db.password=scm
manager界面修改:
1)Cloudera Management Service
2)oozie
3)hive
4)hue
5)根据你的组件,其他地方如果用到了mysql的连接也修改下即可。修改配置:直接搜索:“数据库”就可以找到对应的修改项