阿里云上實(shí)戰(zhàn)openshift1-阿里ECS服務(wù)器上安裝openshift集群

阿里云上購(gòu)買ECS 3臺(tái):

? 其中1臺(tái)ECS: ?8核cpu, 內(nèi)存16G, 系統(tǒng)盤(pán)80G, 作為openshift master以及企業(yè)dockerregistry

? 其中2臺(tái)ECS:2核cpu, 內(nèi)存8G, 系統(tǒng)盤(pán)30G、數(shù)據(jù)盤(pán)40G, 作為openshift node


【注】以下安裝全部用root用戶,root用戶應(yīng)有ssh遠(yuǎn)程登錄權(quán)限

1.node節(jié)點(diǎn)安裝

? #設(shè)置主機(jī)名

?hostnamectl set-hostname node1.honsen.com

?hostnamectl set-hostname node2.honsen.com

? #安裝依賴包

? yum install wget git net-tools bind-utils iptables-services bridge-utilsbash-completion kexec-tools sos psacct

? yum update

? #啟用&啟動(dòng)Docker服務(wù)

?systemctl enable docker; systemctl start docker

? #修改docker配置

? vi/etc/sysconfig/docker

? 首行Options追加上--insecure-registry172.30.0.0/16 --registry-mirror=https://docker.mirrors.ustc.edu.cn

? #重啟docker

?systemctl restart docker

? #啟用&啟動(dòng)網(wǎng)絡(luò)管理器

?systemctl enable NetworkManager; systemctl start NetworkManager

? #停止&禁用防火墻

?systemctl stop firewalld ; systemctl disable firewalld


? #Ansible和系統(tǒng)自帶的urllib3有沖突, 卸載之: Error unpacking rpm package python-urllib3-1.10.2-3.el7.noarch

? pip uninstall urllib3


? #以下設(shè)置Docker中配置overlay/overlay2存儲(chǔ)驅(qū)動(dòng)

? #檢查overlay驅(qū)動(dòng)是否已加載

??lsmod | grep overlay

? #以下設(shè)置node節(jié)點(diǎn)的docker數(shù)據(jù)存儲(chǔ)區(qū)

??see https://docs.openshift.org/latest/install_config/install/host_preparation.html#configuring-docker-storage

? #查看磁盤(pán)情況

?fdisk -l

? #修改docker存儲(chǔ)配置

? vi /etc/sysconfig/docker-storage-setup

???STORAGE_DRIVER=overlay2

???DEVS=/dev/vdb

???VG=docker-vg

? #執(zhí)行docker存儲(chǔ)配置

?docker-storage-setup

? 【注】執(zhí)行這一步后會(huì)創(chuàng)建邏輯分區(qū)/dev/vdb1

?fdisk -l?

? #格式化數(shù)據(jù)盤(pán)為xfs

?mkfs.xfs -f /dev/vdb1

? #停止docker

?systemctl stop docker

