• tidb初体验


    安装

    docker-compose:

    https://github.com/pingcap/tidb-docker-compose

    pd tikv tidb各单个节点,单个副本,限制内存,cpu等,防止给服务器搞宕机

    先使用docker快速安装一个tidb体验一下子

    version: '2.1'
    
    services:
      pd0:
        image: pingcap/pd:latest
        ports:
          - "2379:2379"
        volumes:
          - ./config/pd.toml:/pd.toml:ro
          - ./data:/data
          - ./logs:/logs
        command:
          - --name=pd0
          - --client-urls=http://0.0.0.0:2379
          - --peer-urls=http://0.0.0.0:2380
          - --advertise-client-urls=http://pd0:2379
          - --advertise-peer-urls=http://pd0:2380
          - --initial-cluster=pd0=http://pd0:2380
          - --data-dir=/data/pd0
          - --config=/pd.toml
          - --log-file=/logs/pd0.log
        restart: on-failure
        mem_limit: 2g
        cpu_quota: 50000
        cpu_period: 20ms
    #    networks:
    #      - default
    #    extra_hosts:
    #    - "prometheus-dev.xx.com:192.168.100.96"
    
      tikv0:
        image: pingcap/tikv:latest
        ports:
          - "20180:20180"
          - "20160:20160"
        volumes:
          - ./config/tikv.toml:/tikv.toml:ro
          - ./data:/data
          - ./logs:/logs
        command:
          - --addr=0.0.0.0:20160
          - --advertise-addr=tikv0:20160
          - --data-dir=/data/tikv0
          - --status-addr=0.0.0.0:20180
          - --pd=pd0:2379
          - --config=/tikv.toml
          - --log-file=/logs/tikv0.log
        depends_on:
          - "pd0"
        restart: on-failure
        mem_limit: 2g
        cpu_quota: 50000
        cpu_period: 20ms
    #    networks:
    #      - default
    #    extra_hosts:
    #    - "prometheus-dev.xx.com:192.168.100.96"
      tidb:
        image: pingcap/tidb:latest
        ports:
          - "4000:4000"
          - "10080:10080"
        volumes:
          - ./config/tidb.toml:/tidb.toml:ro
          - ./logs:/logs
        command:
          - --store=tikv
          - --path=pd0:2379
          - --config=/tidb.toml
          - --log-slow-query=/logs/tidb_slow_query.log
          - --log-file=/logs/tidb.log
          - --advertise-address=tidb
        depends_on:
          - "tikv0"
        restart: on-failure
        mem_limit: 2g
        cpu_quota: 50000
        cpu_period: 20ms
    #    networks:
    #      - default
    #    extra_hosts:
    #    - "prometheus-dev.xx.com:192.168.100.96"
    
    #networks:
    #  default:
    #    external: true
    #    name: gibsdev_default
    

     可以接入已有的prometheus监控 

    修改配置,限制内存为2g

    配置

    不要使用默认的配置,里面会有废弃的参数

    [root@xuliang config]# cat pd.toml
    ##
    [pd-server]
    metric-storage = "http://prometheus-dev.xx.com"
    
    [replication]
    max-replicas = 1
    
    [schedule]
    leader-schedule-limit = 4
    region-schedule-limit = 2048
    replica-schedule-limit = 64
    [root@xuliang config]# cat tidb.toml
    mem-quota-query = 209715200
    oom-use-tmp-storage = true
    oom-action = "cancel"
    
    [binlog]
    enable = true
    ignore-error = false
    
    [log]
    slow-threshold = 300
    
    [performance]
    txn-total-size-limit = 204857600
    stmt-count-limit = 500000
    [root@xuliang config]# cat tikv.toml
    
    [raftstore]
    sync-log = false
    store-pool-size = 4
    
    [readpool]
    [readpool.coprocessor]
    use-unified-pool = true
    [readpool.storage]
    use-unified-pool = false
    [storage]
    reserve-space = 0
    [storage.block-cache]
    capacity = "2048MB"
    [root@xuliang config]#
    

     

    配置主要参数,其他默认,看需要改:

       主要参数:副本数,内存,cpu限制等,磁盘。。。

       tidb:

        txn-total-size-limit = 204857600

       tikv:

      capacity = "2048MB" 此参数一定不能大于tikv最大内存,不然会oom 

    用户管理:

    CREATE USER 'benchmark'@'%' IDENTIFIED BY '123456';

    GRANT all on gid_test.* to benchmark@'%';

    flush privileges;

    show grants for 'benchmark';

    revoke DROP on gid_test.* from 'benchmark'@'%';

  • 相关阅读:
    由博客园页面样式挖出的一款心机软件
    SQL Server 各任务所维护
    [转载]SQL Server查找包含某关键字的存储过程3种方法
    Hibernate简单注解开发和事务处理(四)
    Hibernate实现简单的CRUD操作和常见类(三)
    Hibernate中hibernate.cfg.xml文件和Xxx.hbm.xml文件的详细解释(二)
    Hibernate开发环境的简单搭建及常见错误(一)
    Struts2配置异常错误处理(十六)
    Struts2实现类型转换器(十五)
    Struts2实现JSON和Ajax操作(十四)
  • 原文地址:https://www.cnblogs.com/xuliang666/p/14047786.html
Copyright © 2020-2023  润新知