2023/12/06

容器container未啟動時,如何查看log


在Azure Kubernetes Service (AKS) 中,如果容器沒有正常啟動,您可以透過幾種方式來檢查記錄並找出可能的原因。

  1. 使用Azure Portal查看Pod記錄

    • 在Azure Portal中,導航到您的AKS服務。

    • 在左側選單中找到「Kubernetes資源」,並選擇「Pods」。

    • 從列表中找到您關心的Pod,點擊它。

    • 在Pod的詳細頁面中,會有「記錄檔」的選項,點擊它即可查看該Pod的輸出記錄。

  2. 使用kubectl查看Pod記錄

    • 打開命令行介面。

    • 使用以下命令來查看Pod的記錄:

      kubectl logs <Pod名稱> --namespace <命名空間>
    • 如果Pod中運行了多個容器,您可能需要指定容器名稱:

      kubectl logs <Pod名稱> --namespace <命名空間> -c <容器名稱>
    • 這將會顯示該Pod的記錄,通常可以從中找到錯誤訊息和其他診斷信息。

  3. 檢查Pod的狀態

    • 使用以下命令來獲取Pod的詳細狀態資訊,它可能包含錯誤訊息:

      kubectl describe pod <Pod名稱> --namespace <命名空間>
  4. 使用Azure監視和記錄檔功能

    • 在Azure Portal的AKS介面中,您可以使用「監視」和「診斷設定」來查看和設定記錄檔的收集。

    • 配置「診斷設定」來收集特定的記錄檔和性能指標。

    • 使用「監視」功能查看指標和記錄檔分析。

請根據您的需要選擇最方便的方法來獲取記錄並分析您的容器未能啟動的原因。

2023/11/11

在Azure上建立微服務應用程式的前置作業


前置作業

  1. 確認已在開發環境安裝Docker Desktop

  2. 確認已安裝Azure CLI於開發電腦中

  3. 確認在Azure已開通以下服務:容器登錄、Kubernetes服務

開立資源群組(若已建立,則可不需要此步驟)

在搜尋方框中,輸入 “資源群組”,並進入資源群組的頁面中

點選 “建立”



輸入 “資源群組” 名稱後,按 “下一步:標籤”







2020/04/11

Error: No default constructor found; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector


Main:
package com.atguigu.spring.beans.properties;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) throws SQLException {
ApplicationContext ctx = new ClassPathXmlApplicationContext("beans-properties.xml");
DataSource dataSource = (DataSource) ctx.getBean("dataSource");
System.out.println(dataSource.getConnection());
}
}
xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="root"></property>
<property name="password" value="1230"></property>
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql:///test"></property>
</bean>
</beans>
報錯:
四月 11, 2020 9:29:54 下午 org.springframework.context.support.ClassPathXmlApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [beans-properties.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mchange.v2.c3p0.ComboPooledDataSource]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [beans-properties.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mchange.v2.c3p0.ComboPooledDataSource]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1320)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:85)
at com.atguigu.spring.beans.properties.Main.main(Main.java:14)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mchange.v2.c3p0.ComboPooledDataSource]: No default constructor found; nested exception is java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:83)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312)
... 13 more
Caused by: java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:78)
... 14 more
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.ser.Indirector
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 19 more