? rm-rf /var/lib/docker/*

?#mount數(shù)據(jù)盤(pán)到/var/lib/docker

?mount -t xfs /dev/vdb1 /var/lib/docker

? #檢查mount是否成功

? df -Th /var/lib/docker

? #配置重啟時(shí)自動(dòng)mount

? vi /etc/fstab

? 加上一行:

???/dev/vdb1?????/var/lib/docker????? xfs???? defaults???0 0

? #重啟docker??????

?systemctl restart docker

? #查看docker配置信息

?docker info


2.master安裝

? #設(shè)置主機(jī)名

?hostnamectl set-hostname master.honsen.com

? #設(shè)置本地域名解析

?echo "172.18.113.134 master.honsen.com" >> /etc/hosts

?echo "172.18.113.136 node1.honsen.com" >> /etc/hosts

?echo "172.18.113.135 node2.honsen.com" >> /etc/hosts

? #安裝依賴包

? yum install -y docker wget git net-tools bind-utils iptables-services bridge-utilsbash-completion

? #啟用&啟動(dòng) Docker服務(wù)

?systemctl enable docker; systemctl start docker

? #修改docker配置

? vi/etc/sysconfig/docker

? 首行Options追加上--insecure-registry172.30.0.0/16 --registry-mirror=https://docker.mirrors.ustc.edu.cn

? #重啟docker

?systemctl restart docker

? #啟用&啟動(dòng)網(wǎng)絡(luò)管理器

?systemctl enable NetworkManager; systemctl start NetworkManager

? #停止&禁用防火墻

?systemctl stop firewalld ; systemctl disable firewalld


? #Ansible和系統(tǒng)自帶的urllib3有沖突, 卸載之: Error unpacking rpm package python-urllib3-1.10.2-3.el7.noarch

? pip uninstall urllib3


? #以下修改master的docker存儲(chǔ)配置

? vi /etc/sysconfig/docker-storage?

?DOCKER_STORAGE_OPTIONS=--storage-driver devicemapper --storage-optdm.fs=xfs

? #重啟docker

?systemctl stop docker

? rm -rf /var/lib/docker/*

?systemctl restart docker?

? #查看docker配置信息

?docker info?


? #安裝, 啟用&啟動(dòng)etcd分布式數(shù)據(jù)庫(kù)

? yum -y install etcd

?systemctl enable etcd; systemctl start etcd


? #下載安裝EPEL

? yum -y installhttps://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

? #設(shè)置epelenable=0

? sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo

? #安裝ansible

? yum -y --enablerepo=epel install ansible pyOpenSSL


? #生成秘鑰, 實(shí)現(xiàn)ssh免密碼連接

?ssh-keygen -f ~/.ssh/id_rsa -N ''

? #復(fù)制秘鑰到集群中的所有節(jié)點(diǎn),實(shí)現(xiàn)無(wú)密碼訪問(wèn)

? for host in master.honsen.com node1.honsen.com node2.honsen.com; do ssh-copy-id -i~/.ssh/id_rsa.pub -p root@$host;? done

? #設(shè)置ssh端口, 例如52113

?? vi ~/.ssh/config

??host master.honsen.com

??port 52113?

??host node1.honsen.com

??port 52113

??host node2.honsen.com

??port 52113

? #改變~/.ssh/config的權(quán)限

?chmod 600 ~/.ssh/config

? #測(cè)試ssh免密碼連接

? ssh node1.honsen.com

?[honsen@node1 ~]$exit


? #以下下載安裝openshift-ansible

?wget https://github.com/openshift/openshift-ansible/archive/openshift-ansible-3.7.31-1.tar.gz

? tar zxvf openshift-ansible-3.7.31-1.tar.gz

? vi /etc/ansible/hosts

??????????????????????????? [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? #ssh用戶名

??????????????????????????? ansible_ssh_port=52113?? #ssh服務(wù)端口

??????????????????????????? openshift_deployment_type=origin

??????????????????????????? openshift_release=3.7.1


??????????????????????????? #如果CPU內(nèi)存滿足條件, 可以注釋掉openshift_disable_check

??????????????????????????? #Master節(jié)點(diǎn)要求 2 CPU核心, 16G內(nèi)存, 40G磁盤(pán)

??????????????????????????? #?? Node節(jié)點(diǎn)要求 1 CPU核心,? 8G內(nèi)存, 20G磁盤(pán)

??????????????????????????? #openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability


??????????????????????????? #uncomment the following to enable htpasswd authentication; defaults toDenyAllPasswordIdentityProvider

??????????????????? openshift_master_identity_providers=[{'name':'htpasswd_auth','login':'true','challenge':'true','kind':'HTPasswdPasswordIdentityProvider','filename':'/etc/origin/master/htpasswd'}]


??????????????????????????? #host group for masters

??????????????????????????? [masters]

??????????????????????????? master.honsen.com


??????????????????????????? #host group for nodes, includes region info

??????????????????????????? [nodes]

??????????????????????????? master.honsen.com

??????????????????????????? node1.honsen.comopenshift_node_labels="{'region': 'primary', 'zone': 'default'}"

??????????????????????????? node2.honsen.comopenshift_node_labels="{'region': 'infra', 'zone': 'default'}"


??????????????????????????? [etcd]

??????????????????????????? master.honsen.com


???????? #開(kāi)始安裝openshift集群(用ssh用戶)

???ansible-playbook ~/openshift-ansible-openshift-ansible-3.7.31-1/playbooks/byo/config.yml????????


3.成功安裝后购公,檢查安裝結(jié)果

#基本檢查??????

???????? oc get nodes --show-labels?????

?????????????????? NAME??????????????? STATUS???????????????????? AGE?????? VERSION???????????? LABELS

?????????????????? master.honsen.com?? Ready,SchedulingDisabled?? 1h???????v1.7.6+a08f5eeb62??beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=master.honsen.com,openshift-infra=apiserver

?????????????????? node1.honsen.com??? Ready?????????????????????1h??????? v1.7.6+a08f5eeb62??beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node1.honsen.com,region=primary,zone=default

?????????????????? node2.honsen.com??? Ready????????????????????? 1h??????? v1.7.6+a08f5eeb62?? beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/hostname=node2.honsen.com,region=infra,zone=default



***安裝過(guò)程中常見(jiàn)問(wèn)題***

1) 多次執(zhí)行ansible-playbook后韭邓,出現(xiàn)ssh error:

????ssh: connect to host node1.honsen.com port 52113: No route to host\r\n

???????? #檢查防火墻狀態(tài)

???????? systemctl status firewalld??????

???????? ●firewalld.service

???????? ?? Loaded: masked (/dev/null; bad)? //masked表明防火墻被鎖住了O凇G庥怠胶果!

???????? ?? Active: inactive (dead)

???????? #以下是解決辦法??

???????? #修改并重啟iptabless

???????? vi /etc/sysconfig/iptables

?????????????????? 將

?????????????????? -AINPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

?????????????????? 替換為

?????????????????? -AINPUT -p tcp -m state --state NEW -m tcp --dport 52113 -j ACCEPT

???????? service iptables restart??


2)Failure summary:

???????? ?Hosts:???master.honsen.com, node1.honsen.com, node2.honsen.com

????Play:???? OpenShift Health Checks

????Task:???? Run health checks(install) - EL

????Message:? One or more checksfailed

????Details:?

?????????????? check"package_version":

?????????????? Some required package(s) areavailable at a version

?????????????? that is higher than requested

???????????????? docker-1.13.1

?????????????? This will prevent installing theversion you requested.

?????????????? Please check your enabledrepositories or adjust openshift_release.?????

?? #解決辦法

?? cd /roles/openshift_health_checker/openshift_checks

?? vi package_version.py

?????????????????? openshift_to_docker_version= {

???????????????????????????????????? (3,1): "1.8",

???????????????????????????????????? (3,2): "1.10",

???????????????????????????????????? (3,3): "1.10",

???????????????????????????????????? (3,4): "1.12",

???????????????????????????????????? (3,5): "1.12",

???????????????????????????????????? (3,6): "1.12",

???????????????????????????????????? (3,7): ["1.12", "1.13.1"], # <== here add the dockerversion that you want????????????????????????????

???????????????????????????????????? (3,9): "1.13.1",

?????????????????? }??

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末丐巫,一起剝皮案震驚了整個(gè)濱河市谈况,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌递胧,老刑警劉巖碑韵,帶你破解...
    沈念sama閱讀 206,126評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異缎脾,居然都是意外死亡祝闻,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門(mén)遗菠,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)联喘,“玉大人,你說(shuō)我怎么就攤上這事辙纬』碓猓” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 152,445評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵贺拣,是天一觀的道長(zhǎng)蓖谢。 經(jīng)常有香客問(wèn)我,道長(zhǎng)譬涡,這世上最難降的妖魔是什么闪幽? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 55,185評(píng)論 1 278
  • 正文 為了忘掉前任,我火速辦了婚禮涡匀,結(jié)果婚禮上盯腌,老公的妹妹穿的比我還像新娘。我一直安慰自己陨瘩,他們只是感情好腕够,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,178評(píng)論 5 371
  • 文/花漫 我一把揭開(kāi)白布级乍。 她就那樣靜靜地躺著,像睡著了一般燕少。 火紅的嫁衣襯著肌膚如雪卡者。 梳的紋絲不亂的頭發(fā)上蒿囤,一...
    開(kāi)封第一講書(shū)人閱讀 48,970評(píng)論 1 284
  • 那天客们,我揣著相機(jī)與錄音,去河邊找鬼材诽。 笑死底挫,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的脸侥。 我是一名探鬼主播建邓,決...
    沈念sama閱讀 38,276評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼睁枕!你這毒婦竟也來(lái)了官边?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 36,927評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤外遇,失蹤者是張志新(化名)和其女友劉穎注簿,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體跳仿,經(jīng)...
    沈念sama閱讀 43,400評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡诡渴,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,883評(píng)論 2 323
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了菲语。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片妄辩。...
    茶點(diǎn)故事閱讀 37,997評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖山上,靈堂內(nèi)的尸體忽然破棺而出眼耀,到底是詐尸還是另有隱情,我是刑警寧澤佩憾,帶...
    沈念sama閱讀 33,646評(píng)論 4 322
  • 正文 年R本政府宣布畔塔,位于F島的核電站,受9級(jí)特大地震影響鸯屿,放射性物質(zhì)發(fā)生泄漏澈吨。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,213評(píng)論 3 307
  • 文/蒙蒙 一寄摆、第九天 我趴在偏房一處隱蔽的房頂上張望雪侥。 院中可真熱鬧,春花似錦杆融、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,204評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)蚣录。三九已至割择,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間萎河,已是汗流浹背荔泳。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,423評(píng)論 1 260
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留虐杯,地道東北人玛歌。 一個(gè)月前我還...
    沈念sama閱讀 45,423評(píng)論 2 352
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像擎椰,于是被迫代替她去往敵國(guó)和親支子。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,722評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容