这里将进行简单的部署和配置,在配置之前,需要先了解一定的拓扑情况

类目           属性                备注

kingshard  10.11.10.214  无

master       10.11.10.215 主库

slave         10.11.10.216  读库

详细了解地址 https://github.com/flike/kingshard/blob/master/README_ZH.md

安装

由于kingshard使用的是go语言开发。故此需要在kingshard这台机器中安装对应的go支持的编译软件(go版本为1.6以上)

  1. [root@gzsd-ks01-101110214 ~]# yum -y install go git
  2. [root@gzsd-ks01-101110214 ~]# mkdir /data/download
  3. [root@gzsd-ks01-101110214 ~]# cd /data/download/
  4. [root@gzsd-ks01-101110214 download]# git clone https://github.com/flike/kingshard.git /etc/kingshard
  5. [root@gzsd-ks01-101110214 download]# cd /etc/kingshard/
  6. [root@gzsd-ks01-101110214 kingshard]# source ./dev.sh
  7. [root@gzsd-ks01-101110214 kingshard]# make

到这里,编译完成,对配置文件进行修改

  1. [root@gzsd-ks01-101110214 kingshard]# cp etc/ks.yaml etc/ks.yaml.bak
  2. [root@gzsd-ks01-101110214 kingshard]# vi etc/ks.yaml

# kingshard的地址和端口
addr : 0.0.0.0:9696

# prometheus server listen addr
prometheus_addr : 0.0.0.0:7080

# 连接kingshard的用户名和密码的用户列表
user_list:
-
user : root
password : root
# -
# user : kingshard 注册一个账号
# password : kingshard

#kingshard的web API 端口
web_addr : 0.0.0.0:9797
#调用API的用户名和密码
web_user : admin
web_password : admin

# if set log_path, the sql log will write into log_path/sql.log,the system log
# will write into log_path/sys.log
# log_path : /Users/flike/log

# log级别,[debug|info|warn|error],默认是error
log_level : debug

# 打开SQL日志,设置为on;关闭SQL日志,设置为off
log_sql: on

#如果设置了该项,则只输出SQL执行时间超过slow_log_time(单位毫秒)的SQL日志,不设置则输出全部SQL日志
#slow_log_time : 100

# the path of blacklist sql file
# all these sqls in the file will been forbidden by kingshard
#blacklist_sql_file: /Users/flike/blacklist

# 只允许下面的IP列表连接kingshard,如果不配置则对连接kingshard的IP不做限制。
# support ip and ip segment
#allow_ips : 127.0.0.1,192.168.15.0/24

# kingshard使用的字符集,如果不设置该选项,则kingshard使用utf8作为默认字符集
proxy_charset: utf8mb4

# node is an agenda for real remote mysql server.
nodes :
-
#node节点名字
name : node1

# 连接池中最大空闲连接数,也就是最多与后端DB建立max_conns_limit个连接
max_conns_limit : 32
# kingshard连接该node中mysql的用户名和密码,master和slave的用户名和密码必须一致 grant option设置的密码需要一致

user : root
password : root

# master的地址和端口
master : 192.168.248.130:3306

# slave的地址、端口和读权重,@后面的表示该slave的读权重。可不配置slave
#slave : 192.168.59.101:3307@2,192.168.59.101:3307@3
slave : 192.168.248.131:3306@3
#down_after_noalive : 32
#kingshard在300秒内都连接不上mysql,kingshard则会下线该mysql
down_after_noalive : 32

# schema defines sharding rules, the db is the sharding table database.
schema_list :
-
#schema的所属用户名
user: root
#分表分布的node名字
nodes: [node1]
#所有未分表的SQL,都会发往默认node。
default: node1
shard:
-
#分表使用的db
db : kingshard
#分表名字
table: test_shard_hash
#分表字段
key: id
#分表分布的node
nodes: [node1]
#分表类型
type: hash
#子表个数分布,表示node1有4个子表,
locations: [4]

-
db : hidb
table: test_hash
key: id
nodes: [node1]
type: hash
locations: [4]
-
db : kingshard
table: test_shard_range
key: id
type: range
nodes: [node1]
locations: [4]
#个子表最多包好10000条记录。即子表1对应的id为[0,10000),子表2[10000,20000)....
table_row_limit: 10000
# -
# db : kingshard
# table: test_shard_time
# key: id
# nodes: [node1]
# type: hash
# locations: [2]
# -
# db : kingshard
# table: test_shard_month
# key: dtime
# type: date_month
# nodes: [node1]
# date_range: [201603-201605,201609-201612]
# -
# db : kingshard
# table: test_shard_day
# key: mtime
# type: date_day
# nodes: [node1]
# date_range: [20160306-20160307,20160308-20160309]

建立软连接

  1. ln /etc/kingshard /usr/bin/kingshard

测试使用screen来执行启动脚本

  1. [root@gzsd-ks01-101110214 kingshard]# yum -y install screen
  2. [root@gzsd-ks01-101110214 kingshard]# screen -R ks
  3. [root@gzsd-ks01-101110214 kingshard]# kingshard --config=etc/ks.yaml

