请选择 进入手机版 | 继续访问电脑版

部署-Mycat-Server-1.6.7.4安装与配置(CentOS 7.7)

[复制链接]
甜蜜的负担 发表于 2021-1-2 17:40:25 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
版本

  1、Mycat Server:1.6.7.4
2、MySql Server:5.7
3、Linux:CentOS 7.7
摆设 MySql 5.7

  1、摆设-用Yum安装MySQL 5.7(CentOS 7.7)
2、MySQL 5.7 用户暗码安全战略设置
下载 Mycat-server-1.6.7.4

  1. $ cd /opt/mycat$ wget http://dl.mycat.org.cn/1.6.7.4/Mycat-server-1.6.7.4-release/Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz
复制代码
安装 Mycat-server-1.6.7.4

  下载的文件直接解压即可使用
  1. $ tar zxvf Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz
复制代码
运行 Mycat-server-1.6.7.4

  1. $ cd /opt/mycat/mycat/$ bin/mycat start   # 启动$ bin/mycat stop    # 停止$ bin/mycat console # 前台运行$ bin/mycat restart # 重启服务$ bin/mycat pause   # 暂停$ bin/mycat status  # 检察启动状态
复制代码
设置 Mycat-server-1.6.7.4

1、设置 mycat 默认用户 root 的用户暗码:
修改设置文件 conf/server.xml 中的默认 root 用户暗码(可以与 mysql root 用户暗码差别)
  1.         888888
复制代码
重启 mycat:
  1. $ bin/mycat restart
复制代码
如果暗码不对,在毗连 mycat 时,会报错:
  1. $ mysql -uroot -p'888888' -P8066 -h127.0.0.1ERROR 1045 (HY000): Access denied for user 'root', because password is error
复制代码
2、设置 mycat 对后端 mysql 的毗连信息:
将设置文件 conf/schema.xml 中毗连 mysql 的 root 用户暗码修改为 mysql root 用户暗码:
  1.        
复制代码
重启 mycat:
  1. $ bin/mycat restart
复制代码
如果暗码不对,在 mycat 日志文件 logs/mycat.log 中会有如下错误日志:
  can’t connect to mysql server ,errmsg:Access denied for user ‘root’@‘localhost’ (using password: YES)
  1. 2021-01-01 13:49:42.931  WARN [$_NIOREACTOR-1-RW] (io.mycat.backend.mysql.nio.MySQLConnectionAuthenticator.handle(MySQLConnectionAuthenticator.java:91)) - can't connect to mysql server ,errmsg:Access denied for user 'root'@'localhost' (using password: YES) MySQLConnection@1107459254 [id=546, lastTime=1609480182929, user=root, schema=db3, old shema=db3, borrowed=false, fromSlaveDB=false, threadId=1209, charset=latin1, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=localhost, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
复制代码
3、在后端 mysql 中创建三个测试数据库 db1, db2, db3
创建在 mycat 设置文件 conf/schema.xml 中界说的三个默认数据库:
  1.                        
复制代码
  1. $ mysql -uroot -p'123456789' -P3306 -h127.0.0.1mysql> create database db1;mysql> create database db2;mysql> create database db3;
复制代码
如果未创建上述 mysql 数据库,在 mycat 日志文件 logs/mycat.log 中会有如下错误日志:
  can’t connect to mysql server ,errmsg:Unknown database ‘db3’
  1. 2021-01-01 14:22:49.639  WARN [$_NIOREACTOR-3-RW] (io.mycat.backend.mysql.nio.MySQLConnectionAuthenticator.handle(MySQLConnectionAuthenticator.java:91)) - can't connect to mysql server ,errmsg:Unknown database 'db3' MySQLConnection@189652758 [id=216, lastTime=1609482169637, user=root, schema=db3, old shema=db3, borrowed=false, fromSlaveDB=false, threadId=1431, charset=latin1, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=localhost, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false]
复制代码
4、在后端 mysql 中的三个测试数据库 db1, db2, db3 中分别创建两个测试表 travelrecord, address
创建在 mycat 设置文件 conf/schema.xml 中界说的两个默认数据表:
  1.                                                         [table]       
