• Mycat学习-单独启动mycat


    Mycat下载地址:http://mycat.io/
    Mycat安装:解压缩即可。
     
    Mycat作为一个中间件,实现mysql协议,是可以不依赖数据库单独运行的。
    对前端应用连接来说就是一个数据库,也就有数据库的配置,mycat的数据库配置是在schema.xml中配置,配置好后映射到server.xml里面的用户就可以了。
     
    如下一个简单的配置就可以单独启动mycat了。
     

    conf/schema.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mycat:schema SYSTEM "schema.dtd">
    
    <mycat:schema  xmlns:mycat="http://io.mycat/">
      <schema name="TESTDB" checkSQLschema="true" sqlMaxLimit="100" dataNode="dn1">
          <table name="t_user" dataNode="dn1,dn2" rule="auto-sharding-long"/>
          <table name="ht_jy_login_log" primaryKey="ID" dataNode="dn1,dn2" rule="auto-sharding-long"/>
      </schema>
      <dataNode name="dn1" dataHost="localhost1" database="mycat_node1"/>
      <dataNode name="dn2" dataHost="localhost1" database="mycat_node2"/>
    
      <dataHost name="localhost1" writeType="0" switchType="1" slaveThreshold="100" balance="1" dbType="mysql" maxCon="10" minCon="1" dbDriver="native">
        <heartbeat>show status like 'wsrep%'</heartbeat>
        <writeHost host="hostM1" url="127.0.0.1:3306" user="root" password="root" >
        </writeHost>
      </dataHost>
    </mycat:schema >

    conf/server.xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE mycat:server SYSTEM "server.dtd">
    <mycat:server xmlns:mycat="http://io.mycat/">
    <user name="mycat">
        <property name="password">mycat</property>
        <property name="schemas">TESTDB</property>
    </user>
     </mycat:server>

     

    启动 bin/mycat

    [root@localhost conf]# mycat start
    Starting Mycat-server...
    [root@localhost conf]# mycat status
    Mycat-server is running (33384).
    如果启动失败,检查日志 logs/wrapper.log.

     

    登录mycat

    [root@localhost logs]# mysql -h 127.0.0.1 -umycat -pmycat -P8066
    Welcome to the MariaDB monitor.  Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.6.29-mycat-1.6.7.3-release-20190927161129 MyCat Server (OpenCloudDB)
    Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    MySQL [(none)]>  select * from help;
    ERROR 3000 (HY000): No MyCAT Database selected
    MySQL [(none)]> show databases;
    +----------+
    | DATABASE |
    +----------+
    | TESTDB   |
    +----------+
    1 row in set (0.03 sec)
    
    MySQL [(none)]> use TESTDB
    Database changed
    MySQL [TESTDB]> select * from help;
    ERROR 1184 (HY000): Invalid DataSource:0
  • 相关阅读:
    变量作用域
    模块化编程-函数
    递归
    变量
    形参和实参
    函数返回值
    node.js+yarn环境centos7快速部署
    LINUX磁盘添加挂载
    分布式存储MINIO集群部署实例
    Docker取消默认https连接
  • 原文地址:https://www.cnblogs.com/plluoye/p/11716585.html
Copyright © 2020-2023  润新知