使用OracleVM
好好的一个虚拟机,想要安装个中文输入法,结果安装过程中退出了图形界面,然后就起不来啦~~~
重装一次呗~
OracleVM新建虚拟机,要安装centos7.x,虚拟机名称输入centos66,虚拟机类型和版本自动选择为Linux和RedHat64-bit,接下来的步骤中修改内存和硬盘大小。
创建虚拟机之后最好再重新设置一下cpu;网络根据情况,选择桥接,确认一下桥接到了哪个网卡;如果需要与windows共享文件夹,一并设置一下。
虚拟机类型选择了最后一个Development and Creative Workstation,附加了Additional Development 和Development Tools,其他的比如数据库开发环境等,需要再自己安装。
完成centos安装配置
【为wget命令设置代理】
修改/etc/wgetrc,一个是配置代理服务器,另外就是打开代理
或者直接在wget参数中写代理
wget -c -r -np -k -L -p -e "http_proxy=http://127.0.0.1:8087" http://www.subversion.org.cn/svnbook/1.4/
如果是https,则参数为:-e "https_proxy=http://127.0.0.1:8087"
【安装docker】
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
cat /etc/selinux/config
getenforce
setenforce 0
getenforce
sed -i 's/enforcing/disabled/' /etc/selinux/config
swapoff -a
yum install -y yum-utils device-mapper-persistent-data lvm2
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum list docker-ce --showduplicates|sort -r
yum -y install docker-ce-18.06.1.ce-3.el7
systemctl enable docker && systemctl start docker
#Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
docker --version
#Docker version 18.06.1-ce, build e68fc7a
【卸载docker】
yum list installed | grep docker
yum remove xxx
rm -rf /var/lib/docker
【安装/升级Docker客户端】
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum -y install docker-ce
docker version
配置镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-EOF
{
"registry-mirrors": ["https://jvact13k.mirror.aliyuncs.com"] ,
"insecure-registries":["192.168.235.150"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
【Docker开启远程端口实现远程api调用】
http://192.168.10.66:5555/images/json
vim /lib/systemd/system/docker.service
#修改文件内容
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:5555 -H unix:///var/run/docker.sock
systemctl restart docker
systemctl daemon-reload
上次摆弄docker,弄到这步,远程api可以访问了,但是docker命令却每次都被挂起,这次没有问题
【docker 拉取镜像错误 Error response from daemon: Get https://registry-1.docker.io/v2/:】
【配置Docker镜像加速器】
vim /etc/docker/daemon.json
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"]
}
systemctl daemon-reload
systemctl restart docker
[Docker网络代理设置]
mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
systemctl daemon-reload
systemctl restart docker
#检查代理是否生效
docker search redis
http-proxy.conf内容
[Service]
Environment="HTTP_PROXY=http://192.168.1.100:3128" "HTTPS_PROXY=http://192.168.1.100:3128" "NO_PROXY=localhost,127.0.0.1,192.168.1.*,capacity.com"
[采用docker方式打包到服务器]
[Maven 插件之 docker-maven-plugin 的使用]
mvn docker:build
[root@centos66 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
capacity/new-api-gateway latest 342660e7c6c5 27 minutes ago 283MB
openjdk 8-jdk-alpine a3562aa0b991 16 months ago 105MB
docker镜像push到dockerhub(创建dockerhub账号,登录,然后push)
[如何push一个docker镜像到DockerHub上]
[root@centos66 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
smart/new-api-gateway latest 342660e7c6c5 27 minutes ago 283MB
[root@centos66 ~]# docker tag smart/new-api-gateway menglingzhi/new-api-gateway:2.0.3
[root@centos66 ~]# docker login
[root@centos66 ~]# docker push menglingzhi/new-api-gateway:2.0.3
The push refers to repository [docker.io/menglingzhi/new-api-gateway]
Docker Compose
[root@centos66 ~]# curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose --proxy http://192.168.1.55:3128
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 651 100 651 0 0 334 0 0:00:01 0:00:01 --:--:-- 334
100 15.4M 100 15.4M 0 0 90830 0 0:02:58 0:02:58 --:--:-- 71526
[root@centos66 ~]# chmod +x /usr/local/bin/docker-compose
[root@centos66 ~]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
[root@centos66 ~]# docker-compose --version
docker-compose version 1.24.1, build 4667896b
[root@centos66 ~]# docker ps |awk '{print $1}'|xargs docker rm -f
harbor需要的证书
vim /etc/hosts
127.0.0.1 capacity.com
192.168.10.66 capacity.com
cd /data/cert/
openssl genrsa -out ca.key 4096
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=capacity.com" \
-key ca.key \
-out ca.crt
openssl genrsa -out capacity.com.key 4096
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=example/OU=Personal/CN=capacity.com" \
-key capacity.com.key \
-out capacity.com.csr
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=capacity.com
DNS.2=capacity
EOF
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in capacity.com.csr \
-out capacity.com.crt
openssl x509 -inform PEM -in capacity.com.crt -out capacity.com.cert
mkdir -p /etc/docker/certs.d/capacity.com/
cp capacity.com.cert /etc/docker/certs.d/capacity.com/
cp capacity.com.key /etc/docker/certs.d/capacity.com/
cp ca.crt /etc/docker/certs.d/capacity.com/
systemctl restart docker
Harbor下载安装
wget https://storage.googleapis.com/harbor-releases/harbor-offline-installer-v1.6.1.tgz
tar -zxvf harbor-offline-installer-v1.6.1.tgz
cd harbor
./prepare
vim harbor.cfg
中间需要修改一下配置文件。
【Configure the Harbor YML File】
vim harbor.cfg,hostname参照虚拟机安装时的名称或者实际情况设置
hostname = capacity.com
ui_url_protocol = https
http_proxy = http://192.168.10.5:3128
https_proxy = http://192.168.10.5:3128
ssl_cert = /etc/docker/certs.d/capacity.com/capacity.com.cert
ssl_cert_key = /etc/docker/certs.d/capacity.com/capacity.com.key
继续Harbor的安装
./install.sh
访问Harbor https://192.168.10.66/
[root@centos66 harbor]# docker login 192.168.10.66
Username: admin
Password:
Login Succeeded
#增加https
vim /etc/docker/daemon.json
{
"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["192.168.10.66"]
}
#登录尝试
docker login 192.168.10.66
docker login capacity.com
#tag & push
docker tag smart/new-api-gateway:2.0.3 capacity.com/library/smart-new-api-gateway:2.0.3
docker push capacity.com/library/smart-new-api-gateway:2.0.3