您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > Ubuntu Server最佳方案19
第19章负载均衡、高可用的MySQL集群19.2管理节点(MGM)的安装及配置19.2.1安装MySQL$sudoapt-getupdateinstallmysql-server19.2.2配置ndb_mgmd.cnf$sudonano/etc/mysql/ndb_mgmd.cnf[NDBDDEFAULT]NoOfReplicas=2[MYSQLDDEFAULT][NDB_MGMDDEFAULT][TCPDEFAULT][NDB_MGMD]#管理节点HostName=192.168.1.10#本机(管理节点)的IP地址[NDBD]#存储节点1HostName=192.168.1.13DataDir=/var/lib/mysql-clusterBackupDataDir=/var/lib/mysql-cluster/backup[NDBD]#存储节点2HostName=192.168.1.14DataDir=/var/lib/mysql-clusterBackupDataDir=/var/lib/mysql-cluster/backup#有几个存储节点,就写几行[MYSQLD][MYSQLD][MYSQLD]$sudo/etc/init.d/mysql-ndb-mgmstart最佳方案29219.3存储节点(NDB)的安装及配置19.3.1安装MySQL$sudoapt-getupdateinstallmysql-server$sudo/etc/init.d/mysqlstop19.3.2配置my.cnf$sudomv/etc/mysql/my.cnf/etc/mysql/my.cnf-back$sudonano/etc/mysql/my.cnf[client]socket=/var/run/mysqld/mysqld.sockport=3306[mysqld]ndbclusterndb-connectstring=192.168.1.10#管理节点的IP地址default-storage-engine=NDBCLUSTER[mysql_cluster]ndb-connectstring=192.168.1.10#管理节点的IP地址$sudo/etc/init.d/mysql-ndbstart-initial*StartingMySQLNDBDataNodendbderror=23502009-02-1522:20:55[ndbd]INFO--Errorhandlerrestartingsystem2009-02-1522:20:55[ndbd]INFO--Errorhandlershutdowncompleted-exitingsphase=0exit=-1$psaux|grepndb|grep-vgrep第19章负载均衡、高可用的MySQL集群293$sudo/etc/init.d/mysqlstart19.4阶段测试19.4.1集群连接状态测试$ndb_mgm--NDBCluster--ManagementClient--ndb_mgmndb_mgmshowConnectedtoManagementServerat:localhost:1186ClusterConfiguration---------------------[ndbd(NDB)]2node(s)id=2@192.168.1.13(Version:5.0.51,Nodegroup:0)id=3@192.168.1.14(Version:5.0.51,Nodegroup:0,Master)[ndb_mgmd(MGM)]1node(s)id=1@192.168.1.10(Version:5.0.51)[mysqld(API)]2node(s)id=4@192.168.1.13(Version:5.0.51)id=5@192.168.1.14(Version:5.0.51)ndb_mgmquit19.4.2测试1.数据同步测试$mysql-uroot-pmysqlCREATEDATABASEclustertest;QueryOK,1rowaffected(0.24sec)mysqlUSEclustertest;最佳方案294DatabasechangedmysqlCREATETABLEtesttable(CountINT)ENGINE=NDBCLUSTER;QueryOK,0rowsaffected(0.24sec)mysqlINSERTINTOtesttable()VALUES(1);QueryOK,1rowaffected(0.00sec)mysqlSELECT*FROMtesttable;+-------+|Count|+-------+|1|+-------+1rowinset(0.00sec)$mysql-uroot-pmysqlCREATEDATABASEclustertest;QueryOK,1rowaffected(0.24sec)mysqlUSEclustertest;ReadingtableinformationforcompletionoftableandcolumnnamesYoucanturnoffthisfeaturetogetaquickerstartupwith-ADatabasechangedmysqlSELECT*FROMtesttable;+-------+|Count|+-------+|1|+-------+1rowinset(0.03sec)mysqlINSERTINTOtesttable()VALUES(2);QueryOK,1rowaffected(0.23sec)mysqlquitByemysqlSELECT*FROMtesttable;第19章负载均衡、高可用的MySQL集群295+-------+|Count|+-------+|2||1|+-------+2rowsinset(0.00sec)mysqlquitBye最佳方案2962.故障模拟测试$sudo/etc/init.d/mysql-ndbstop$ndb_mgm--NDBCluster--ManagementClient--ndb_mgmshowConnectedtoManagementServerat:localhost:1186ClusterConfiguration---------------------[ndbd(NDB)]2node(s)id=2(notconnected,acceptingconnectfrom192.168.1.13)id=3@192.168.1.14(Version:5.0.51,Nodegroup:0,Master)[ndb_mgmd(MGM)]1node(s)id=1@192.168.1.10(Version:5.0.51)[mysqld(API)]2node(s)id=4@192.168.1.13(Version:5.0.51)id=5@192.168.1.14(Version:5.0.51)ndb_mgmquit$mysql-uroot-pmysqlUSEclustertest;ReadingtableinformationforcompletionoftableandcolumnnamesYoucanturnoffthisfeaturetogetaquickerstartupwith-ADatabasechangedmysqlSELECT*FROMtesttable;+-------+|Count|+-------+|2||1|+-------+2rowinset(0.03sec)mysqlINSERTINTOtesttable()VALUES(3);QueryOK,1rowaffected(0.89sec)第19章负载均衡、高可用的MySQL集群297mysqlSELECT*FROMtesttable;+-------+|Count|+-------+|1||2||3|+-------+3rowsinset(0.00sec)mysqlquitBye$sudo/etc/init.d/mysql-ndbstart$mysql-uroot-pmysqlUSEclustertest;ReadingtableinformationforcompletionoftableandcolumnnamesYoucanturnoffthisfeaturetogetaquickerstartupwith-ADatabasechangedmysqlSELECT*FROMtesttable;+-------+|Count|+-------+|2||3||1|+-------+3rowsinset(0.00sec)mysqlquitBye19.5实现负载均衡19.5.2让内核支持IPVS$sudomodprobeip_vs_dh$sudomodprobeip_vs_ftp$sudomodprobeip_vs$sudomodprobeip_vs_lblc$sudomodprobeip_vs_lblcr$sudomodprobeip_vs_lc$sudomodprobeip_vs_nq最佳方案298$sudomodprobeip_vs_rr$sudomodprobeip_vs_sed$sudomodprobeip_vs_sh$sudomodprobeip_vs_wlc$sudomodprobeip_vs_wrr$sudonano/etc/modulesip_vs_dhip_vs_ftpip_vsip_vs_lblcip_vs_lblcrip_vs_lcip_vs_nqip_vs_rrip_vs_sedip_vs_ship_vs_wlcip_vs_wrr$sudonano/etc/sysctl.confnet.ipv4.ip_forward=1$sudosysctl-p19.5.3安装heartbeat、ldirectord等软件下面我们来安装heartbeat、ldirectord,以及要用到的其他软件。在mysql-lb1.mytest.com和mysql-lb2.mytest.com上,执行下面的命令:$sudoapt-getinstallheartbeatldirectord$sudoapt-getinstalllibdbi-perllibdbd-mysql-perllibmysqlclient15-dev19.5.4配置heartbeat$sudonano/etc/hosts127.0.0.1localhost192.168.1.11mysql-lb1.mytest.commysql-lb1192.168.1.12mysql-lb2.mytest.commysql-lb2第19章负载均衡、高可用的MySQL集群299$sudonano/etc/ha.d/ha.cflogfacilitylocal0bcasteth0mcasteth0225.0.0.169410auto_failbackoffnodemysql-lb1nodemysql-lb2respawnhacluster/usr/lib/heartbeat/ipfailapiauthipfailgid=haclientuid=hacluster$suodnano/etc/ha.d/haresourcesmysql-lb1\ldirectord::ldirectord.cf\LVSSyncDaemonSwap::master\IPaddr2::192.168.1.15/24/eth0/192.168.1.255$sudonano/etc/ha.d/authkeysauth33md5A46fsdgCH$sudochmod600/etc/ha.d/authkeys19.5.5配置ldirectord$sudonan
本文标题:Ubuntu Server最佳方案19
链接地址:https://www.777doc.com/doc-4353480 .html