yum localinstall http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
vi /etc/yum.repos.d/mysql-community.repo
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1 # 启用5.6
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=0 # 禁用5.7
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
yum repolist enabled | grep mysql
yum install mysql-community-server
systemctl start mysqld #启动MySQLDB
systemctl stop mysqld #停止MySQLDB
systemctl restart mysqld #重启MySQLDB
systemctl enable mysqld #设置开机启动`
初始化实例目录
mysql_install_db --datadir=/var/lib/mysql/3306 --user=mysql
mysql_install_db --datadir=/var/lib/mysql/3307 --user=mysql
修改配置
vi /etc/my.cnf
[client]
default-character-set = utf8
[mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
user = root
log = /var/log/mysqld.multi.log
[mysqld1]
user=mysql
port=3306
datadir=/var/lib/mysql/3306
socket=/var/lib/mysql/3306.sock
pid-file=/tmp/mysql3306.pid
log-error=/var/log/3306-error.log
max_allowed_packet=1M
table_open_cache=4
thread_stack=128k
character_set_server=utf8
lower_case_table_names=1
server-id=1
log-bin = master3306-bin #必须开启
log-bin-index = master3306-bin.index #必须开启
[mysqld2]
user=mysql
port=3307
datadir=/var/lib/mysql/3307
socket=/var/lib/mysql/3307.sock
pid-file=/tmp/mysql3307.pid
log-error=/var/log/3307-error.log
max_allowed_packet=1M
table_open_cache=4
thread_stack=128k
character_set_server=utf8
lower_case_table_names=1
server-id=2
log-bin=mysql3307-bin
relay-log = relay-log
relay-log-index = relay-log-index
read-only = on
mysqld_multi start
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --add-port=3307/tcp --permanent
firewall-cmd --reload
grant replication slave on *.* to 'reply'@'localhost' identified by 'reply';
FLUSH PRIVILEGES;
change master to master_host='localhost',master_user='repl',master_password='repl',master_port=3306;
start slave;
show slave status;## Slave_IO_Running:Yes, Slave_SQL_Running:Yes
主库
create database test; -- 主库建库
从库
show databases; -- 从库查看
http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz?AuthParam=1446824947_759e61ddd65fdc24639703e1929d6e21
```
tar xzvf jdk-8u65-linux-x64.tar.gz
mv jdk1.8.0_65 /usr/local/
```
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_65
export PATH=$PATH:$JAVA_HOME/bin
. /etc/profile
cd /opt
wget https://github.com/MyCATApache/Mycat-download/raw/master/1.4.1-DEV/Mycat-server-1.4.1-dev-20151104100146-linux.tar.gz
tar xzvf Mycat-server-1.4.1-dev-20151104100146-linux.tar.gz
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://org.opencloudb/">
<schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100">
<table name="t_user" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" />
</schema>
<!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
/> -->
<dataNode name="dn1" dataHost="localhost1" database="db1" />
<dataNode name="dn2" dataHost="localhost1" database="db2" />
<dataNode name="dn3" dataHost="localhost1" database="db3" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="0"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<!-- can have multi write hosts -->
<writeHost host="hostM1" url="localhost:3306" user="root"
password="123456">
<!-- can have multi read hosts -->
</writeHost>
<writeHost host="hostS1" url="localhost:3307" user="root"
password="123456" />
<!-- <writeHost host="hostM2" url="localhost:3316" user="root" password="123456"/> -->
</dataHost>
</mycat:schema>
cd /opt/
./bin/mycat start && tail -200f logs/mycat.log
cd /opt
wget http://nexus.mycat.io/content/groups/public/io/mycat/mycat/Mycat-web/1.0-SNAPSHOT/Mycat-web-1.0-20151020.024535-7-20151020104455-linux.tar.gz
tar xzvf Mycat-web-1.0-20151020.024535-7-20151020104455-linux.tar.gz
cd mycat-web
./start.sh
点击访问?IP根据实际情况