复制代码
  1. $ mysql -uroot -p'123456789' -P3306 -h127.0.0.1mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || db1                || db2                || db3                || mysql              || performance_schema || sys                |+--------------------+7 rows in set (0.00 sec)# 在数据库 db1 中创建数据表 travelrecord, addressmysql> use db1;mysql> CREATE TABLE `travelrecord` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;mysql> CREATE TABLE `address` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;# 在数据库 db2 中创建数据表 travelrecord, addressmysql> use db2;mysql> CREATE TABLE `travelrecord` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;mysql> CREATE TABLE `address` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;# 在数据库 db3 中创建数据表 travelrecord, addressmysql> use db3;mysql> CREATE TABLE `travelrecord` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;mysql> CREATE TABLE `address` ( `id` INT(11) NOT NULL, `name` VARCHAR(50) NULL DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB;
复制代码
如果未创建上述数据表,毗连 mycat 并查询这些数据表时会报错:“Table ‘db2.address’ doesn’t exist”
  1. $ mysql -uroot -p'123456789' -P8066 -h127.0.0.1mysql> show databases;+----------+| DATABASE |+----------+| TESTDB   |+----------+1 row in set (0.00 sec)mysql> use TESTDB;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+------------------+| Tables in TESTDB |+------------------+| address          || travelrecord     |+------------------+2 rows in set (0.00 sec)mysql> select * from address;ERROR 1105 (HY000): Table 'db2.address' doesn't exist# 多次执行上述 select 语句,大概会报如下错误:# ERROR 1105 (HY000): Table 'db1.address' doesn't exist# ERROR 1105 (HY000): Table 'db2.address' doesn't exist# ERROR 1105 (HY000): Table 'db3.address' doesn't exist
复制代码
同时在 mycat 日志文件 logs/mycat.log 中会有如下错误日志:
  err Table ‘db1.address’ doesn’t exist code:1146
err Table ‘db2.address’ doesn’t exist code:1146
err Table ‘db3.address’ doesn’t exist code:1146
  1. 2021-01-01 14:55:12.664  WARN [$_NIOREACTOR-2-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeHandler.errorResponse(MultiNodeHandler.java:142)) - io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@d0dece4error response from MySQLConnection@972530381 [id=222, lastTime=1609484112657, user=root, schema=db1, old shema=db1, borrowed=false, fromSlaveDB=false, threadId=1438, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=localhost, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] err Table 'db1.address' doesn't exist code:11462021-01-01 14:55:12.665  WARN [$_NIOREACTOR-2-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeHandler.errorResponse(MultiNodeHandler.java:142)) - io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@d0dece4error response from MySQLConnection@1848688729 [id=219, lastTime=1609484112657, user=root, schema=db2, old shema=db2, borrowed=false, fromSlaveDB=false, threadId=1435, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=localhost, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] err Table 'db2.address' doesn't exist code:11462021-01-01 14:55:12.665  WARN [$_NIOREACTOR-2-RW] (io.mycat.backend.mysql.nio.handler.MultiNodeHandler.errorResponse(MultiNodeHandler.java:142)) - io.mycat.backend.mysql.nio.handler.MultiNodeQueryHandler@d0dece4error response from MySQLConnection@990905854 [id=229, lastTime=1609484112657, user=root, schema=db3, old shema=db3, borrowed=false, fromSlaveDB=false, threadId=1444, charset=utf8, txIsolation=3, autocommit=true, attachment=null, respHandler=null, host=localhost, port=3306, statusSync=null, writeQueue=0, modifiedSQLExecuted=false] err Table 'db3.address' doesn't exist code:11462021-01-01 14:55:12.665 ERROR [$_NIOREACTOR-2-RW] (io.mycat.net.FrontendConnection.writeErrMessage(FrontendConnection.java:210)) - ServerConnection [id=5, schema=TESTDB, host=127.0.0.1, user=root,txIsolation=3, autocommit=true, schema=TESTDB, executeSql=select * from address]Table 'db3.address' doesn't exist
复制代码
Mycat 毗连测试

  测试 mycat 与测试 mysql 完全一致,mysql 怎么毗连,mycat 就怎么毗连
  1. # 8066 是 Mycat 的默认毗连端口$ mysql -uroot -p'123456789' -P8066 -h127.0.0.1
复制代码
参考



来源:https://blog.csdn.net/SparkLee2013/article/details/112058637
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


专注素材教程免费分享
全国免费热线电话

18768367769

周一至周日9:00-23:00

反馈建议

27428564@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by Discuz! X3.4© 2001-2013 Comsenz Inc.( 蜀ICP备2021001884号-1 )