新特性解读 | MySQL 8.0.19 支持 DNS SRV
Connector/NET
Connector/ODBC
Connector/J
Connector/Node.js
Connector/Python
-
Connector/C++
for i in `seq 4000 4002`; do
echo "Deploy mysql sandbox $i"
mysqlsh -- dba deploy-sandbox-instance $i --password=root
done
echo "Create innodb cluster..."
mysqlsh root@localhost:4000 -- dba create-cluster cluster01
mysqlsh root@localhost:4000 -- cluster add-instance --recoveryMethod=clone --password=root root@localhost:4001
mysqlsh root@localhost:4000 -- cluster add-instance --recoveryMethod=clone --password=root root@localhost:4002
for i in 6446 6556; do
echo "Bootstrap router $i"
mysqlrouter --bootstrap root@localhost:4000 --conf-use-gr-notifications -d router_$i --conf-base-port $i --name router_$i
sed -i 's/level = INFO/level = DEBUG/g router_$i/mysqlrouter.conf
sh router_$i/stop.sh
sh router_$i/start.sh
done
echo "Install consul..."
brew install consul
consul agent -dev &
echo "Services register..."
consul services register -name router -id router1 -port 6446 -tag rw
consul services register -name router -id router2 -port 6556 -tag rw
echo "Test dns srv..."
dig router.service.consul SRV -p 8600
;; QUESTION SECTION:
;router.service.consul. IN SRV
;; ANSWER SECTION:
router.service.consul. 0 IN SRV 1 1 6556 MBP.node.dc1.consul.
router.service.consul. 0 IN SRV 1 1 6446 MBP.node.dc1.consul.
;; ADDITIONAL SECTION:
MBP.node.dc1.consul. 0 IN A 127.0.0.1
MBP.node.dc1.consul. 0 IN TXT "consul-network-segment="
MBP.node.dc1.consul. 0 IN A 127.0.0.1
MBP.node.dc1.consul. 0 IN TXT "consul-network-segment="
echo "Install dnsmasq..."
brew install dnsmasq
echo 'server=/consul/127.0.0.1#8600' > /usr/local/etc/dnsmasq.d/consul
sudo brew services restart dnsmasq
echo "Test dns forwarding..."
dig router.service.consul SRV
pip install mysql-connector-python
import mysql.connector
cnx = mysql.connector.connect(user='root', password='root', database='mysql_innodb_cluster_metadata', host='router.service.consul', dns_srv=True)
cursor = cnx.cursor()
query = ("select instance_id from v2_this_instance")
cursor.execute(query)
for (instance_id) in cursor:
print("instance id: {}".format(instance_id))
cursor.close()
cnx.close()
关于爱可生
爱可生成立于2003年,依托于融合、开放、创新的数据处理技术和服务能力,为大型行业用户的特定场景提供深度挖掘数据价值的解决方案。
公司持续积累的核心关键技术,覆盖到分布式数据库集群、云数据平台、数据库大体量运管平台、海量数据集成于存储、清洗与治理、人工智能分析挖掘、可视化展现、安全与隐私保护等多个领域。
公司已与多个行业内的专业公司建立了长期伙伴关系,不断促进新技术与行业知识相结合,为用户寻求新的数据驱动的价值增长点。公司已在金融、能源电力、广电、政府等行业取得了众多大型用户典型成功案例,获得了市场的认可和业务的持续增长。
更多详情请访问爱可生官网:
www.actionsky.com