mysql 裸设备_RHEL+mysql + 裸设备实验

实验环境:

1、Vmware RHEL 6.5 X64

2、一块虚拟硬盘 16G

3、mysql 5.5.40

配置过程:

1、关机添加一块虚拟磁盘16G(过程略)

2、配置裸设备将磁盘设备绑定到裸设备上

# /bin/raw /dev/raw/raw1 /dev/sdb

# chown root:mysql /dev/raw/raw1

# chmod 0660 /dev/raw/raw1

# /bin/raw -qa

# /bin/raw -q /dev/raw/raw1

# /bin/ls -l /dev/raw/raw1

# blockdev --report /dev/raw/raw1

# blockdev --report /dev/sdb

#vi /etc/udev/rules.d/60-raw.rules

ACTION=="add", KERNEL=="sdb", GROUP=="mysql",MODE="0660",RUN+="/bin/raw /dev/raw/raw1 %N"

3、如果在使用裸设备之前已经有innodb表了,导出表备份,然后删除所有innodb相关的文件,数据文件ibdata,日志文件ib_logfile等。

4、配置mysql,初始化裸设备# vi /etc/my.cnf

innodb_data_home_dir=

innodb_data_file_path=/dev/raw/raw1:3Gnewraw

启动mysql:

mysqld_safe --defaults-file=/data/mysql/my.cnf &

日志内容:#tail -f /data/mysql/log/alter.err

150922 00:42:01 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

150922  0:42:01 InnoDB: The InnoDB memory heap is disabled

150922  0:42:01 InnoDB: Mutexes and rw_locks use GCC atomic builtins

150922  0:42:01 InnoDB: Compressed tables use zlib 1.2.3

150922  0:42:01 InnoDB: Initializing buffer pool, size = 256.0M

150922  0:42:01 InnoDB: Completed initialization of buffer pool

InnoDB: The first specified data file /dev/raw/raw1 did not exist:

InnoDB: a new database to be created!

150922  0:42:01  InnoDB: Setting file /dev/raw/raw1 size to 3072 MB

InnoDB: Database physically writes the file full: wait...

InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000

150922  0:43:51  InnoDB: Log file ./ib_logfile0 did not exist: new to be created

InnoDB: Setting log file ./ib_logfile0 size to 5 MB

InnoDB: Database physically writes the file full: wait...

150922  0:43:51  InnoDB: Log file ./ib_logfile1 did not exist: new to be created

InnoDB: Setting log file ./ib_logfile1 size to 5 MB

InnoDB: Database physically writes the file full: wait...

InnoDB: Doublewrite buffer not found: creating new

InnoDB: Doublewrite buffer created

InnoDB: 127 rollback segment(s) active.

InnoDB: Creating foreign key constraint system tables

InnoDB: Foreign key constraint system tables created

150922  0:43:52  InnoDB: Waiting for the background threads to start

150922  0:43:53 InnoDB: 5.5.40 started; log sequence number 0

150922  0:43:53 [Note] Recovering after a crash using /data/mysql/log/mysql-bin

150922  0:43:53 [Note] Starting crash recovery...

150922  0:43:53 [Note] Crash recovery finished.

150922  0:43:53 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306

150922  0:43:53 [Note]   - '0.0.0.0' resolves to '0.0.0.0';

150922  0:43:53 [Note] Server socket created on IP: '0.0.0.0'.

150922  0:43:53 [Note] Event Scheduler: Loaded 0 events

150922  0:43:53 [Note] /data/mysql/bin/mysqld: ready for connections.

Version: '5.5.40-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

然后关闭mysql#mysqladmin -uroot shutdown

日志输出:#tail -f /data/mysql/log/alter.err

150922  2:02:23 [Note] /data/mysql/bin/mysqld: Normal shutdown

150922  2:02:23 [Note] Event Scheduler: Purging the queue. 0 events

150922  2:02:23  InnoDB: Starting shutdown...

150922  2:02:24  InnoDB: Shutdown completed; log sequence number 1595669

150922  2:02:24 [Note] /data/mysql/bin/mysqld: Shutdown complete

150922 02:02:24 mysqld_safe mysqld from pid file /data/mysql/mysql.pid ended

5、编辑my.cnf文件# vi /etc/my.cnf

innodb_data_home_dir=

innodb_data_file_path=/dev/raw/raw1:3Graw

启动mysql:

mysqld_safe --defaults-file=/data/mysql/my.cnf &

日志输出:#tail -f /data/mysql/log/alter.err

150922 02:02:24 mysqld_safe mysqld from pid file /data/mysql/mysql.pid ended

150922 02:05:02 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

150922  2:05:02 InnoDB: The InnoDB memory heap is disabled

150922  2:05:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins

150922  2:05:02 InnoDB: Compressed tables use zlib 1.2.3

150922  2:05:02 InnoDB: Initializing buffer pool, size = 256.0M

150922  2:05:02 InnoDB: Completed initialization of buffer pool

150922  2:05:02 InnoDB: highest supported file format is Barracuda.

150922  2:05:02  InnoDB: Waiting for the background threads to start

150922  2:05:03 InnoDB: 5.5.40 started; log sequence number 1595669

150922  2:05:03 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306

150922  2:05:03 [Note]   - '0.0.0.0' resolves to '0.0.0.0';

150922  2:05:03 [Note] Server socket created on IP: '0.0.0.0'.

150922  2:05:03 [Note] Event Scheduler: Loaded 0 events

150922  2:05:03 [Note] /data/mysql/bin/mysqld: ready for connections.

Version: '5.5.40-log'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

可以看到启动成功。执行innodb表恢复过程(略)

6、服务器重启后,裸设备的权限将丢失。

#reboot# ll /dev/raw/raw1

crw-rw----. 1 root disk 162, 1 Sep 22 02:13 /dev/raw/raw1

这时启动mysql将无法正常启动:[root@localhost ~]# mysqld_safe --defaults-file=/data/mysql/my.cnf &

[1] 1520

[root@localhost ~]# 150922 02:20:10 mysqld_safe Logging to '/data/mysql/log/alter.err'.

150922 02:20:10 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

150922 02:20:11 mysqld_safe mysqld from pid file /data/mysql/mysql.pid ended

[1]+  Done                    mysqld_safe --defaults-file=/data/mysql/my.cnf

必须重新赋权限:#chown root:mysql /dev/raw/raw1

为了解决这个问题,把上述命令放在/etc/rc.d/rc.local文件中。

报错信息:

报错一:

150921 09:41:51 mysqld_safe mysqld from pid file /data/mysql/mysql.pid ended

150921 09:42:39 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

150921  9:42:39 InnoDB: The InnoDB memory heap is disabled

150921  9:42:39 InnoDB: Mutexes and rw_locks use GCC atomic builtins

150921  9:42:39 InnoDB: Compressed tables use zlib 1.2.3

150921  9:42:39 InnoDB: Initializing buffer pool, size = 256.0M

150921  9:42:39 InnoDB: Completed initialization of buffer pool

150921  9:42:39  InnoDB: Operating system error number 13 in a file operation.

InnoDB: The error means mysqld does not have the access rights to//服务器重启后,/dev/raw/raw1的权限发生变化了。变成root:disk. 应该为root:mysql。

InnoDB: the directory.

InnoDB: File name /dev/raw/raw1

InnoDB: File operation call: 'open'.

InnoDB: Cannot continue operation.

报错二:

150922 00:36:20 mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

150922  0:36:20 InnoDB: The InnoDB memory heap is disabled

150922  0:36:20 InnoDB: Mutexes and rw_locks use GCC atomic builtins

150922  0:36:20 InnoDB: Compressed tables use zlib 1.2.3

150922  0:36:20 InnoDB: Initializing buffer pool, size = 256.0M

150922  0:36:20 InnoDB: Completed initialization of buffer pool

InnoDB: The first specified data file /dev/raw/raw1 did not exist:

InnoDB: a new database to be created!

150922  0:36:20  InnoDB: Setting file /dev/raw/raw1 size to 3072 MB

InnoDB: Database physically writes the file full: wait...

InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000

150922  0:38:10 InnoDB: Error: all log files must be created at the same time.      //提示要删除innodb已有的数据和日志文件。

150922  0:38:10 InnoDB: All log files must be created also in database creation.

150922  0:38:10 InnoDB: If you want bigger or smaller log files, shut down the

150922  0:38:10 InnoDB: database and make sure there were no errors in shutdown.

150922  0:38:10 InnoDB: Then delete the existing log files. Edit the .cnf file

150922  0:38:10 InnoDB: and start the database again.

150922  0:38:10 [ERROR] Plugin 'InnoDB' init function returned error.

150922  0:38:10 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

150922  0:38:10 [ERROR] Unknown/unsupported storage engine: innodb

150922  0:38:10 [ERROR] Aborting

150922  0:38:10 [Note] /data/mysql/bin/mysqld: Shutdown complete

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值