[DRBD新手上路] -- 测试

5. 测试

我们先在primary节点上写入数据:

[root@s1.yejr.com ~]# cp mysql-6.0.3.tar.gz /data/
[root@s1.yejr.com ~]# ls –l /data/
………
-rw-r--r--  1 root root 56857784 Mar 13 16:41 mysql-6.0.3-alpha-linux-x86_64-glibc23.tar.gz

然后,我们把primary降级成secondary,把secondary提升成primary:

[root@s1.yejr.com ~]# umount /data
[root@s1.yejr.com ~]# drbdadm secondary db

把primary降级前,一定要先umount设备才行。
然后提升secondary:

[root@s2.yejr.com ~]# drbdadm primary db
[root@s2.yejr.com ~]# mount /dev/drbd0 /data
[root@s2.yejr.com ~]# ls –l /data
………
-rw-r--r--  1 root root 56857784 Mar 13 16:41 mysql-6.0.3-alpha-linux-x86_64-glibc23.tar.gz

可以看到,数据已经完全同步过去了。

结语:

这是我第一次接触drbd,一开始有很多概念的东西都还没搞明白,通过看手册,看FAQ,看其他人写的案例,做到了心中有个基本的概念。然后把drbd理解成mysql的replication,这样一来,就更形象了。在实践的过程中,也碰到过一些问题,主要是靠和朋友的交流,还有搜索等来分析、了解问题所在,并且解决。下一步就是把drbd和heartbeat整合起来,形成一个实际的解决方案。

技术相关:

评论

[root@s1.yejr.com ~]# drbdadm create-md r0
这条命令是不需要的吧
因为本身配置文件指定resource db

drbd+ha的解决方案还是很不错的 有人也做过3机方案

看的真仔细,这里是整理时的笔误,sorry

MySQL方案、培训、支持
MySQL 用户组

我搭建了drbd+ha+mysql ,恳请大家分析一下这个架构可能会出现的问题,因为我过一段打算把其应用到线上。

自己模拟实际环境多测试下吧,考虑周全了一般没什么问题

MySQL方案、培训、支持

觉得没有rsync方便啊

呵呵,方便是方便了,但是却不是想要的。

MySQL方案、培训、支持

把drbd和heartbeat整合起来,用在网站上比较好,用于OLTP实时性较强的系统中硬件宕机后的切换时间较长。主要是当HEARTBEAT心跳时间较短时,drbddisk不能一次性设置primary状态成功(drbd版本为7.0.23),需要重复试几次才行。
我们测试heartbeat2.1.3+drbd版本为7.0.23+Mon可以形成一个完整的解决方案,heartbeat+drbd8.2.4硬件宕机后drbddisk不设置primary状态成功,导致业务不可加载。。这件事比较奇怪。也许我对drbd.conf各配置项了解不够深刻吧。

尝试过先disconnect了吗?参见 http://imysql.cn/2008_03_25_drbd_node_switch

MySQL方案、培训、支持
MySQL 用户组

disconnect当然测试过了..^-^drbd8的drbddisk有问题

heartbeat2.1.3+drbd0.7.23+Mon0.99整合方案。。
功能实现mysql的高可用性。
问题:
主节点可以通过heartbeat在镜像分区启动mysql
drbd同步后(主从节点镜像分区的字节数一致。且内容一致),
备份节点不能通过heartbeat在镜像分区启动mysql(这时主节点drbd处于secondary状态)
察看镜像分区中mysql日志
innodb :error :tried to read 16384 bytes at offset 0 81920
innodb:were only to read -1
innodb:operation system error 5 in a file operation

当前备份节点不能进行任何读写操作,新版本中会实现只读功能。
想要在原来的备份节点上启动mysql,就必须要先把它切换成主节点才行

MySQL方案、培训、支持

当前状态:
原来的主节点上的heartbeat服务已经关闭
原来的备份节点未安装heartbeat。两边同时启动drbd
然后原来的备份节点drbd设置为primary状态,加载/dev/drbd0映射镜像分区。
最后启动mysql服务。
注:/etc/my.cnf符号连接指向镜像分区下的my.cnf
/etc/init.d/mysqld中数据目录设定为镜像分区数据目录

