У меня возникли проблемы при подключении к экземпляру mysql с помощью приложения go с использованием стандартного пакета. Это моя строка подключения/журналgo-mysql соединение отказалось при подключении к kubernetes mysql service
[13 Nov 16 13:53 +0000] [INFO] connecting to MySQL.. root:[email protected](a-mysql-0:3340)/db?charset=utf8&parseTime=True&loc=Local
2016/11/13 13:53:25 dial tcp 10.108.1.35:3340: getsockopt: connection refused
Я попытался
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
вот как я делаю подключение, только основные, с конкатенации только
db, err := sql.Open("mysql", "root:[email protected](a-mysql-0:3340)/db?charset=utf8&parseTime=True&loc=Local")
if err != nil {
log.Fatal(err)
}
Я могу свистеть обслуживание , подключитесь к нему с помощью mysql-клиента из другого контейнера.
# can connect without port for service
/# mysql -u root -h a-mysql-0 -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.16 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]> Ctrl-C -- exit!
Aborted
# can't' connect with port for service
/# mysql -u root -h a-mysql-0:3340 -p
Enter password:
ERROR 2005 (HY000): Unknown MySQL server host 'a-mysql-0:3340' (-3)
и MySQL-служба
➜ stg git:(develop) ✗ kubectl describe svc a-mysql-0
Name: a-mysql-0
Namespace: default
Labels: name=a-mysql-0
tier=database
type=mysql
Selector: name=a-mysql-0,tier=database
Type: ClusterIP
IP: None
Port: a-mysql-0 3340/TCP
Endpoints: 10.108.1.35:3340
Session Affinity: None
No events.
Что я пропустил или разрешение?
'getsockopt' подразумевает, что нет реальной связи с хостом mysql. У вас есть сетевая сеть? – jaxxstorm
pod подключение к хосту mysql имеет настройку сети, поскольку он может подключаться к другим службам и другим db, только mysql не может подключиться. – Hokutosei
вам следует скопировать сюда код, в котором вы открыты() при подключении –