奈学教育大数据百万架构师学习笔记分享

string和byte类型互相转换

  返回  

001_TiDB单机版安装

2021/7/20 23:57:25 浏览:

使用 TiUP Playground 快速部署本地测试环境

下载并安装TiUP

[root@tidb-01 ~]# curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 7037k  100 7037k    0     0  4727k      0  0:00:01  0:00:01 --:--:-- 4732k
WARN: adding root certificate via internet: https://tiup-mirrors.pingcap.com/root.json
You can revoke this by remove /root/.tiup/bin/7b8e153f2e2d0928.root.json
Successfully set mirror to https://tiup-mirrors.pingcap.com
Detected shell: bash
Shell profile:  /root/.bash_profile
/root/.bash_profile has been modified to add tiup to PATH
open a new terminal or source /root/.bash_profile to use it
Installed path: /root/.tiup/bin/tiup
===============================================
Have a try:     tiup playground
===============================================

声明全局环境变量

[root@tidb-01 ~]# source .bash_profile

注:TiUP 安装完成会提示对应的 profile 文件的绝对路径,以下 source 操作需要根据实际位置进行操作

在当前 session 执行以下命令启动集群

[root@tidb-01 ~]# tiup playground

### 前台运行结果

The component `playground` version  is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/playground-v1.5.3-linux-amd64.tar.gz 7.51 MiB / 7.51 MiB 100.00% 5.36 MiB/s           
Starting component `playground`: /root/.tiup/components/playground/v1.5.3/tiup-playground
Using the version v5.1.0 for version constraint "".

If you'd like to use a TiDB version other than v5.1.0, cancel and retry with the following arguments:
    Specify version manually:   tiup playground <version>
    Specify version range:      tiup playground ^5
    The nightly version:        tiup playground nightly

Playground Bootstrapping...
The component `prometheus` version v5.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/prometheus-v5.1.0-linux-amd64.tar.gz 39.84 MiB / 39.84 MiB 100.00% 9.80 MiB/s         
download https://tiup-mirrors.pingcap.com/grafana-v5.1.0-linux-amd64.tar.gz 54.26 MiB / 54.26 MiB 100.00% 7.64 MiB/s            
Start pd instance
The component `pd` version v5.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/pd-v5.1.0-linux-amd64.tar.gz 39.54 MiB / 39.54 MiB 100.00% 6.71 MiB/s                 
Start tikv instance
The component `tikv` version v5.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tikv-v5.1.0-linux-amd64.tar.gz 162.12 MiB / 162.12 MiB 100.00% 6.64 MiB/s             
Start tidb instance
The component `tidb` version v5.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tidb-v5.1.0-linux-amd64.tar.gz 42.12 MiB / 42.12 MiB 100.00% 6.60 MiB/s               
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
127.0.0.1:4000 ... Done
Start tiflash instance
The component `tiflash` version v5.1.0 is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/tiflash-v5.1.0-linux-amd64.tar.gz 404.82 MiB / 404.82 MiB 100.00% 7.02 MiB/s          
Waiting for tiflash instances ready
127.0.0.1:3930 ... Done
CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --host 127.0.0.1 --port 4000 -u root -p (no password) --comments
To view the dashboard: http://127.0.0.1:2379/dashboard
PD client endpoints: [127.0.0.1:2379]
To view the Prometheus: http://127.0.0.1:9090
To view the Grafana: http://127.0.0.1:3000

查看进程

[root@tidb-01 ~]# yum -y install net-tools
[root@tidb-01 ~]# netstat -tlunp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      8368/grafana-server 
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1472/master         
tcp        0      0 0.0.0.0:8123            0.0.0.0:*               LISTEN      8524/tiflash        
tcp        0      0 127.0.0.1:45727         0.0.0.0:*               LISTEN      8380/pd-server      
tcp        0      0 127.0.0.1:4000          0.0.0.0:*               LISTEN      8512/tidb-server    
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      8356/prometheus     
tcp        0      0 0.0.0.0:20292           0.0.0.0:*               LISTEN      8524/tiflash        
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      8524/tiflash        
tcp        0      0 0.0.0.0:8234            0.0.0.0:*               LISTEN      8524/tiflash        
tcp        0      0 127.0.0.1:2379          0.0.0.0:*               LISTEN      8380/pd-server      
tcp        0      0 127.0.0.1:2380          0.0.0.0:*               LISTEN      8380/pd-server      
tcp        0      0 127.0.0.1:20180         0.0.0.0:*               LISTEN      8396/tikv-server    
tcp        0      0 127.0.0.1:33684         0.0.0.0:*               LISTEN      8380/pd-server      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1043/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1472/master         
tcp6       0      0 127.0.0.1:3930          :::*                    LISTEN      8524/tiflash        
tcp6       0      0 :::10080                :::*                    LISTEN      8512/tidb-server    
tcp6       0      0 127.0.0.1:20160         :::*                    LISTEN      8396/tikv-server    
tcp6       0      0 :::20170                :::*                    LISTEN      8524/tiflash        
tcp6       0      0 :::22                   :::*                    LISTEN      1043/sshd           
tcp6       0      0 :::9527                 :::*                    LISTEN      8348/tiup-playgroun 
udp        0      0 0.0.0.0:68              0.0.0.0:*                           864/dhclient