相关mysql问题
http://forums.mysql.com/read.php?21,119097,119767#msg-119767

version:0.7.23(api:79/proto:74)
SVN Revision :2686 build by root@local180
2008-5-26 18:05-21
0:cs connected st:primary/Secondary
ld:Consistent ns:284 nr:0 dw:284 dr:3529
al:4 bm:0 lo:0 pe:0 ua:0 ap:0
这是原来的备份节点(现为drbd主节点)的drbd状态
有一种解决方法,正在测试。

错误性质:I/O error
这里的错误是硬件问题还是mysql版本的bug

如图
MySQL 5.0 Reference Manual :: 13 Storage Engines :: 13.2 The InnoDB Storage Engine ::

13.2.15 InnoDB Error Handling :: 13.2.15.2 Operating System Error Codes
« 13.2.15.1 InnoDB Error Codes

--------------------------------------------------------------------------------
13.2.16 Restrictions on InnoDB Tables »
Section Navigation [Toggle]
13.2.15 InnoDB Error Handling
13.2.15.1 InnoDB Error Codes
13.2.15.2 Operating System Error Codes
13.2.15.2. Operating System Error Codes
To print the meaning of an operating system error number, use the perror program that comes

with the MySQL distribution.

The following table provides a list of some common Linux system error codes. For a more

complete list, see Linux source code.

1 (EPERM)

Operation not permitted

2 (ENOENT)

No such file or directory

3 (ESRCH)

No such process

4 (EINTR)

Interrupted system call

5 (EIO)

I/O error

6 (ENXIO)

No such device or address

7 (E2BIG)

Arg list too long

8 (ENOEXEC)

Exec format error

9 (EBADF)

Bad file number

10 (ECHILD)

No child processes

11 (EAGAIN)

Try again

12 (ENOMEM)

Out of memory

13 (EACCES)

Permission denied

14 (EFAULT)

Bad address

15 (ENOTBLK)

Block device required

16 (EBUSY)

Device or resource busy

17 (EEXIST)

File exists

18 (EXDEV)

Cross-device link

19 (ENODEV)

No such device

20 (ENOTDIR)

Not a directory

21 (EISDIR)

Is a directory

22 (EINVAL)

Invalid argument

23 (ENFILE)

File table overflow

24 (EMFILE)

Too many open files

25 (ENOTTY)

Inappropriate ioctl for device

26 (ETXTBSY)

Text file busy

27 (EFBIG)

File too large

28 (ENOSPC)

No space left on device

29 (ESPIPE)

Illegal seek

30 (EROFS)

Read-only file system

31 (EMLINK)

Too many links

The following table provides a list of some common Windows system error codes. For a

complete list, see the Microsoft Web site.

1 (ERROR_INVALID_FUNCTION)

Incorrect function.

2 (ERROR_FILE_NOT_FOUND)

The system cannot find the file specified.

3 (ERROR_PATH_NOT_FOUND)

The system cannot find the path specified.

4 (ERROR_TOO_MANY_OPEN_FILES)

The system cannot open the file.

5 (ERROR_ACCESS_DENIED)

Access is denied.

6 (ERROR_INVALID_HANDLE)

The handle is invalid.

7 (ERROR_ARENA_TRASHED)

The storage control blocks were destroyed.

8 (ERROR_NOT_ENOUGH_MEMORY)

Not enough storage is available to process this command.

9 (ERROR_INVALID_BLOCK)

The storage control block address is invalid.

10 (ERROR_BAD_ENVIRONMENT)

The environment is incorrect.

11 (ERROR_BAD_FORMAT)

An attempt was made to load a program with an incorrect format.

12 (ERROR_INVALID_ACCESS)

The access code is invalid.

13 (ERROR_INVALID_DATA)

The data is invalid.

14 (ERROR_OUTOFMEMORY)

Not enough storage is available to complete this operation.

15 (ERROR_INVALID_DRIVE)

The system cannot find the drive specified.

