ansible-tidb3.0安装(离线版)

环境:centos7.6

1、配置ntp时间同步服务

https://www.cnblogs.com/wukc/p/13279847.html

2、创建用户tidb

useradd tidb
echo your-passwd|passwd --stdin tidb

3、配置tidb用户sudo免密码,将tidb ALL=(ALL) NOPASSWD: ALL添加到文件末尾即可。

chmod 755 /etc/sudoers
cat >> /etc/sudoers <<EOF
tidb ALL=(ALL) NOPASSWD: ALL
EOF
chmod 440 /etc/sudoers

4、时区修改
timedatectl set-timezone Asia/Shanghai
5、安装bash补全命令
yum -y install bash-completion

6、磁盘挂载

[root@host-172-21-136-198 ~]# lsblk       #查看磁盘
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda             252:0    0  100G  0 disk 
├─vda1          252:1    0  500M  0 part /boot
└─vda2          252:2    0 99.5G  0 part 
  ├─centos-root 253:0    0 91.5G  0 lvm  /
  └─centos-swap 253:1    0    8G  0 lvm  [SWAP]
vdb             252:16   0  500G  0 disk
[root@host-172-21-136-198 ~]# pvcreate /dev/vdb     #创建pv
  Physical volume "/dev/vdb" successfully created.
[root@host-172-21-136-198 ~]# vgcreate vg_data /dev/vdb  #创建vg
  Volume group "vg_data" successfully created
[root@host-172-21-136-198 ~]# lvcreate -l 100%VG -n lv_tidb vg_data   #创建lv
  Logical volume "lv_tidb" created.
[root@host-172-21-136-198 ~]# mkdir /data1                           #建挂载盘
[root@host-172-21-136-198 ~]# mkfs.ext4 /dev/mapper/vg_data-lv_tidb   #对lv盘镜像ext4格式化
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
32768000 inodes, 131070976 blocks
6553548 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2279604224
4000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done     

[root@host-172-21-136-198 ~]# echo "UUID=`lsblk -f|grep vg_data-lv_tidb|awk ‘{print $3}‘` /data1 ext4 defaults,nodelalloc,noatime 0 2" >> /etc/fstab  #配置开机挂载
[root@host-172-21-136-198 ~]# mount -a   #进行磁盘挂载
[root@host-172-21-136-198 ~]# df /data1
Filesystem                  1K-blocks  Used Available Use% Mounted on
/dev/mapper/vg_data-lv_tidb 515924224 73752 489619896   1% /data1
[root@host-172-21-136-197 ~]# chown -R tidb:tidb /data1 #建data1目录分给tidb

7、上传pip、ansible、tidb软件到部署机器

文件下载:链接: https://pan.baidu.com/s/1JPsL4fJdLaHMFp6L_xji1w 提取码: uu4v

8、pip安装

tar -xzvf ansible-system-rpms.el7.tar.gz && cd ansible-system-rpms.el7 
chmod u+x install_ansible_system_rpms.sh && \
./install_ansible_system_rpms.sh
 安装完成后,可通过 pip -V 验证 pip 是否安装成功:
 #pip -V
 pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

9、离线安装 Ansible 及相关依赖:

wget https://download.pingcap.org/ansible-2.5.0-pip.tar.gz -P /tidb
tar -xzvf ansible-2.5.0-pip.tar.gz && \
cd ansible-2.5.0-pip/ && chmod u+x install_ansible.sh && \
./install_ansible.sh
   安装完成后,可通过 ansible --version 查看版本:
   ansible --version

10、在中控机上配置部署机器 tidb的SSH(tidb、root都配置一下)

 ssh-keygen   #一直回车

ssh-copy-id tidb@172.21.136.197  #配置免密登录(几台机器复制几个)

11、修改ansible的host文件

ansible-tidb3.0安装(离线版)
tar -xvf tidb-ansible.tar && cd  tidb-ansible && vi hosts.ini
[servers]
172.21.136.197
172.21.136.198
172.21.136.199
172.21.136.200
172.21.136.201
172.21.136.202
172.21.136.203

[all:vars]
username = tidb
ntp_server = 172.21.136.197  #ntp服务器地址
View Code

12、编辑 inventory.ini 文件,分配机器资源

ansible-tidb3.0安装(离线版)
## TiDB Cluster Part
[tidb_servers]
172.21.136.198
172.21.136.199


[tikv_servers]
172.21.136.201
172.21.136.202
172.21.136.203

[pd_servers]
172.21.136.198
172.21.136.199
172.21.136.200

[spark_master]

[spark_slaves]

[lightning_server]

[importer_server]

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

[grafana_servers]
172.21.136.197

# node_exporter and blackbox_exporter servers
[monitored_servers]
172.21.136.197
172.21.136.198
172.21.136.199
172.21.136.200
172.21.136.201
172.21.136.202
172.21.136.203

[alertmanager_servers]
172.21.136.197

[kafka_exporter_servers]

## Binlog Part
[pump_servers]

[drainer_servers]

## Group variables
[pd_servers:vars]
# location_labels = ["zone","rack","host"]

## Global variables
[all:vars]
deploy_dir = /data1/deploy
View Code

13、安装前检查

执行以下命令,如果所有 server 均返回 tidb,表示 SSH 互信配置成功:
ansible -i inventory.ini all -m shell -a whoami
执行以下命令,如果所有 server 均返回 root,表示 tidb 用户 sudo 免密码配置成功。
ansible -i inventory.ini all -m shell -a whoami -b
初始化系统环境,修改内核参数。
yum -y install yum-utils    #需要安装yum工具包
ansible-playbook bootstrap.yml
ansible-playbook bootstrap.yml --extra-vars "dev_mode=True"  #跳过磁盘检测

14、安装tidb

部署 TiDB 集群软件。
ansible-playbook deploy.yml
ansible-tidb3.0安装(离线版)

15、启动tidb

启动 TiDB 集群。
ansible-playbook start.yml

16、验证

安装客户端进行验证
 mysql -h 172.21.36.198 -P 4000 -u root -D test
登录http://172.21.36.197:3000 ,用户名密码:上方inventory.ini配置文件中

17、修改root密码

set password for root@‘%‘ = password(123);

 

ansible-tidb3.0安装(离线版)

上一篇:MySQL基础_视图


下一篇:Linux-MongoDB基础操作