访问 TiDB 数据库

  1. 使用 TiUP client 连接 TiDB
[root@tidb-01 ~]# tiup client

The component `client` version  is not installed; downloading from repository.
download https://tiup-mirrors.pingcap.com/client-v1.5.3-linux-amd64.tar.gz 4.59 MiB / 4.59 MiB 100.00% 9.60 MiB/s                                 
Starting component `client`: /root/.tiup/components/client/v1.5.3/tiup-client
Connected with driver mysql (5.7.25-TiDB-v5.1.0)
Type "help" for help.

my:root@127.0.0.1:4000=> show databases;
      Database      
--------------------
 INFORMATION_SCHEMA 
 METRICS_SCHEMA 
 PERFORMANCE_SCHEMA 
 mysql 
 test 
(5 rows)
  1. 使用 MySQL 客户端连接 TiDB
# 安装mysql客户端
[root@tidb-01 ~]# yum -y install mariadb

# 访问
[root@tidb-01 ~]# mysql -h 127.0.0.1 -P 4000 -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.25-TiDB-v5.1.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible

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 |
| METRICS_SCHEMA     |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
5 rows in set (0.02 sec)

指定监听地址

[root@tidb-01 ~]# tiup playground --host 192.168.74.138

Starting component `playground`: /root/.tiup/components/playground/v1.5.3/tiup-playground --host 192.168.74.138
Using the version v5.1.0 for version constraint "".

If you'd like to use a TiDB version other than v5.1.0, cancel and retry with the following arguments:
    Specify version manually:   tiup playground <version>
    Specify version range:      tiup playground ^5
    The nightly version:        tiup playground nightly

Playground Bootstrapping...
Start pd instance
Start tikv instance
Start tidb instance
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
Waiting for tidb instances ready
192.168.74.138:4000 ... Done
Start tiflash instance
Waiting for tiflash instances ready
192.168.74.138:3930 ... Done
CLUSTER START SUCCESSFULLY, Enjoy it ^-^
To connect TiDB: mysql --host 192.168.74.138 --port 4000 -u root -p (no password) --comments
To view the dashboard: http://192.168.74.138:2379/dashboard
PD client endpoints: [192.168.74.138:2379]
To view the Prometheus: http://192.168.74.138:9090
To view the Grafana: http://192.168.74.138:3000

通过http://192.168.74.138:9090 访问 TiDB 的 prometheus 管理界面

在这里插入图片描述

通过 http://192.168.74.138::2379/dashboard 访问 TiDB Dashboard 页面,默认用 户名为 root,密码为空

在这里插入图片描述
在这里插入图片描述

注:若浏览器不能访问,请确认防火墙是否关闭

[root@tidb-01 ~]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2021-07-20 22:54:46 CST; 45min ago
     Docs: man:firewalld(1)
 Main PID: 717 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─717 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid

Jul 20 22:54:45 tidb-01 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jul 20 22:54:46 tidb-01 systemd[1]: Started firewalld - dynamic firewall daemon.
Jul 20 22:54:46 tidb-01 firewalld[717]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release...ling it now.
Hint: Some lines were ellipsized, use -l to show in full.

[root@tidb-01 ~]# systemctl stop firewalld.service
[root@tidb-01 ~]# systemctl status firewalld.service
[root@tidb-01 ~]# systemctl disable firewalld.service

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@tidb-01 ~]# 

可以通过执行以下步骤来清理群集

[root@tidb-01 ~]# tiup clean --all

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号