轉自:http://www.cnblogs.com/zhangning/p/7251810.htmlhtml
v1.0node
節點linux |
說明git |
主機名github |
IPweb |
Masterdocker |
主控制節點shell |
openshiftmaster.dynastech.comwindows |
192.168.30.95centos |
Etcd |
協調服務節點 |
openshiftetcd.dynastech.com |
192.168.30.96 |
Node1 |
計算節點1 |
openshiftnode1.dynsatech.com |
192.168.30.102 |
Node2 |
計算節點2 |
openshiftnode2.dynastech.com |
192.168.30.98 |
Node3 |
計算節點3 |
openshiftnode3.dynastech.com |
192.168.30.110 |
校驗並安裝centos linux 7系統
等待校驗完成
(這裏能夠選擇桌面版,以下圖,服務器建議最小安裝)
這裏我爲了測試方便,直接修改各個節點hosts文件
用xshell5鏈接各個節點
進入編輯vi /etc/hosts
開始編輯按insert
編輯完成esc,
保存並退出:wq
強制退出不保存!q
[root@全部節點 ~]# yum install -y lrzsz git wget net-tools bind-utils iptables-services bridge-utils bash-completion
[root@全部節點 ~]# yum install -y docker
[root@openshiftectd ~]# systemctl start iptables
[root@openshiftectd ~]# systemctl enable iptables
命令: fdisk -l
如圖所示,添加的數據盤掛載在/dev/sdb目錄下
[root@全部節點 ~]# vi /etc/sysconfig/docker-storage-setup
[root@全部節點 ~]# docker-storage-setup
vi /etc/sysconfig/docker
追加參數:
--registry-mirror=https://docker.mirrors.ustc.edu.cn
systemctl enable docker
systemctl start docker
systemctl status docker
[root@openshiftectd ~]# yum install -y etcd
[root@openshiftectd ~]# systemctl enable etcd
[root@openshiftectd ~]# systemctl start etcd
下載安裝包
http://mirrors.neusoft.edu.cn/epel/7/x86_64/e/
上傳到master
[root@openshiftmaster ~]# yum install -y epel-release-7-10.noarch.rpm
[root@openshiftmaster ~]# yum install -y --enablerepo=epel ansible pyOpenSSL
[root@openshiftmaster ~]# ssh-keygen -f /root/.ssh/id_rsa -N ''
[root@openshiftmaster ~]# vi /etc/ssh/ssh_config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
[root@openshiftmaster ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub openshiftmaster.dynastech.com
[root@openshiftmaster ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub openshiftetcd.dynastech.com
[root@openshiftmaster ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub openshiftnode1.dynastech.com
[root@openshiftmaster ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub openshiftnode2.dynastech.com
[root@openshiftmaster ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub openshiftnode3.dynastech.com
[root@openshiftmaster ~]# git clone https://github.com/openshift/openshift-ansible
參考:https://docs.openshift.org/latest/install_config/install/advanced_install.html
[root@openshiftmaster ~]# vi /etc/ansible/hosts
添加以下內容
# Create an OSEv3 group that contains the masters and nodes groups
[OSEv3:children]
masters
nodes
etcd
# Set variables common for all OSEv3 hosts
[OSEv3:vars]
# SSH user, this user should allow ssh based auth without requiring a password
ansible_ssh_user=root
# If ansible_ssh_user is not root, ansible_become must be set to true
#ansible_become=true
openshift_deployment_type=origin
# uncomment the following to enable htpasswd authentication; defaults to DenyAllPasswordIdentityProvider
openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider', 'filename': '/etc/origin/master/htpasswd'}]
# host group for masters
[masters]
openshiftmaster.dynastech.com
# host group for etcd
[etcd]
openshiftetcd.dynastech.com
# host group for nodes, includes region info
[nodes]
openshiftmaster.dynastech.com
openshiftnode1.dynastech.com
openshiftnode2.dynastech.com
openshiftnode3.dynsatech.com
[root@openshiftmaster ~]# ansible-playbook openshift-ansible/playbooks/byo/config.yml
等待運行完成,正常狀況已經配置完成。
硬件配置過低會有以下錯誤:
解決此錯誤的方法是編輯/etc/ansible/hosts
加入以下配置,跳過檢查項
因爲是運行在pc機上的,硬件配置不夠,我在這裏同時將etcd合併到了master節點(即將ectd安裝到master節點並啓動),在配置hosts時,將etcd指向master節點,停用了node3,配置變成以下圖所示
(若是參考者的運行環境,硬件配置能夠,這裏沒必要要刪減節點)
再次運行
[root@openshiftmaster ~]# ansible-playbook openshift-ansible/playbooks/byo/config.yml
即成功經過安裝。
安裝成功的彙總信息以下圖
[root@openshiftmaster ~]# oc get nodes
[root@openshiftmaster ~]# htpasswd -b /etc/origin/master/htpasswd admin admin
配置本機hosts文件,將master節點ip指向其主機名
用admin登陸web站點
至此OpenShift集羣搭建完畢!開始探索吧………
後記:
此文檔不詳盡處:
https://docs.openshift.org/latest/install_config/install/advanced_install.html