声明:此方法不太常规,在生产环境操作前一定要充分验证
stop TiDB
ansible-playbook stop.yml-
配置hosts文件
在TiDB集群的所有节点修改/etc/hosts,添加预定义的hostname映射关系$ more /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.0.101 server.tidb.com 192.168.0.102 kv1.tidb.com 192.168.0.103 kv2.tidb.com 192.168.0.104 kv3.tidb.com
-
修改inventory.ini
将inventory.ini配置文件中的ip都换成对应的hostname# TiDB Cluster Part [tidb_servers] #192.168.0.101 server.tidb.com [tikv_servers] #TiKV1-1 ansible_host=192.168.0.102 deploy_dir=/data1/deploy tikv_port=20171 labels="host=tikv_1" #TiKV2-1 ansible_host=192.168.0.103 deploy_dir=/data1/deploy tikv_port=20171 labels="host=tikv_2" #TiKV3-1 ansible_host=192.168.0.104 deploy_dir=/data1/deploy tikv_port=20171 labels="host=tikv_3" TiKV1-1 ansible_host=kv1.tidb.com deploy_dir=``/data1/deploy` `tikv_port=20171 labels=``"host=tikv_1" TiKV2-1 ansible_host=kv1.tidb.com deploy_dir=``/data1/deploy` `tikv_port=20171 labels=``"host=tikv_2" TiKV3-1 ansible_host=kv1.tidb.com deploy_dir=``/data1/deploy` `tikv_port=20171 labels=``"host=tikv_3" [pd_servers] #192.168.0.101 server.tidb.com # Monitoring Part [monitoring_servers] #192.168.0.101 server.tidb.com [grafana_servers] #192.168.0.101 server.tidb.com
清空prometheus-XXX.data.metrics
mv prometheus2.0.0.data.metrics prometheus2.0.0.data.metrics.bak
- 重新部署
$ ansible-playbook deploy.yml
- 修改PD启动脚本
PD的启动脚本中,client-urls和peer-urls不能使用域名,都修改成0.0.0.0
exec bin/pd-server \
--name="pd1" \
--client-urls="[http://0.0.0.0:2379](http://0.0.0.0:2379/)" \
--advertise-client-urls="[http://server.tidb.com:2379](http://server.tidb.com:2379/)" \
--peer-urls="[http://0.0.0.0:2380](http://0.0.0.0:2380/)" \
--advertise-peer-urls="[http://server.tidb.com:2380](http://server.tidb.com:2380/)" \
--data-dir="/home/tidb/deploy/data.pd" \
--initial-cluster="pd1=[http://server.tidb.com:2380](http://server.tidb.com:2380/)" \
--config=conf/pd.toml \
--log-file="/home/tidb/deploy/log/pd.log" 2>> "/home/tidb/deploy/log/pd_stderr.log"
- 重新启动数据库,验证
ansible-playbook stop.yml