安装部署:
注意:单机环境配置只有一个pd-server ,一个tikv-server 和一个tidb-server,无法进行扩容和缩容配置
操作系统环境:
[root@tidb-node200 tidb]# uname -a
Linux tidb-node200 4.4.219-1.el7.elrepo.x86_64 #1 SMP Sun Apr 12 16:13:06 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@tidb-node200 tidb]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
主机IP: 172.16.1.200 需要能连接外网安装软件
mysql客户端安装:
centos7:
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql-community-client.x86_64
ubuntu16.04:
apt-get install mysql-client mysql-server
下载安装tidb
wget http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz
mkdir -p /data/pd
mkdir -p /data/tikv
mv tidb-latest-linux-amd64.tar.gz /usr/local/
cd /usr/local/
tar xf tidb-latest-linux-amd64.tar.gz
ln -s tidb-latest-linux-amd64 tidb
测试服务是否正常:
cd /usr/local/tidb
./bin/pd-server --data-dir=/data/pd --log-file=pd.log &
./bin/tikv-server --pd="127.0.0.1:2379" --data-dir=/data/tikv --log-file=tikv.log &
./bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=tidb.log &
启动停止服务脚本:
touch /etc/init.d/tidbd
chmod 755 /etc/init.d/tidbd
chkconfig tidbd on
[root@tidb-node200 tidb]# cat /etc/init.d/tidbd
#! /bin/bash
#
# tidbd Bring up/down tidb
#
# chkconfig: 2345 10 90
# description: tidb daemon
# start at boot time.
case "$1" in
start)
/usr/local/tidb/bin/pd-server --data-dir=/data/pd --log-file=pd.log &
/usr/local/tidb/bin/tikv-server --pd="127.0.0.1:2379" --data-dir=/data/tikv --log-file=tikv.log &
/usr/local/tidb/bin/tidb-server --store=tikv --path="127.0.0.1:2379" --log-file=tidb.log &
if [ $? = 0 ]; then
echo "Start Tidb Server OK"
else
echo "Stop Tidb fail"
fi
;;
stop)
ps -ef | grep "/bin/tidb-server" | grep -Ev grep | awk '{print $2}'| xargs kill -9
ps -ef | grep "/bin/tikv-server" | grep -Ev grep | awk '{print $2}'| xargs kill -9
ps -ef | grep "/bin/pd-server" | grep -Ev grep | awk '{print $2}'| xargs kill -9
if [ $? = 0 ]; then
echo "Stop Tidb Server OK"
else
echo "Stop Tidb fail"
fi
;;
restart)
cd "$CWD"
$0 stop
$0 start
;;
status)
ps -ef | grep "/bin/tidb-server" | grep -Ev grep
ps -ef | grep "/bin/tikv-server" | grep -Ev grep
ps -ef | grep "/bin/pd-server" | grep -Ev grep
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 2
esac
查看服务进程:
[root@tidb-node200 tidb]# ps -ef | grep tidb
root 8982 1 14 11:03 pts/0 00:00:00 /usr/local/tidb/bin/pd-server --data-dir=/data/pd --log-file=pd.log
root 8983 1 1 11:03 pts/0 00:00:00 /usr/local/tidb/bin/tikv-server --pd=127.0.0.1:2379 --data-dir=/data/tikv --log-file=tikv.log
root 8984 1 5 11:03 pts/0 00:00:00 /usr/local/tidb/bin/tidb-server --store=tikv --path=127.0.0.1:2379 --log-file=tidb.log
root 9025 8662 0 11:03 pts/0 00:00:00 grep --color=auto tidb
查看服务端口:
[root@tidb-node200 tidb]# netstat -lntp
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:36007 0.0.0.0:* LISTEN 7785/pd-server
tcp 0 0 127.0.0.1:2379 0.0.0.0:* LISTEN 7785/pd-server
tcp 0 0 127.0.0.1:2380 0.0.0.0:* LISTEN 7785/pd-server
tcp 0 0 127.0.0.1:33200 0.0.0.0:* LISTEN 7785/pd-server
tcp 0 0 127.0.0.1:20180 0.0.0.0:* LISTEN 7786/tikv-server
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 8417/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 8577/master
tcp6 0 0 :::10080 :::* LISTEN 7787/tidb-server
tcp6 0 0 :::4000 :::* LISTEN 7787/tidb-server
tcp6 0 0 127.0.0.1:20160 :::* LISTEN 7786/tikv-server
tcp6 0 0 :::22 :::* LISTEN 8417/sshd
tcp6 0 0 ::1:25 :::* LISTEN 8577/master
通过mysql客户端登录数据库:
mysql -h 127.0.0.1 -P 4000 -u root
创建alias
cat /root/.bash_profile
alias 'tidb'='mysql -uroot -p'' -h172.16.1.200 -P 4000'
功能测试:
创建用户
mysql> create user 'tidb'@'%' identified by 'tidb';
Query OK, 0 rows affected (0.07 sec)
mysql> grant all privileges on *.* to 'tidb'@'%';
Query OK, 0 rows affected (0.04 sec)
flush privileges;
以上就完成了TiDB-5.0.1的单主机测试环境部署
2021-10-17
TiDB-V5.0.1-单机测试环境部署详解
评论
发表评论
姓 名: