8 17 1060258 sdb1
node2:
[root@node2 ~]# drbdadm create-md web
'web' not defined in your config (for this host).
[root@node2 ~]# drbdadm create-md mysql
initializing activity log
NOT initializing bitmap
Writing meta data...
New drbd meta data block successfully created.
[root@node2 ~]# service drdb start
drdb: 未被识别的服务
[root@node2 ~]# service drbd start
Starting DRBD resources: [
create res: mysql
prepare disk: mysql
adjust disk: mysql
adjust net: mysql
]
7、初始化设备同步
[root@node1 ~]# drbdadm -- --overwrite-data-of-peer primary mysql
[root@node1 ~]# cat /proc/drbd #查看同步进度
version: 8.4.7-1 (api:1/proto:86-101)
GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by mockbuild@Build64R6, 2016-01-12 13:27:11
0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r-----
ns:577536 nr:0 dw:0 dr:578200 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:482648
[=========>..........] sync'ed: 54.9% (482648/1060184)K
finish: 0:00:11 speed: 41,252 (41,252) K/sec
[root@node1 ~]# drbd-overview #查看设备级别
0:mysql/0 Connected Primary/Secondary UpToDate/UpToDate
8、创建文件系统
######格式化文件系统
[root@node1 ~]# mkfs.ext4 /dev/drbd0
禁止node1与node2节点上的DRBD服务开机自启动
[root@node1 ~]# chkconfig drbd off
[root@node1 ~]# chkconfig --list drbd
drbd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
=====================================================================
[root@node2 ~]# chkconfig drbd off
[root@node2 ~]# chkconfig --list drbd
drbd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
三、安装mysql
1、安装Mysql并配置
######在NOD1节点上安装Mysql
[root@nod1 ~]# mkdir /data/mysql/
[root@nod1 ~]# mount /dev/drbd0 /data/mysql/
[root@nod1 ~]# tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz -C /usr/local/
[root@nod1 ~]# cd /usr/local/
[root@nod1 local]# ln -s mysql-5.5.33-linux2.6-x86_64 mysql
[root@nod1 local]# cd mysql
[root@nod1 mysql]# cp support-files/my-large.cnf /etc/my.cnf
[root@nod1 mysql]# cp support-files/mysql.server /etc/init.d/mysql
[root@nod1 mysql]# chmod +x /etc/init.d/mysql
[root@nod1 mysql]# chkconfig --add mysql
[root@nod1 mysql]# chkconfig mysql off
[root@nod1 mysql]# vim /etc/my.cnf
在[mysql]部分添加:
datadir = /mydata/data #指定数据存储路径
innodb_file_per_table = 1 #开启独享表空间
[root@nod1 mysql]# echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
[root@nod1 mysql]# . /etc/profile #让mysql的环境变量生效
[root@nod1 mysql]# useradd -r -u 306 mysql
[root@nod1 mysql]# chown mysql.mysql -R /data/mysql/
[root@nod1 mysql]# chown root.mysql *
[root@nod1 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
[root@nod1 mysql]# service mysql start
Starting MySQL..... [ OK ]
[root@nod1 mysql]# chkconfig --list mysql
mysql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@nod1 mysql]# service mysql stop
Shutting down MySQL. [ OK ]
(责任编辑:liangzh) |