InnoDB Cluster에 대해 MySQL Router bootstrap
MySQLRouter 및 Proxy명령어
# Generates config from metadata and creates the router account; --user is required when run as root
mysqlrouter --bootstrap icadmin@db1:3306 --directory /etc/mysqlrouter/prod --account routeruser --account-create if-not-exists --name router01 --conf-bind-address 0.0.0.0 --user mysqlrouter
/etc/mysqlrouter/prod/start.sh
# Ports: 6446 RW, 6447 RO, 6450 RW split (classic); 6448 / 6449 X protocol
mysql -h app-host -P 6446 -u app -p -e "SELECT @@hostname"
mysql -h app-host -P 6447 -u app -p -e "SELECT @@hostname"
mysqlsh icadmin@db1:3306 -- cluster list-routers하는 일
Router를 클러스터 메타데이터에 등록하고 계정과 구성을 생성한다. 애플리케이션은 RW 포트로 현재 primary에, RO 포트로 secondary에 round-robin으로 접근한다.
사용 시점
InnoDB Cluster / ClusterSet / ReplicaSet 앞에 투명한 페일오버 계층을 둘 때. 일반적으로 애플리케이션 서버마다 Router 하나.
주의
Router는 stateless다. 애플리케이션 옆에서 실행하면 단일 장애 지점을 피할 수 있지만 중앙 Router 하나로는 그렇지 않다. bootstrap 계정은 bootstrap 중에만 사용되며 Router는 자체 계정(routeruser)으로 메타데이터를 읽는다. 토폴로지 변경은 재bootstrap 없이 metadata cache로 인식한다. RW split 포트(6450)는 트랜잭션 내 읽기를 primary로, 나머지를 secondary로 보내므로 read-your-writes를 기대하는 애플리케이션에 주의한다. Router 버전은 클러스터의 MySQL 서버보다 오래되어서는 안 된다.