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




2018/01/04

ValueError: Masked arrays must be 1-D

週未的時候買了一本 "Python入手+演算法" 的書
為了確認相關的演算法函數庫,執行書本中的mytest1.py程式
結果得到以下的錯誤訊息:
Traceback (most recent call last):
  File "D:\python_learning\mytest1_1.py", line 13, in
    plt.scatter(dataMat[0],dataMat[1],c='red',marker='o')
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 3378, in scatter
    edgecolors=edgecolors, data=data, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 1717, in inner
    return func(ax, *args, **kwargs)
  File "C:\Python27\lib\site-packages\matplotlib\axes\_axes.py", line 3996, in scatter
    x, y, s, c, colors, edgecolors, linewidths)
  File "C:\Python27\lib\site-packages\matplotlib\cbook\__init__.py", line 1640, in delete_masked_points
    raise ValueError("Masked arrays must be 1-D")
ValueError: Masked arrays must be 1-D

經由google查詢後,得到scatter中需要放的是array
原始碼及解法如下
改完後就可以執行了


# -*- coding: utf-8 -*-
# Filename : mytest1.py

import numpy as np
from numpy import *
import matplotlib.pyplot as plt

dataSet = [[-0.017612,14.053064], [-1.395634,4.662541],[-0.752157
,6.538620],[-1.322371,7.152853],[0.423363,11.054677],[0.406704
,7.067335],[0.667394,12.741452],[-2.460150,6.866805],[0.569411
,9.548755],[-0.026632,10.427743],[0.850433,6.920334],[1.347183
,13.175500],[1.176813,3.167020],[-1.781871,9.097953]]

dataMat = mat(dataSet).T
#plt.scatter(dataMat[0],dataMat[1],c='red', market='o')   #原始代碼
plt.scatter(array(dataMat[0]),array(dataMat[1]),c='red',marker='o')     #修改後代碼

X = np.linspace(-2,2,100)
Y = 2.8*X+9

plt.plot(X,Y)
plt.show()

執行結果為:

2017/09/17

安裝 .whl 檔

pip install setuptools-36.5.0-py2.py3-none-any.whl

Installing Hadoopy


git clone https://github.com/bwhite/hadoopy.git
cd hadoopy
sudo python setup.py install

hadoopy/_main.c:4:20: fatal error: Python.h: 沒有此一檔案或目錄

先安裝
sudo apt-get install python-dev


hduser@master:~/hadoopy$ sudo yum install python-devel 没有已启用的仓库。


hduser@master:~/hadoopy$ sudo yum install python-devel
没有已启用的仓库。
执行 "yum repolist all" 查看您拥有的仓库。
您可以用 yum-config-manager --enable <仓库名> 来启用仓库
hduser@master:~/hadoopy$ yum-config-manager --enable
程式 'yum-config-manager' 目前尚未安裝。 您可以由輸入以下內容安裝:
sudo apt-get install yum-utils
hduser@master:~/hadoopy$ sudo apt-get install yum-utils
正在讀取套件清單... 完成
正在重建相依關係        
正在讀取狀態資料... 完成
下列的額外套件將被安裝:
  python-iniparse
下列【新】套件將會被安裝:
  python-iniparse yum-utils
升級 0 個,新安裝 2 個,移除 0 個,有 318 個未被升級。
需要下載 108 kB 的套件檔。
此操作完成之後,會多佔用 516 kB 的磁碟空間。
Do you want to continue? [Y/n] y
下載:1 http://ubuntu.cs.nctu.edu.tw/ubuntu/ trusty/universe python-iniparse all 0.4-2.1build1 [21.5 kB]
下載:2 http://ubuntu.cs.nctu.edu.tw/ubuntu/ trusty/universe yum-utils all 1.1.31-2 [86.6 kB]
取得 108 kB 用了 0秒 (206 kB/s)
選取了原先未選的套件 python-iniparse。
(讀取資料庫 ... 目前共安裝了 178600 個檔案和目錄。)
準備解開 .../python-iniparse_0.4-2.1build1_all.deb ...
解開 python-iniparse (0.4-2.1build1) 中...
選取了原先未選的套件 yum-utils。
準備解開 .../yum-utils_1.1.31-2_all.deb ...
解開 yum-utils (1.1.31-2) 中...
Processing triggers for doc-base (0.10.5) ...
正在處理 1 added doc-base file...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
設定 python-iniparse (0.4-2.1build1) ...
設定 yum-utils (1.1.31-2) ...

No module named setuptools


sudo apt-get install -y python-setuptools

2017/09/15

TypeError: not enough arguments for format string

原本
import csv
import MySQLdb

print "DB connecting start"
mydb = MySQLdb.connect(user='root',passwd='root',host='localhost', db='ECDatabase' )
print "DB connecting end"

cursor = mydb.cursor()

csv_data = csv.reader(file('data/productClick.csv'))
for row in csv_data:
    cursor.execute("INSERT INTO ProductClick ( userId,  productId, clickCount ) VALUES ( '%s', '%s', '%s' );", row)