可以用supervisor管理进程

中间件kingshard入门(一):基本安装的更多相关文章

  1. jmeter安装教程与新手入门(附jdk安装教程)

    一.前言 最近要对网站做性能测试,提到了并发数测试,查了下,还是决定使用jmeter来完成这项测试,这里总结了jmeter完整的安装教程,附上新手使用教程. 二.jmeter安装 1.jdk安装(jm ...

  2. MQTT入门1 -- mosquitto 安装

    原文链接:https://www.cnblogs.com/NickQ/p/9247638.html MQTT入门1 -- mosquitto 安装 简介: MQTT(Message Queuing T ...

  3. [转] Spark快速入门指南 – Spark安装与基础使用

    [From] https://blog.csdn.net/w405722907/article/details/77943331 Spark快速入门指南 – Spark安装与基础使用 2017年09月 ...

  4. 『NiFi 学习之路』入门 —— 下载、安装与简单使用

    一.概述 "光说不练假把式." 官网上的介绍多少让人迷迷糊糊的,各种高大上的词语仿佛让 NiFi 离我们越来越远. 实践是最好的老师.那就让我们试用一下 NiFi 吧! 二.安装 ...

  5. Python3入门之软件安装

    获得更多资料欢迎进入我的网站或者 csdn或者博客园 最近将我的Python笔记整理下,希望能对他人有所帮助,这是第一课,安装入门篇: windows下安装Python 1.下载,从这里下载:[下载链 ...

  6. Docker入门之 - 如何安装Docker CE

    原文:Docker入门之 - 如何安装Docker CE 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u012055638/article/det ...

  7. MySQL入门——Linux下安装后的配置文件

    MySQL入门——Linux下安装后的配置文件 摘要:本文主要了解了在Linux环境下安装MySQL后的配置文件的位置,以及如何创建配置文件. 查看配置文件的加载顺序 找到mysqld的路径 通过wh ...

  8. R语言入门1:安装R和RStudio

    R语言入门1:安装R和RStudio 曹务强 中科院遗传学博士研究生 9 人赞同了该文章 1. Windows安装R 在Windows系统上,安装R语言比较简单,直接从R的官方网站下载,按照正常的软件 ...

  9. 1,turicreate入门 - jupyter & turicreate安装

    turicreate入门系列文章目录 1,turicreate入门 - jupyter & turicreate安装 2,turicreate入门 - 一个简单的回归模型 3,turicrea ...

随机推荐

  1. 吴裕雄--天生自然Numpy库学习笔记:NumPy Matplotlib

    Matplotlib 是 Python 的绘图库. 它可与 NumPy 一起使用,提供了一种有效的 MatLab 开源替代方案. 它也可以和图形工具包一起使用,如 PyQt 和 wxPython. W ...

  2. ASA-有关AAA用户登录的问题

    问题示例:I have created a test user that is set to privilege 15 in the config: When I log in to the ASA ...

  3. XCOJ 1205 A.First Blood

    1205: A.First Blood 时间限制: 1 Sec  内存限制: 64 MB提交: 152  解决: 44 标签提交统计讨论版 题目描述 盖伦是个小学一年级的学生,在一次数学课的时候,老师 ...

  4. sqlserver数据库中char、varchar、text与nchar、nvarchar、ntext数据类型使用详解

    很多开发者进行数据库设计的时候往往并没有太多的考虑char, varchar类型,有的是根本就没注意,因为存储价格变得越来越便宜了,忘记了最开始的一些基本设计理论和原则,这点让我想到了现在的年轻人,大 ...

  5. docker运行安装mysql postgres

    安装mysql [root@host1 ~]# docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/mysql 5.7 4d ...

  6. Failed to read candidate component class

    今天编程时遇到了Failed to read candidate component class 这个异常,查了好久终于发现了是因为jdk的版本不对,所以报了这个错.

  7. linux搭建jenkins+github详细步骤

    事情缘由: 现在在做的主要工作是通过jenkins+postman实现api的自动化测试,想要达到的效果是,api自动化测试定时跑脚本的同时,github有新的代码提交,jenkins会自动检测部署新 ...

  8. Codeforces Round #594 (Div. 2) - C. Ivan the Fool and the Probability Theory(思维)

    题意:给n*m的网格涂黑白两种颜色,保证每个格子上下左右的四个格子中最多只有一个格子与自己颜色相同,问有多少种涂法?结果$mod1000000007$ 思路:先只考虑一行有多少种涂法 $dp[i][0 ...

  9. Kafka 启动报错java.io.IOException: Can't resolve address.

    阿里云上 部署Kafka 启动报错java.io.IOException: Can't resolve address. 本地调试的,报错 需要在本地添加阿里云主机的 host 映射   linux ...

  10. VScode小白简介

    前言   现在使用Vscode编码的人越来越多,凭借着免费,开源,轻量,跨平台的特点收货了一大批忠实粉丝 最近因项目需要开始使用Vscode,但不知为何,感觉有点力不从心,不知道该怎么用 首先想到去官 ...