容器随docker自启动

docker自启动了的情况下,我们希望对应的容器也自动启动,比如mysql、redis

设置过程

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo docker update --restart=always 容器id或者名称

#如果还没有安装容器,可以在run命令中指定,比如
docker run xxxxxxxxxx xxx --restart=always xxxxx

#查看哪些设置了开机启动
systemctl list-unit-files | grep enable

#设置docker开机启动
systemctl enable docker.service

#重新启动容器
docker start 容器id或者名称

linux下docker安装

linux下docker安装

安装流程

如果已经安装旧的版本先卸载

1
2
3
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2

安装测试阶段可以先关闭防火墙

1
2
3
4
5
#关闭防火墙
service firewalld stop

#禁用防火墙
systemctl disable firewalld

安装

1
2
3
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
1
2
3
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
1
yum install docker-ce docker-ce-cli containerd.io

docker 一些相关的命令

1
2
3
4
5
6
7
8
9
10
11
12
13
#启动
systemctl start docker
# 或
service docker start

#设置开机自启动
systemctl enable docker

#重启docker服务
service docker restart

#查看哪些已经设置了开机启动
systemctl list-unit-files | grep enable

docker 一些相关配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#docker镜像仓库配置

#编辑文件
vim /etc/docker/daemon.json

#添加
{
"insecure-registries": [
"192.168.100.1:5001"
],
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"}
}

#配置docker 目录环境变量
#docker env variables
export CONF_DIR=/javafamily/docker/configs
export VOLUME_DATA_DIR=/javafamily/docker/volumes
export LOGS_DIR=/javafamily/docker/logs

no matching host key type found

ssh指定密钥登录服务器失败

Their offer: ssh-rsa 问题解决

修改ssh配置文件 ~/.ssh/config 添加如下配置 (没有 config 文件则新增)

1
2
3
# 追加内容
HostKeyAlgorithms ssh-rsa
PubkeyAcceptedKeyTypes ssh-rsa

TFS 搭建发布系统 (Azure DevOps)

通过源代码管理、工作跟踪、持续集成和交付,在本地和云中协作进行软件开发

搭建过程中注意

在安装JDK的时候只安装了jre(用于运行jar包),没有安装jdk(用于打包编译),会出现 No compiler is provided in this environment.
Perhaps you are running on a JRE rather than a JDK
表现如下:

1
2
3
4
5
#有jdk的版本信息
java -version

#没有显示版本信息
javac -version

解决方法:同时安装jdk和jre

1
yum -y install java-1.8.0-openjdk-devel

或者安装指定版本jdk

1
2
3
4
5
#只安装jre
yum -y install java-1.8.0-openjdk-1.8.0.272.b10-1.el7_9.x86_64

#安装jdk
yum -y install java-1.8.0-openjdk-devel-1.8.0.272.b10-1.el7_9.x86_64

配置JAVA_HOME

1
2
3
4
5
6
7
8
9
10
#编辑环境变量
vim /etc/profile

#添加下面几行
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-1.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib

#使上述配置生效
source /etc/profile

Maven 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#配置maven本地仓库
<localRepository>/web/setupbase/mavenlib</localRepository>

#配置maven阿里云镜像
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

#配置maven全局jdk版本
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>

缺失 gss-ntlmssp | gssntlmssp

1
2
3
4
5
6
7
8
9
10
11
12
# Via Yum (Centos RHEL) - requires epel-release
yum -y install epel-release
yum -y install gssntlmssp

# Via Dnf (Fedora)
dnf -y install gssntlmssp

# Via Apt (Ubuntu)
apt-get -y install gss-ntlmssp

# Via Pacman (Arch Linux)
pacman -S gss-ntlmssp

Centos7 git 升级

Centos7 自带的git版本太低了,无法搭建tfs 自动化部署

先卸载旧版本,然后下载新版本

1
2
3
4
5
6
7
8
9
10
11
#卸载旧版本git
yum remove git

#安装git仓库
rpm -ivh http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm

#安装新版本git
yum -y install git

#验证git 版本
git version

搭建hexo博客系统

hexo一个主流的博客框架。

安装 hexo.io

1
2
3
4
5
全局安装    npm install hexo-cli -g

查看hexo版本,确保安装成功 hexo -v

切换到博客空目录,执行命令初始化 hexo init

启动博客,默认在浏览器中运行localhost:4000访问

hexo基础命令

1
2
3
4
5
6
7
8
9
10
11
添加文件  hexo new 文件名称

启动博客系统 hexo s

清理文件 hexo clean

生成文件 hexo g

部署到github远端,将本地同步到远端 hexo d

git部署的插件安装 npm install --save hexo-deployer-git

添加主题 melody

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
npm install hexo-renderer-pug hexo-renderer-stylus

复制
./node_modules/hexo-theme-melody/_config.yml
到 _config.melody.yml (没有就新增该配置文件)

进行配置文件的修改 _config.yml
例:
theme: melody
type: 'git'
repo: https://github.com/xinker17/xinker17.github.io
brach: master

主题更新
npm update hexo-theme-melody

如果出现:因为在此系统上禁止运行脚本

我们通过管理员权限运行power shell(可通过win+x打开),然后输入命令

1
set-ExecutionPolicy RemoteSigned

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment