创建用户
##创建用户
adduser tidb
#设置密码
passwd tidb
cat >> /etc/sudoers << "EOF"
tidb ALL=(ALL) NOPASSWD:ALL
EOF
切换用户
[root@jeames ~]# su - tidb
执行命令,一直按回车键就行
[tidb@jeames ~]$ ssh-keygen -t rsa
解压安装包安装
1.切换到tidb用户,新建以下两个目录
[tidb@k8s-master3 ~]$ mkdir tidb-deploy
[tidb@k8s-master3 ~]$ mkdir tidb-data
chmod +x tidb-community*
tar -zxvf tidb-community-server-v4.0.11-linux-amd64.tar.gz
3.执行instal文件
[tidb@k8s-master3 ~]$ sh /home/tidb/tidb-community-server-v4.0.11-linux-amd64/local_install.sh
配置初始化参数文件
YAML、YML在线编辑器(格式化校验)-BeJSON.com
cat >> /home/tidb/topology.yaml << "EOF"
global:
user: "tidb"
ssh_port: 22
deploy_dir: "/home/tidb/tidb-deploy"
data_dir: "/home/tidb/tidb-data"
server_configs: {}
pd_servers:
- host: 192.168.56.17
tidb_servers:
- host: 192.168.56.17
tikv_servers:
- host: 192.168.56.17
monitoring_servers:
- host: 192.168.56.17
grafana_servers: - host: 192.168.56.17
alertmanager_servers:
- host: 192.168.56.17
EOF
more /home/tidb/topology.yaml
部署版本为v4.0.11 ,其他版本可以执行 tiup list tidb 获取
部署集群
tiup cluster deploy tidb-test v4.0.11 ./topology.yaml --user tidb -p
输入tidb用户密码
启动集群
tiup cluster start tidb-test
检查集群状态,命令:tiup cluster display tidb-test
找一个pd 节点登录 [前提安装好mariadb 客户端工具有MySQL命令]
mysql -uroot -h192.168.56.17 -P 4000
mysql> SET password = password("[email protected]");
Query OK, 0 rows affected (0.01 sec)
mysql> flush PRIVILEGES;
推出在登录:
mysql -uroot -h192.168.56.17 -P 4000 [email protected]
插入表测试:
create database yangyang;
use yangyang;
创建一个my_user表:
CREATE TABLE `my_user` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT,
`account` varchar(255) DEFAULT NULL,
`passwd` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
插入数据:
INSERT INTO `my_user` VALUES ('1', 'admin', 'admin');
INSERT INTO `my_user` VALUES ('2', 'pu', '12345');
INSERT INTO `my_user` VALUES ('3', 'system', 'system');
INSERT INTO `my_user` VALUES ('4', 'zxh', 'zxh');
INSERT INTO `my_user` VALUES ('5', 'test', 'test');
INSERT INTO `my_user` VALUES ('6', 'pudong', 'pudong');
INSERT INTO `my_user` VALUES ('7', 'qiqi', 'qiqi');
或者dbeaver
打开web:
http://192.168.56.17:2379/dashboard/#/overview
用户名:root
密码:[email protected]
打开prometheus:
http://192.168.56.17:9090/graph
grafana 监控打开:
http://192.168.56.17:3000/?orgId=1
默认用户名密码:
admin/[email protected]
关闭数据库
tiup cluster stop tidb-test