每臺宿主機安裝 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