16 (ERROR_CURRENT_DIRECTORY)

The directory cannot be removed.

17 (ERROR_NOT_SAME_DEVICE)

The system cannot move the file to a different disk drive.

18 (ERROR_NO_MORE_FILES)

There are no more files.

19 (ERROR_WRITE_PROTECT)

The media is write protected.

20 (ERROR_BAD_UNIT)

The system cannot find the device specified.

21 (ERROR_NOT_READY)

The device is not ready.

22 (ERROR_BAD_COMMAND)

The device does not recognize the command.

23 (ERROR_CRC)

Data error (cyclic redundancy check).

24 (ERROR_BAD_LENGTH)

The program issued a command but the command length is incorrect.

25 (ERROR_SEEK)

The drive cannot locate a specific area or track on the disk.

26 (ERROR_NOT_DOS_DISK)

The specified disk or diskette cannot be accessed.

27 (ERROR_SECTOR_NOT_FOUND)

The drive cannot find the sector requested.

28 (ERROR_OUT_OF_PAPER)

The printer is out of paper.

29 (ERROR_WRITE_FAULT)

The system cannot write to the specified device.

30 (ERROR_READ_FAULT)

The system cannot read from the specified device.

31 (ERROR_GEN_FAILURE)

A device attached to the system is not functioning.

32 (ERROR_SHARING_VIOLATION)

The process cannot access the file because it is being used by another process.

33 (ERROR_LOCK_VIOLATION)

The process cannot access the file because another process has locked a portion of the file.

34 (ERROR_WRONG_DISK)

The wrong diskette is in the drive. Insert %2 (Volume Serial Number: %3) into drive %1.

36 (ERROR_SHARING_BUFFER_EXCEEDED)

Too many files opened for sharing.

38 (ERROR_HANDLE_EOF)

Reached the end of the file.

39 (ERROR_HANDLE_DISK_FULL)

The disk is full.

87 (ERROR_INVALID_PARAMETER)

The parameter is incorrect. (If this error occurs on Windows and you have enabled

innodb_file_per_table in a server option file, add the line innodb_flush_method=unbuffered

to the file as well.)

112 (ERROR_DISK_FULL)

The disk is full.

123 (ERROR_INVALID_NAME)

The filename, directory name, or volume label syntax is incorrect.

1450 (ERROR_NO_SYSTEM_RESOURCES)

Insufficient system resources exist to complete the requested service.

Previous / Next / Up / Table of Contents
User Comments
Posted by Peter Beckman on August 23 2005 1:41pm [Delete] [Edit]

On FreeBSD 5.x, there is a hard limit default compiled into the kernel which limits the

amount of memory a process can use to 512MB. You can see this by running the command

"limits."

You can, without recompiling the kernel, increase this per process memory limit to something

higher, but absolutely below your physical memory. I.e. if you have 1GB of memory, do not

set your per process memory limit equal to or higher than that! FreeBSD 5.x will crash and

not be able to be recovered without a local change being made if you set that limit higher

than the amount of physical memory . (FreeBSD Bug: http://www.freebsd.org/cgi/query-pr.cgi?

pr=84656)

In /boot/loader.conf, add these lines (on a 1.5GB box or greater):
kern.maxdsiz="1073741824" # 1GB
kern.dfldsiz="1073741824" # 1GB
kern.maxssiz="134217728" # 128MB

Then reboot, and increase your my.cnf memory configuration values in order to increase mysql

memory usage.

The error you might see (related here since the Operating system error number is 12 (ENOMEM)

Out of memory:

InnoDB: Error: cannot allocate 797284 bytes of
InnoDB: memory with malloc! Total allocated memory
InnoDB: by InnoDB 6299504 bytes. Operating system errno: 12
InnoDB: Check if you should increase the swap file or
InnoDB: ulimits of your operating system.
InnoDB: On FreeBSD check you have compiled the OS with
InnoDB: a big enough maximum process size.
InnoDB: We keep retrying the allocation for 60 seconds...
InnoDB: Fatal error: cannot allocate the memory for the buffer pool

Add your own comment.