每台宿主机安装 ansible 依赖包
- 手动修改每台宿主机APT 私有源
- 安装python-minimal
刷新APT 服务
sudo apt-get update
sudo apt-get -y install python-minimal #每台宿主机都要安装 python2
ansible 配置文件/etc/ansible/hosts 。允许普通用户免密执行sudo,集群安装必须使用root.
[harbor]
192.168.1.114 ansible_ssh_user=huyi ansible_ssh_pass=redhat ansible_sudo_pass=redhat ansible_become_user=root ansible_become=true ansible_become_pass=redhat
[k8s-master]
192.168.1.115 ansible_ssh_user=huyi ansible_ssh_pass=redhat ansible_sudo_pass=redhat ansible_become_user=root ansible_become=true ansible_become_pass=redhat
[k8s-node]
192.168.1.113 ansible_ssh_user=huyi ansible_ssh_pass=redhat ansible_sudo_pass=redhat ansible_become_user=root ansible_become=true ansible_become_pass=redhat
在ansible.cfg文件中更改下面的参数:
#host\_key\_checking = False 将#号去掉即可
验证ansbile 链接主机 权限
sudo ansible all -m ping
192.168.1.115 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.113 | SUCCESS => {
"changed": false,
"ping": "pong"
}
192.168.1.114 | SUCCESS => {
"changed": false,
"ping": "pong"
}
docker install
sudo apt-get install docker-ce -y
install harbor
ansible-playbook -e host=harbor -e user=root deploy_harbor.yml
### 文件压缩
要将目录logs打包压缩并分割成多个1M的文件,可以用下面的命令:
tar cjf - logs/ |split -b 1m - logs.tar.bz2.
完成后会产生下列文件:
logs.tar.bz2.aa, logs.tar.bz2.ab, logs.tar.bz2.ac
要解压的时候只要执行下面的命令就可以了:
cat logs.tar.bz2.a* | tar zxv