本机是Mac OS系统虚拟机,版本为最新的VMware fusion 7
下载地址:http://pan.baidu.com/s/1o6LoXGu 提取密码:vnlj
可用的序列号:
HYCTT-5L9RQ-44T8L-C1RG5-K2GPC
ZZAX9-UR1QM-M4MQ0-5RYQ6-6C539
LVGJ3-KHW30-M4MRU-T3N7E-RCX43
NYZ5L-HDV3T-44HKM-WW952-227Y1
4VJHT-2YWWP-04J4M-HV4ZE-X378E
由于系统磁盘空间不富裕,CentOS安装的是CentOS-7.0-XXX-x86_64-Minimal.iso 版:
下载地址:http://mirrors.sina.cn/centos/7/isos/x86_64/
Minimal版本大小约500多M,比DVD版4G和Everything版的7G比,显得实惠多了,但是也少了不少东西,比如连ifconfig、wget都要自己装,不过yum是自带的,所以稍微费一番周折。
2.1.若采用快捷安装root还需初始化():
http://jingyan.baidu.com/article/4b07be3c687f2748b280f36b.html
2.2.我在安装时碰到了下面告警(我同事在Win主机上部署就没有碰到这个问题):
针对piix4_smbus ****host smbus controller not enabled的解决方法
[root@Nagios ~]# lsmod | grep i2c_piix4
i2c_piix4 12574 0
i2c_core 31274 1 i2c_piix4
[root@Nagios ~]# vi /etc/modprobe.d/blacklist.conf
blacklist i2c_piix4
[root@Nagios ~]# reboot
重启后再无此提示!
2.3.查看ip地址,由于ifconfig没有安装,可以通过其它命令查看
ip addr show
如果网卡没有启动,还需要通过ifup命令启动网卡
ip地址是192.168.69.132 ,下一步会用到,通过客户端工具来方位,比如iterm等:(因为这是minimal版本,在server里面操作,不能进行拷贝啊!!)
2.4.通过ssh命令登录 ssh [email protected]
在CentOS中,yum中得mysql版本是MariaDB,如果想装通用的5.6版本,还需要需要参加下列操作:http://serverlab.org/view/8/How-to-install-latest-mysql-5.6-on-CentOS7
3.1.把 Mysql社区增加到 rpm repo中
yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
3.2. 执行安装
yum install mysql-community-server
4.1.修改/etc/my.cnf文件
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
user = mysql
log = /data/mysql/multi.log
[mysqld3306]
port=3306
pid-file=/data/mysql/mysqldata3306/sock/mysql.pid
socket=/data/mysql/mysqldata3306/sock/mysql.sock
atadir=/data/mysql/mysqldata3306/mydata
tmpdir=/data/mysql/mysqldata3306/tmpdir
[mysqld3307]
port=3307
pid-file=/data/mysql/mysqldata3307/sock/mysql.pid
socket=/data/mysql/mysqldata3307/sock/mysql.sock
datadir=/data/mysql/mysqldata3307/mydata
tmpdir=/data/mysql/mysqldata3307/tmpdir
[mysqldump]
quick
max_allowed_packet=2G
default-character-set=utf8
[mysql]
no-auto-rehash
prompt="\\u@\\h : \\d \\r:\\m:\\s> "
default-character-set=utf8
#default-character-set=gbk
show-warnings
#pager=mk-visual-explain
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
user=mysql
open-files-limit=8192
4.2.创建实例目录,进行数据库初始化
mkdir -p /data/mysql/mysqldata3307/sock
mkdir -p /data/mysql/mysqldata3307/tmpdir
mkdir -p /data/mysql/mysqldata3307/mydata
mkdir -p /data/mysql/mysqldata3307/log
mkdir -p /data/mysql/mysqldata3307/binlog
mkdir -p /data/mysql/mysqldata3307/relaylog
mkdir -p /data/mysql/mysqldata3307/innodb_ts
mkdir -p /data/mysql/mysqldata3307/innodb_log
mkdir -p /data/mysql/mysqldata3306/sock
mkdir -p /data/mysql/mysqldata3306/tmpdir
mkdir -p /data/mysql/mysqldata3306/mydata
mkdir -p /data/mysql/mysqldata3306/log
mkdir -p /data/mysql/mysqldata3306/binlog
mkdir -p /data/mysql/mysqldata3306/relaylog
mkdir -p /data/mysql/mysqldata3306/innodb_ts
mkdir -p /data/mysql/mysqldata3306/innodb_log
mysql_install_db --datadir=/data/mysql/mysqldata3306/mydata/ --user=mysql
mysql_install_db --datadir=/data/mysql/mysqldata3307/mydata/ --user=mysql
4.3.启动双实例
mysqld_multi start 3306
mysqld_multi start 3307
4.4.更改root密码
mysqladmin -S /data/mysql/mysqldata3306/sock/mysql.sock -u root password 123456
mysqladmin -S /data/mysql/mysqldata3307/sock/mysql.sock -u root password 123456
4.5.登录数据库
mysql -uroot -p123456 -P3306
4.6. 另外,MySQL通过yum安装后,默认是开机启动的,双实例后,还需要修改开机启动方式
参见:http://mysql-mmm.org/mmm2:guide
5.1.编辑/etc/my.cnf文件,在每个实例的参数块中增加:
server_id = 1 #同步的数据包含server_id,用来防止复制死循环
log_bin = /var/log/mysql/mysql-bin.log
log_bin_index = /var/log/mysql/mysql-bin.log.index
relay_log = /var/log/mysql/mysql-relay-bin
relay_log_index = /var/log/mysql/mysql-relay-bin.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1 #把所有的操作写入到binary log,双主+读写分离时,必须要配置为1
注意:不同实例的server_id不能相等
5.2.Then get the current position in the binary-log. We will need this values when we setup the replication on db2
(db1) mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 120 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
5.3.Configure replication And Start the slave-process
(db2) mysql>CHANGE MASTER TO master_host='localhost', master_port=3306, master_user='root',master_password='123456',master_log_file='mysql-bin.000001', master_log_pos= 120;
(db2) mysql> START SLAVE;
5.4. Also start slave-process on db1
also start