博文

encrypted EBS caused AWS EC2 failed to start by Lambda

    前不久因为安全方面的考虑,把AWS EC2挂载的EBS硬盘做了加密处理,具体就是先给未加密non-encrypted的EBS硬盘创建一个snapshot,然后在KMS里创建了一个新的key,再从那个未加密的snapshot来copy一个新的snapshot,copy的时候选KMS里的key来做加密,这样就得到了一个加密过的snapshot,最后再用这个加密过的snapshot创建一个新的EBS,来替换原先EC2挂载的未加密的EBS硬盘,这样就完成了对EC2硬盘的加密。     当时做的很顺利,做完看看貌似EC2一切正常,也就放那儿用了。     但是最近发现,用来定时启动这些EC2的Lambda function貌似失效了,具体表现为可以被Lambda停机,但不能被Lambda启动了。     查了一下,发现Lambda自己是执行成功了的,打印Lambda的instance.start()的response,可以看到Lambda的确已经成功发出了启动的event:   [{'StartingInstances': [ {' CurrentState ': {'Code': 0, 'Name': ' pending '}, 'InstanceId': 'i-aaaaa', ' PreviousState ': {'Code': 80, 'Name': 'stopped '}}, {'CurrentState': {'Code': 0, 'Name': 'pending'}, 'InstanceId': 'i-bbbbbb', 'PreviousState': {'Code': 80, 'Name': 'stopped'}}], 'ResponseMetadata': {'RequestId': 'a15ff429-06ae-4214-b29a-982e7958e8e9', '...

evosuite自动生成的单元测试jacoco显示代码覆盖率为0

 evosuite的网站上有解释:   https://www.evosuite.org/documentation/measuring-code-coverage/    但尝试用jacoco的offline模式怎么也试不成功 😟   所以还是只能用改classLoader的方式,简而言之,就是在pom.xml文件evosuite的plugin里,增加一个参数:                   <plugin>                     <groupId>org.evosuite.plugins</groupId>                     <artifactId>evosuite-maven-plugin</artifactId>                     <version>1.0.6</version>                     <configuration>         ...

Jenkins的自动升级之后无法服务

    最近的Jenkins自动升级2.312以上的版本,貌似和Role-based Authorization插件不兼容!由于Authorization相关的部件会在Jenkins启动时加载,所以这个不兼容的问题会造成Jenkins无法启动,只会出一个报错的页面: Error java.lang.IllegalStateException: An attempt to save the global configuration was made before it was loaded at jenkins.model.Jenkins.save(Jenkins.java:3475) at jenkins.model.Jenkins.saveQuietly(Jenkins.java:3502) at jenkins.model.Jenkins.setSecurityRealm(Jenkins.java:2701) at jenkins.model.Jenkins$15.run(Jenkins.java:3437) at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169) at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296) at jenkins.model.Jenkins$5.runTask(Jenkins.java:1153) at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214) at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurren...

aws ec2 install jenkins

1. add jenkins yum source: sudo wget -O /etc/yum.repos.d/jenkins.repo  http://jenkins-ci.org/redhat/jenkins.repo 2. add jenkins key: sudo rpm --import https://pkg.jenkins.io/redhat/jenkins.io.key 3. install jenkins: yum install jenkins --nogpgcheck 4. start jenkins & check status: service jenkins start service jenkins status 5. expose jenkins UI via aws alb: 1) create aws ALB 2) create target group, protocol as TCP or HTTP, port as 8080 3) register the target as EC2 instance or ip 4) append the target group to ALB 5) in ALB security group, add inbound rules with the internet ip address where will access ALB 6. launch ALB's dns address to launch jenkins GUI 7. as the very first time launch jenkins GUI, follow UI's initial administrator password retrieval method to cat initial password from EC2 file system 8. install jenkins plugins 9. from EC2, install jdk(not jre!), maven, docker 10. for docker, if error raise as: docker: Got permission denied while trying to connect to the...

查看docker日志的方法

1. 获得container的name或id docker container ls -a 2. 用如下命令获得docker container runtime log的路径 docker inspect --format='{{.LogPath}}' <container_name_or_id> 3. tail -f <log的路径>查看实时日志

Python3.8安装kmods报错"Microsoft Visual C++ 14.0 is required"

    前不久尝鲜安装了最新的Python3.8版本,但没想到很快就碰到了兼容性的问题。     昨晚想用kmodes聚合数据,但pip install kmodes时报错"Microsoft Visual C++ 14.0 is required"。     当时第一反应就是去Microsoft网站( https://visualstudio.microsoft.com/zh-hans/downloads/ )去下载最新的VC runtime安装包,但装了x86和x64也没有毛用。     后来又去下载安装了最新的.net framework,以及windows upgrade升级了系统最新的补丁,仍然不行。     后来又去试着先pip install wheel,再去下了.whl安装,但仍然不行。     没奈何,只好去顺着安装报错日志慢慢捋。这样,发现了kmodes失败时是失败在了几个依赖的包上,一个一个手动装,最后发现题头的报错是发生在安装scikit-learn时。     再去pypi上去找scikit-learn,发现这是一个机器学习的包,pypi上的介绍( https://pypi.org/project/scikit-learn/ )说它要求python3.5以上,但实际上仔细去读它的文档,就会发现它实际 上只支持到Python3.7!     换成Python3.7,再试装kmodes,果然一次成功!

MySQL8.0 on RHEL7

用了很久的mysql5.7,终于也要升级到mysql8.0了。升级之后的安装配置步骤有些不同,记录一下 mysql5.7的安装步骤: https://cbzhan.blogspot.com/2018/01/linuxel7-mysql5720-jira738.html mysql8.0的官网安装文档: https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html 1. 首先还是下载yum源: 1) 访问 https://dev.mysql.com/downloads/repo/yum/ ,找到对应的OS和mysql版本的yum源包 2)  下载yum源包: # wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm 3)  安装: # rpm -ivh mysql80-community-release-el7-3.noarch.rpm 4) 确认一下: # yum repolist all | grep mysql 2. 和5.7时一样,卸掉系统自带的mariadb的包 1) 先查询一下: # rpm -qa|grep mariadb mariadb-libs-5.5.64-1.el7.x86_64 2) 卸载: # yum remove mariadb-libs-5.5.64-1.el7.x86_64 3) 再确认一下已经没有了: # rpm -qa|grep mariadb 3. 安装mysql8.0: 1) yum安装: # yum -y install mysql-community-server 2) 确认一下: # rpm -qa | grep mysql mysql-community-common-8.0.17-1.el7.x86_64 mysql-community-server-8.0.17-1.el7.x86_64 mysql80-community-release-el7-3.noarch mysql-community-client-8.0.17-1.el7.x86_64 mysql...