内核:2.6.9-78.0.17.ELsmp 硬件:DELL 2950, 146G 15K RPM SAS * 6(raid 1+0), 8G Ram
IP | 描述 |
192.168.0.2 | ndb mgm node |
192.168.0.3 | data node1, sql node 1, LVS DR Server |
192.168.0.4 | data node2, sql node 2 |
192.168.0.5 | data node3, sql node 3 |
192.168.0.6 | data node4, sql node 4 |
192.168.0.7 | sql node 5 |
192.168.0.8 | sql node 6 |
192.168.0.9 | sql node 7 |
192.168.0.10 | sql node 8 |
[[email protected] ~]# rpm -ivhU ~/kernel-2.6.9-78.0.17.EL.src.rpm [[email protected] ~]# cd /usr/src/redhat/SPECS [[email protected] ~]# rpmbuild -bp kernel-2.6.spec #解开源码包,打上各种pache [[email protected] ~]# rpm -ivhU ~/ipvsadm-1.24-5.src.rpm #安装ipvsadm的源码包 [[email protected] SPECS]# ls ipvsadm.spec kernel-2.6.spec #需要做一下链接,编译ipvsadm时用得着 [[email protected] SPECS]# ln -s /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9 /usr/src/linux [[email protected] SPECS]# rpm -bb ipvsadm.spec #编译出ipvsadm的rpm包 [[email protected] SPECS]# ls -l /usr/src/redhat/RPMS/x86_64/ total 36 -rw-r--r-- 1 root root 30941 May 4 18:06 ipvsadm-1.24-5.x86_64.rpm -rw-r--r-- 1 root root 2968 May 4 18:06 ipvsadm-debuginfo-1.24-5.x86_64.rpm [[email protected] ~]# rpm -ivhU /usr/src/redhat/RPMS/x86_64/ipvsadm-1.24-5.x86_64.rpm
[[email protected] ~]# /sbin/modprobe ip_vs [[email protected] ~]# lsmod | grep ip_vs ip_vs 103169 3 ip_vs_rr
[[email protected] ~]# cat /etc/sysconfig/ipvsadm -C -A -t lvs_vip:mysql -s rr -a -t lvs_vip:mysql -r ndb_data_node_1:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_data_node_2:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_data_node_3:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_data_node_4:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_sql_node_1:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_sql_node_2:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_sql_node_3:mysql -g -w 1 -a -t lvs_vip:mysql -r ndb_sql_node_4:mysql -g -w 1
[[email protected] ~]# echo 1 > /proc/sys/net/ipv4/ip_forward #修改内核,打开转发 [[email protected] ~]# /sbin/ifconfig eth0:0 192.168.0.11 netmask 255.255.255.0 #绑定vip [[email protected] ~]# /etc/init.d/ipvsadm start #启动ipvsadm [[email protected] ~]# ipvsadm -L #查看列表 ipvsadm -L IP Virtual Server version 1.2.0 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP lvs_vip:mysql rr -> gs_ndb_sql_node_1:mysql Route 1 0 0 -> gs_ndb_sql_node_2:mysql Route 1 0 0 -> gs_ndb_sql_node_3:mysql Route 1 0 0 -> gs_ndb_sql_node_4:mysql Route 1 0 0 -> gs_ndb_data_node_1:mysql Route 1 0 0 -> gs_ndb_data_node_2:mysql Route 1 0 0 -> gs_ndb_data_node_3:mysql Route 1 0 0 -> gs_ndb_data_node_4:mysql Route 1 0 0 [[email protected] ~]# lsmod | ip_vs #查看已加载模块 lsmod | grep ip_vs ip_vs_rr 3649 1 ip_vs 103169 3 ip_vs_rr
[[email protected] ~]# /sbin/ifconfig lo:0 192.168.0.11 netmask 255.255.255.255 broadcast 192.168.0.11 #设定noarp [[email protected] ~]# echo '2' > /proc/sys/net/ipv4/conf/lo/arp_announce;echo '1' > /proc/sys/net/ipv4/conf/lo/arp_ignore;echo '2' > /proc/sys/net/ipv4/conf/all/arp_announce;echo '1' > /proc/sys/net/ipv4/conf/all/arp_ignore
[[email protected] ~]# cat /home/mysql/config.ini [TCP DEFAULT] SendBufferMemory=2M ReceiveBufferMemory=2M [NDB_MGMD DEFAULT] PortNumber=1186 Datadir=/home/mysql/ [NDB_MGMD] id=1 Datadir=/home/mysql/ Hostname=192.168.0.2 [NDBD DEFAULT] NoOfReplicas=2 Datadir=/home/mysql/ DataMemory=2048M IndexMemory=1024M LockPagesInMainMemory=1 MaxNoOfConcurrentOperations=100000 StringMemory=25 MaxNoOfTables=4096 MaxNoOfOrderedIndexes=2048 MaxNoOfUniqueHashIndexes=512 MaxNoOfAttributes=24576 DiskCheckpointSpeedInRestart=100M FragmentLogFileSize=256M InitFragmentLogFiles=FULL NoOfFragmentLogFiles=6 RedoBuffer=32M TimeBetweenLocalCheckpoints=20 TimeBetweenGlobalCheckpoints=1000 TimeBetweenEpochs=100 MemReportFrequency=30 BackupReportFrequency=10 ### Params for setting logging LogLevelStartup=15 LogLevelShutdown=15 LogLevelCheckpoint=8 LogLevelNodeRestart=15 ### Params for increasing Disk throughput BackupMaxWriteSize=1M BackupDataBufferSize=16M BackupLogBufferSize=4M BackupMemory=20M #Reports indicates that odirect=1 can cause io errors (os err code 5) on some systems. You must test. #ODirect=1 ### Watchdog TimeBetweenWatchdogCheckInitial=30000 ### TransactionInactiveTimeout - should be enabled in Production #TransactionInactiveTimeout=30000 ### CGE 6.3 - REALTIME EXTENSIONS #RealTimeScheduler=1 #SchedulerExecutionTimer=80 #SchedulerSpinTimer=40 ### DISK DATA #SharedGlobalMemory=384M #read my blog how to set this: #DiskPageBufferMemory=3072M ### Multithreading MaxNoOfExecutionThreads=8 [NDBD] id=2 Datadir=/home/mysql/ Hostname=192.168.221.3 #LockExecuteThreadToCPU=X #LockMaintThreadsToCPU=Y [NDBD] id=3 Datadir=/home/mysql/ Hostname=192.168.0.4 #LockExecuteThreadToCPU=X #LockMaintThreadsToCPU=Y [NDBD] id=4 Datadir=/home/mysql/ Hostname=192.168.0.5 #LockExecuteThreadToCPU=X #LockMaintThreadsToCPU=Y [NDBD] id=5 Datadir=/home/mysql/ Hostname=192.168.0.6 #LockExecuteThreadToCPU=X #LockMaintThreadsToCPU=Y [MYSQLD] id=6 Hostname=192.168.0.3 [MYSQLD] id=7 Hostname=192.168.0.4 [MYSQLD] id=8 Hostname=192.168.0.5 [MYSQLD] id=9 Hostname=192.168.0.6 [MYSQLD] id=10 Hostname=192.168.0.7 [MYSQLD] id=11 Hostname=192.168.0.8 [MYSQLD] id=12 Hostname=192.168.0.9 [MYSQLD] id=13 Hostname=192.168.0.10
[[email protected] ~]# /usr/sbin/ndb_mgmd -f /home/mysql/config.ini --configdir=/home/mysql/
[[email protected] ~]# /usr/sbin/ndb_mgmd -f /home/mysql/config.ini --configdir=/home/mysql/ --reload
[[email protected] ~]# /usr/sbin/ndbd --initial
[[email protected] ~]# cat /etc/my.cnf #my.cnf [mysql_cluster] ndb-connectstring="192.168.0.2:1186" [MYSQLD] ...... ndb-cluster-connection-pool=1 ndbcluster ndb-connectstring="192.168.0.2:1186" ndb-force-send=1 ndb-use-exact-count=0 ndb-extra-logging=1 ndb-autoincrement-prefetch-sz=256 engine-condition-pushdown=1 ...... [[email protected] ~]# /etc/init.d/mysql start [[email protected] ~]# mysqladmin pr +------+-------------+-----------+----+---------+------+-----------------------------------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------+-------------+-----------+----+---------+------+-----------------------------------+------------------+ | 1 | system user | | | Daemon | 0 | Waiting for event from ndbcluster | | | 1579 | root | localhost | | Query | 0 | | show processlist | +------+-------------+-----------+----+---------+------+-----------------------------------+------------------+
[[email protected] ~]# ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 4 node(s) id=2 @192.168.0.3 (mysql-5.1.32 ndb-7.0.5, Nodegroup: 0, Master) id=3 @192.168.0.4 (mysql-5.1.32 ndb-7.0.5, Nodegroup: 0) id=4 @192.168.0.5 (mysql-5.1.32 ndb-7.0.5, Nodegroup: 1) id=5 @192.168.0.6 (mysql-5.1.32 ndb-7.0.5, Nodegroup: 1) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.2 (mysql-5.1.32 ndb-7.0.5) [mysqld(API)] 10 node(s) id=6 @192.168.0.3 (mysql-5.1.32 ndb-7.0.5) id=7 @192.168.0.4 (mysql-5.1.32 ndb-7.0.5) id=8 @192.168.0.5 (mysql-5.1.32 ndb-7.0.5) id=9 @192.168.0.6 (mysql-5.1.32 ndb-7.0.5) id=10 @192.168.0.7 (mysql-5.1.32 ndb-7.0.5) id=13 @192.168.0.8 (mysql-5.1.32 ndb-7.0.5) id=14 @192.168.0.9 (mysql-5.1.32 ndb-7.0.5) id=15 @192.168.0.10 (mysql-5.1.32 ndb-7.0.5) ndb_mgm> exit
mysqlslap -hlocalhost -uroot --engine=myisam --auto-generate-sql-write-number=100000 --auto-generate-sql-guid-primary \ --concurrency=50,100,200 --number-of-queries=500000 --iterations=2 --number-char-cols=10 --number-int-cols=10 \ --auto-generate-sql --create-schema=ndb --auto-generate-sql-load-type=mixed
sysbench --mysql-user=root --test=oltp --mysql-host=localhost --oltp-test-mode=complex \ --mysql-table-engine=ndbcluster --oltp-table-size=10000000 --mysql-db=ndb --oltp-table-name=mdb_1kw \ --num-threads=200 --max-requests=500000 run
本文出自 “爱MySQL” 博客,转载请与作者联系!