#close the connection to the database.
mydb.commit()
cursor.close()
print "Done"

出現錯誤:TypeError: not enough arguments for format string
原因是csv的內容為tab分隔

修改
import csv
import MySQLdb

print "DB connecting start"
mydb = MySQLdb.connect(user='root',passwd='root',host='localhost', db='ECDatabase' )
print "DB connecting end"

cursor = mydb.cursor()

csv_data = csv.reader(file('data/productClick.csv'))
for row in csv_data:
    data=row[0].split('\t')
    # query = """insert into newsletter_subscriber (id, name, email) values ('%s', '%s', '%s')"""  %(data[0], data[1], data[2])
    cursor.execute("INSERT INTO ProductClick ( userId,  productId, clickCount ) VALUES ( '%s', '%s', '%s' );" %(data[0], data[1], data[2]))
#close the connection to the database.
mydb.commit()
cursor.close()
print "Done"

python EnvironmentError: mysql_config not found

hduser@master:~/MySQL-python-1.2.4b4$ python setup.py build
sh: 1: mysql_config: not found
Traceback (most recent call last):
  File "setup.py", line 18, in
    metadata, options = get_config()
  File "/home/hduser/MySQL-python-1.2.4b4/setup_posix.py", line 44, in get_config
    libs = mysql_config("libs_r")
  File "/home/hduser/MySQL-python-1.2.4b4/setup_posix.py", line 25, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

hduser@master:~/MySQL-python-1.2.4b4$ sudo  apt-get install libmysqld-dev

找到mysql_config目錄的所在位置
find  / -name mysql_config

修改
hduser@master:~/MySQL-python-1.2.4b4$ sudo gedit setup_posix.py
內容,如下
mysql_config.path = "/usr/bin/mysql_config"

hduser@master:~/MySQL-python-1.2.4b4$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
hduser@master:~/MySQL-python-1.2.4b4$

hduser@master:~/MySQL-python-1.2.4b4$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
hduser@master:~/MySQL-python-1.2.4b4$ python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql_exceptions.py -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_mysql.so -> build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/cursors.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/connections.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb
creating build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/ER.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CR.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/FLAG.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/constants/__init__.py -> build/bdist.linux-x86_64/egg/MySQLdb/constants
copying build/lib.linux-x86_64-2.7/MySQLdb/times.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/release.py -> build/bdist.linux-x86_64/egg/MySQLdb
copying build/lib.linux-x86_64-2.7/MySQLdb/converters.py -> build/bdist.linux-x86_64/egg/MySQLdb
byte-compiling build/bdist.linux-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/times.py to times.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.linux-x86_64/egg/MySQLdb/converters.py to converters.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.linux-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing distribute-0.6.28-py2.7.egg
creating /home/hduser/anaconda2/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg
Extracting distribute-0.6.28-py2.7.egg to /home/hduser/anaconda2/lib/python2.7/site-packages
Adding distribute 0.6.28 to easy-install.pth file
Installing easy_install script to /home/hduser/anaconda2/bin
Installing easy_install-2.7 script to /home/hduser/anaconda2/bin

Installed /home/hduser/anaconda2/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg
Processing dependencies for distribute==0.6.28
Finished processing dependencies for distribute==0.6.28
Processing MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg
creating /home/hduser/anaconda2/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg
Extracting MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg to /home/hduser/anaconda2/lib/python2.7/site-packages
Adding MySQL-python 1.2.4b4 to easy-install.pth file

Installed /home/hduser/anaconda2/lib/python2.7/site-packages/MySQL_python-1.2.4b4-py2.7-linux-x86_64.egg
Processing dependencies for MySQL-python==1.2.4b4
Finished processing dependencies for MySQL-python==1.2.4b4

執行Eclipse  Window >> Preferences >> Apply




2017/09/14

安裝mysqlbench


$ wget http://dev.mysql.com/get/mysql-apt-config_0.3.5-1ubuntu14.04_all.deb

$ sudo dpkg -i mysql-apt-config_0.3.5-1ubuntu14.04_all.deb

$ sudo apt-get update -y

devops@devopsservice:~

2017/09/04

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org/bson/conversions/Bson


solution:
缺bson-VERSION.jar檔案

確認mongodb版本

hduser@master$ mongod --version
db version v3.4.7
git version: cf38c1b8a0a8dca4a11737581beafef4fe120bcd
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1404
    distarch: x86_64
    target_arch: x86_64

FAILED: ParseException line 1:87 Failed to recognize predicate 'Timestamp'. Failed rule: 'identifier' in column specification


solution:
hive > set hive.support.sql11.reserved.keywords=false;

2011/09/06

如何將你的粉絲頁上的塗鴉崁入Blog中

        這個功能只有適用於粉絲團的塗鴉牆,不適用於個人塗鴉牆哦~~~~方法很簡單,不需要任何程式就會啦,步驟如下: