2016-02-29 93 views
2

我有兩個吊艙與kubernetes訪問MySQL:訪問被拒絕用戶根

  • MySQL的
  • .jar文件(用於Java的microService服務器)

這是MySQL的.yaml文件

apiVersion: v1 
kind: Pod 
metadata: 
    name: mysql 
    labels: 
    name: mysql 
spec: 
    containers: 
    - resources: 
     limits : 
      cpu: 0.5 
     image: mysql 
     name: mysql 
     env: 
     - name: MYSQL_ROOT_PASSWORD 
      # change this 
      value: pass 
     ports: 
     - containerPort: 3306 
      name: mysql 
     volumeMounts: 
     - name: mysqlkuber 
      mountPath: /var/lib/mysql 
      readOnly: false 
    volumes: 
    - name: mysqlkuber 
     hostPath: 
     path: /home/adicipta/mysqlkuber 

我使用ip公開pod mysql服務10​​.0.0.67:3306

.jar文件吊艙運行這個表彰

sudo ./kubectl run lingga --image=msf4j 

和我得到這個錯誤

2016-02-29 03:11:08 INFO ClassPathXmlApplicationContext:512 - Refreshing org[email protected]2401f4c3: startup date [Mon Feb 29 03:11:08 GMT 2016]; root of context hierarchy 
2016-02-29 03:11:09 INFO XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [Beans.xml] 
2016-02-29 03:11:10 INFO DefaultListableBeanFactory:603 - Pre-instantiating singletons in org.s[email protected]1753acfe: defining beans [dataSource,hibernateSessionFactoryBean,globalManagerDAO,baseLogicBean,interfaceAccount]; root of factory hierarchy 
2016-02-29 03:11:10 INFO DriverManagerDataSource:153 - Loaded JDBC driver: com.mysql.jdbc.Driver 
2016-02-29 03:11:10 INFO Version:37 - Hibernate Commons Annotations 3.2.0.Final 
2016-02-29 03:11:10 INFO Environment:603 - Hibernate 3.6.10.Final 
2016-02-29 03:11:10 INFO Environment:636 - hibernate.properties not found 
2016-02-29 03:11:10 INFO Environment:814 - Bytecode provider name : javassist 
2016-02-29 03:11:10 INFO Environment:695 - using JDK 1.4 java.sql.Timestamp handling 
2016-02-29 03:11:10 INFO AnnotationBinder:532 - Binding entity from annotated class: com.adins.model.Msuser 
2016-02-29 03:11:10 INFO EntityBinder:530 - Bind entity com.adins.model.Msuser on table msuser 
2016-02-29 03:11:10 INFO Configuration:1676 - Hibernate Validator not found: ignoring 
2016-02-29 03:11:10 INFO AnnotationSessionFactoryBean:780 - Building new Hibernate SessionFactory 
2016-02-29 03:11:10 INFO HibernateSearchEventListenerRegister:75 - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled. 
2016-02-29 03:11:10 INFO ConnectionProviderFactory:173 - Initializing connection provider: org.springframework.orm.hibernate3.TransactionAwareDataSourceConnectionProvider 
2016-02-29 03:11:11 WARN SettingsFactory:140 - Could not obtain connection metadata 
java.sql.SQLException: Access denied for user 'root'@'172.17.0.1' (using password: NO) 
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814) 
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871) 

.jar文件裏面我有一個已經設定的IP來(10.0 bean.xml。 0.67:3306)

我只是不明白爲什麼它不工作

也許有人可以幫我整理出來

和我在數據源代碼

使用kubernetes與搬運工人容器

回答

0

剛纔設置的密碼這個數據源代碼是我的.jar文件

<property name="username" value="root" /> 
<property name="password" value="pass" /> 

它取決於你的數據源的樣子裏面。