TIDB安装

所有机器添加tidb用户,添加sudo权限

useradd tidb

passwd tidb

touch /etc/sudoers.d/tidb

echo 'tidb ALL=(ALL) NOPASSWD: ALL' >/etc/sudoers.d/tidb

ssh添加

su - tidb

ssh-keygen

cat ~/.ssh/id_rsa.pub >~/.ssh/authorized_keys

chmod 600 /home/tidb/.ssh/authorized_keys

ssh-copy-id -i ~/.ssh/id_rsa.pub 127.0.0.1

ssh-copy-id -i ~/.ssh/id_rsa.pub 127.0.0.2

ssh-copy-id -i ~/.ssh/id_rsa.pub 127.0.0.3

安装Ansible及其依赖软件包

(1)安装PIP

yum -y install wget

wget https://download.pingcap.org/pip-rpms.el7.tar.gz

tar -xzvf pip-rpms.el7.tar.gz

cd pip-rpms.el7

chmod u+x install_pip.sh

./install_pip.sh

pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

(2)安装Ansible

wget https://download.pingcap.org/ansible-2.5.0-pip.tar.gz

tar -xzvf ansible-2.5.0-pip.tar.gz

cd ansible-2.5.0-pip/

chmod +x install_ansible.sh

mkdir ~/.pip

vi ~/.pip/pip.conf //更改pip源为国内源
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

pip install paramiko

pip install cryptography

./install_ansible.sh

下载TiDB-Ansible安装包

(1)下载2.0 GA版本

yum -y install git

git clone -b release-2.0 https://github.com/pingcap/tidb-ansible.git

(2)下载TiDB binary

cd tidb-ansible

ansible-playbook local_prepare.yml

(3)复制目录

复制tidb-ansible目录到中控机的/home/tidb目录下,并设置属主为tidb用户。

cp -r tidb-ansible /home/tidb/

chown -R tidb /home/tidb/tidb-ansible

分配机器资源

Tidb

TiDB对应的是Google F1,是一层无状态的SQL层,负责与客户端交互,对客户端体现的是MySQL网络协议,且客户端需要通过一个本地负载均衡器将SQL请求转发到本地或最近的数据中心中的TiDB服务器。TiDB服务器负责解析用户的SQL语句,生成分布式的查询计划,并翻译成底层Key-Value操作发送给TiKV

Pd

TiDB架构采用PD集群来管理整个分布式数据库,PD服务器在TiKV节点之间以Region作为单位进行调度,将部分数据迁移到新添加的节点上,完成集群调度和负载均衡。

Tikv

TiKV则是真正存储数据的地方,对应的是Google Spanner,是一个分布式Key-Value数据库,支持弹性水平扩展、自动的灾难恢复和故障转移,以及ACID跨行事务。

编辑inventory.ini文件,路径为tidb-ansible/inventory.ini,在该文件内进行各个组件的角色分配。

HostTidbPdTikvGrafanaTisparkTidb-ansible
127.0.0.1
127.0.0.2
127.0.0.3
cd /home/tidb/

vi tidb-ansible/inventory.ini

[tidb_servers]
127.0.0.1

[tikv_servers]
127.0.0.1
127.0.0.2
127.0.0.3

[pd_servers]
127.0.0.2

[spark_master]

[spark_slaves]

## Monitoring Part
# prometheus and pushgateway servers
[monitoring_servers]
127.0.0.1

[grafana_servers]
127.0.0.1

# node_exporter and blackbox_exporter servers
[monitored_servers]
127.0.0.1
127.0.0.2
127.0.0.3

[alertmanager_servers]
127.0.0.1

修改 deploy_dir

vi tidb-ansible/inventory.ini

[all:vars]
deploy_dir = /data/deploy

实施部署

确认服务运行用户

tidb-ansible/inventory.ini文件,确保ansible_user项配置为tidb,即使用tidb用户作为服务运行用户

cat tidb-ansible/inventory.ini

## Connection
# ssh via normal user
ansible_user = tidb

确认操作权限配置

[tidb@vm76 tidb-ansible]$ ansible -i inventory.ini all -m shell -a 'whoami'
127.0.0.1 | SUCCESS | rc=0 >>
tidb

127.0.0.2 | SUCCESS | rc=0 >>
tidb

127.0.0.3 | SUCCESS | rc=0 >>
tidb


[tidb@vm76 tidb-ansible]$ ansible -i inventory.ini all -m shell -a 'whoami' -b
127.0.0.1 | SUCCESS | rc=0 >>
root

127.0.0.2 | SUCCESS | rc=0 >>
root

127.0.0.3 | SUCCESS | rc=0 >>
root

初始化系统环境,修改内核参数

vi bootstrap.yml

# -{ role: check_system_optional, when: not dev_mode|default(false) }…

#-{ role: machine_benchmark, when: not dev_mode|default(false) }…

部署TiDB集群软件

ansible-playbook deploy.yml

安装Grafana

sudo yum install fontconfig open-sans-fonts

启动TiDB集群

ansible-playbook start.yml

连接测试

[tidb@vm76 tidb-ansible]$ mysql -u root -h 127.0.0.1 -P 4000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.10-TiDB-v2.0.11 MySQL Community Server (Apache License 2.0)

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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MySQL [(none)]> 

访问监控平台

http://127.0.0.1:3000

admin admin
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值