首页 » Latest Post

如何用nodejs的koa2 快速生成一个项目呢。注意koa2 使用的nodejs 版本至少7以上,所以请先更新最新的nodejs

1.安装koa2 的项目generator

sudo npm install koa-generator -g

2.生成一个nodejs项目,注意-e是使用ejs模板,默认是jade。具体和可以用koa2 --help查看帮助

koa2 -e projectName

k8s 想要进入容器查看日志比较麻烦,还是推荐把日志log到etl等工具里面查看

1.查看所有pods,

kubectl get pod 

返回如下,我们要看rrtv-third-test-68bf79765b-p8rvw

dubbo-third-test-77c7d5f85d-zhc8v          2/2       Running   0          2d
rrtv-third-test-68bf79765b-p8rvw           2/2       Running   0          12h

2.查看这个pod所有的实例

 kubectl logs rrtv-third-test-68bf79765b-p8rvw

返回如下,其中group-nyg9gk3a-docker 就是我们要进入的实力

Error from server (BadRequest): a container name must be specified for pod rrtv-third-test-68bf79765b-p8rvw, choose one of: [group-nyg9gk3a-agent-docker group-nyg9gk3a-docker]

3.进入实例,然后就可以cd到目录文件夹,看日志了

kubectl exec -it rrtv-third-test-68bf79765b-p8rvw -c group-nyg9gk3a-docker /bin/bash
cd /data/logs
tailf spring.log

jpa报错,Table 'DBNAME.hibernate_sequence' doesn't exist,这个解决办法是加上自增

尝试如下:

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

或者配置

spring:
  jpa:
    hibernate:
      use-new-id-generator-mappings: false

这个报错是因为kafka server的版本过低,建议更换kafka server

完整报错

java.lang.IllegalArgumentException: Magic v1 does not support record headers
    at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:403)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.appendWithOffset(MemoryRecordsBuilder.java:442)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:499)
    at org.apache.kafka.common.record.MemoryRecordsBuilder.append(MemoryRecordsBuilder.java:522)
    at org.apache.kafka.clients.producer.internals.ProducerBatch.tryAppend(ProducerBatch.java:107)
    at org.apache.kafka.clients.producer.internals.RecordAccumulator.append(RecordAccumulator.java:222)
    at org.apache.kafka.clients.producer.KafkaProducer.doSend(KafkaProducer.java:814)
    at org.apache.kafka.clients.producer.KafkaProducer.send(KafkaProducer.java:768)
    at org.springframework.kafka.core.DefaultKafkaProducerFactory$CloseSafeProducer.send(DefaultKafkaProducerFactory.java:384)
    at brave.kafka.clients.TracingProducer.send(TracingProducer.java:106)
    at org.springframework.kafka.core.KafkaTemplate.doSend(KafkaTemplate.java:368)
    at org.springframework.kafka.core.KafkaTemplate.send(KafkaTemplate.java:183)
    at tv.rr.messaging.KafkaMessageProducer.sendMessage(KafkaMessageProducer.java:38)
    at tv.rr.messaging.KafkaMessageProducer$$FastClassBySpringCGLIB$$8cc6427f.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
    at org.springframework.cloud.sleuth.instrument.async.TraceAsyncAspect.traceBackgroundThread(TraceAsyncAspect.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
    at java.util.concurrent.FutureTask.run(FutureTask.java)
    at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.run(TraceRunnable.java:62)
    at java.lang.Thread.run(Thread.java:748)