###测试看是否安装成功
[root@MYSQL_M tools]# netstat -lntup|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 47525/mysqld
[root@MYSQL_M tools]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@MYSQL_M tools]# netstat -lntup|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 47742/mysqld
[root@MYSQL_M tools]#
######安装成功mysql
修改MYSQL数据库的数据目录
因为的drbd要挂载到/data目录上,所以我需要把上面的mysql数据目录移除。重新初始化数据库文件到/data目录,同时要确保/data目录现在已经挂载到drbd0上操作如下
df
[root@MYSQL_M ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 11150604 2498092 8086088 24% /
tmpfs 247112 0 247112 0% /dev/shm
/dev/sda1 198337 29670 158427 16% /boot
/dev/drbd0 576696 38308 509092 3% /data
《=====此时/dev/drbd0已经挂载到/data目录
[root@MYSQL_M ~]#
/etc/init.d/mysqld stop
mv /application/mysql/data /tmp/
/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/data --user=mysql
##执行上面初始数据库目录脚本时,必须要把drbd的/dev/drbd0 挂载到/data 目录上
初始化数据目录到/data目录后,直接用脚本启动数据库会出现下面错误
/etc/init.d/mysqld start
[root@MYSQL_M ~]# /etc/init.d/mysqld start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.
[root@MYSQL_M ~]#
上面的故障解决:
修改/etc/init.d/mysqld 启动目录的47 行,修改为如下内容:
47 datadir=/data
或者用sed替换,命令如下:
sed -i 's#^datadir=#datadir=/data#' /etc/init.d/mysqld
=====================
/etc/init.d/mysqld start
netstat -lntup |grep 3306
=====================
[root@MYSQL_M ~]# sed -i 's#^datadir=#datadir=/data#' /etc/init.d/mysqld
[root@MYSQL_M ~]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS!
[root@MYSQL_M ~]# netstat -lntup|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 48830/mysqld
[root@MYSQL_M ~]#
[root@MYSQL_M ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 11150604 2498092 8086088 24% /
tmpfs 247112 0 247112 0% /dev/shm
/dev/sda1 198337 29670 158427 16% /boot
/dev/drbd0 576696 38308 509092 7% /data
[root@MYSQL_M ~]#
[root@MYSQL_M ~]# ls /data/
a1 a10 a2 a3 a4 a5 a6 a7 a8 a9 ibdata1 ib_logfile0 ib_logfile1 lost+found mysql MYSQL_M.err MYSQL_M.pid test