搭建本地OpenStack源
1、安裝系統
配置以下:
Centos 7.6 虛擬機一臺
CPU:雙核雙線程
內存:2G
硬盤:30G系統盤+300G掛載盤
安裝桌面-開發工具
關閉防火牆以及核心防禦
2、同步OpenStack生產環境源
備份系統自帶的yum源html
[root@localhost network-scripts]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# mkdir bak [root@localhost yum.repos.d]# mv C* bak/ [root@localhost yum.repos.d]# hostnamectl set-hostname opstkyumy [root@localhost yum.repos.d]# su [root@opstkyumy yum.repos.d]#
編輯阿里雲Centos 7 官方源和OpenStack源
編輯阿里雲Centos 7 官方源和Open將相關的repo文件複製到/etc/yum.repos.d/下
CentOS-QEMU-EV.repo
epel.repo
openstack.repo
CentOS-Base.repo
CentOS-Storage-common.repo
nginx.repoStack源linux
[root@opstkyumy yum.repos.d]# mkdir /abc [root@opstkyumy yum.repos.d]# mount.cifs //192.168.254.1/linuxs /abc Password for root@//192.168.254.1/linuxs: [root@opstkyumy yum.repos.d]# cp /abc/yum.repos.d/* . [root@opstkyumy yum.repos.d]# ls bak CentOS-QEMU-EV.repo epel.repo openstack.repo CentOS-Base.repo CentOS-Storage-common.repo nginx.repo
檢測阿里雲源是否正常nginx
[root@opstkyumy yum.repos.d]# yum repolist
安裝相關軟件
yum-utils:reposync同步工具
createrepo:編輯yum庫工具 作依賴關係用
plugin-priorities:控制yum源更新優先級工具,這個工具能夠用來控制進行yum源檢索的前後順序,建議能夠用在client端c++
[root@opstkyumy yum.repos.d]# yum install -y wget make cmake gcc gcc-c++ pcre-devel zlib-devel openssl openssl-devel createrepo yum-utils
建立源目錄,掛載數據盤,將源同步到本地目錄swift
[root@opstkyumy yum.repos.d]# mkdir /data [root@opstkyumy yum.repos.d]# fdisk -l 磁盤 /dev/sdb:322.1 GB, 322122547200 字節,629145600 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤 /dev/sda:32.2 GB, 32212254720 字節,62914560 個扇區 Units = 扇區 of 1 * 512 = 512 bytes 扇區大小(邏輯/物理):512 字節 / 512 字節 I/O 大小(最小/最佳):512 字節 / 512 字節 磁盤標籤類型:dos 磁盤標識符:0x0001df55 設備 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 6295551 2098176 82 Linux swap / Solaris /dev/sda3 6295552 62914559 28309504 83 Linux [root@opstkyumy yum.repos.d]# [root@opstkyumy yum.repos.d]# mkfs.xfs /dev/sdb meta-data=/dev/sdb isize=512 agcount=4, agsize=19660800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=78643200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=38400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@opstkyumy yum.repos.d]# mount /dev/sdb /data [root@opstkyumy data]# vim /etc/fstab /dev/sdb /data xfs defaults 0 0 [root@opstkyumy data]# mount -a //也能夠重啓生效更穩妥 [root@opstkyumy data]# df -Th 文件系統 類型 容量 已用 可用 已用% 掛載點 /dev/sda3 xfs 27G 4.2G 23G 16% / devtmpfs devtmpfs 895M 0 895M 0% /dev tmpfs tmpfs 910M 0 910M 0% /dev/shm tmpfs tmpfs 910M 11M 900M 2% /run tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 174M 841M 18% /boot tmpfs tmpfs 182M 4.0K 182M 1% /run/user/42 tmpfs tmpfs 182M 24K 182M 1% /run/user/0 /dev/sr0 iso9660 4.3G 4.3G 0 100% /run/media/root/CentOS 7 x86_64 //192.168.254.1/linuxs cifs 455G 183G 273G 41% /abc /dev/sdb xfs 300G 33M 300G 1% /data
開始同步,將源同步到本地目錄,過程較長,耐心等待
能夠用 repo -r --repoid=repoid指定要查詢的repo id,能夠指定多個(# reposync -r base -p /data #這裏同步base目錄到本地)
更新新的rpm包
reposync -np /datavim
[root@opstkyumy ~]# reposync -p /data [root@opstkyumy data]# ls base epel nginx openstack-rocky openstack-train centos-qemu-ev extras openstack-queens openstack-stein updates [root@opstkyumy data]# ls base/ Packages //裏面都是RPM包 [root@opstkyumy data]# ls epel/ Packages [root@opstkyumy data]# ls nginx/ RPMS [root@opstkyumy data]# ls openstack-rocky/ //裏面都是RPM包 [root@opstkyumy data]# ls centos-qemu-ev/ [root@opstkyumy data]# ls extras/ Packages [root@opstkyumy data]# ls updates/ Packages
3、解決OpenStack軟件環境依賴關係
1.建立軟件依賴關係庫centos
[root@opstkyumy ~]# createrepo -po /data/base/ /data/base/ [root@opstkyumy ~]# createrepo -po /data/extras/ /data/extras/ [root@opstkyumy ~]# createrepo -po /data/updates/ /data/updates/ [root@opstkyumy ~]# createrepo -po /data/epel/ /data/epel/ [root@opstkyumy ~]# createrepo -po /data/openstack-queens/ /data/openstack-queens/ [root@opstkyumy ~]# createrepo -po /data/openstack-rocky/ /data/openstack-rocky/ [root@opstkyumy ~]# createrepo -po /data/openstack-stein/ /data/openstack-stein/ [root@opstkyumy ~]# createrepo -po /data/openstack-train/ /data/openstack-train/ [root@opstkyumy ~]# createrepo -po /data/centos-qemu-ev /data/centos-qemu-ev/ [root@opstkyumy ~]# createrepo -po /data/nginx /data/nginx
2.更新源數據bash
[root@localhost ~]# createrepo --update /data/base [root@localhost ~]# createrepo --update /data/extras [root@localhost ~]# createrepo --update /data/updates [root@localhost ~]# createrepo --update /data/epel [root@localhost ~]# createrepo --update /data/openstack-queens [root@localhost ~]# createrepo --update /data/openstack-rocky [root@localhost ~]# createrepo --update /data/openstack-stein [root@localhost ~]# createrepo --update /data/openstack-train [root@localhost ~]# createrepo --update /data/centos-qemu-ev [root@localhost ~]# createrepo --update /data/nginx
3.更新yum腳本app
[root@opstkyumy ~]# mkdir /data/script [root@opstkyumy ~]# vim /data/script/centos_openstack_yum_update.sh #!/bin/bash echo 'Updating Aliyum Source' DATETIME=`date +%F_%T` exec > /var/log/aliyumrepo_$DATETIME.log reposync -np /data if [ $? -eq 0 ];then createrepo --update /data/base createrepo --update /data/extras createrepo --update /data/updates createrepo --update /data/epel createrepo --update /data/openstack-queens createrepo --update /data/openstack-rocky createrepo --update /data/openstack-stein createrepo --update /data/openstack-train createrepo --update /data/centos-ceph-nautilus createrepo --update /data/centos-nfs-ganesha28 createrepo --update /data/centos-ceph-luminous createrepo --update /data/centos-qemu-ev createrepo --update /data/nginx createrepo --update /data/ceph-noarch echo "SUCESS: $DATETIME aliyum_yum update successful" else echo "ERROR: $DATETIME aliyum_yum update failed" fi [root@opstkyumy ~]# chmod +x /data/script/centos_openstack_yum_update.sh
4.將腳本加入到定時任務中ide
將腳本加入到定時任務中 [root@opstkyumy ~]# crontab -e 00 13 * * 6 [ $(date +%d) -eq $(cal | awk 'NR==3{print $NF}') ] && /bin/bash /data/script/centos_openstack_yum_update.sh
4、發佈本地OpenStack-yum源倉庫
1.安裝nginx開啓目錄權限保證本地機器能夠直接本地yum源
[root@opstkyumy ~]# groupadd nginx [root@opstkyumy ~]# useradd -r -g nginx -s /bin/false -M nginx [root@opstkyumy ~]# yum -y install nginx [root@opstkyumy ~]# vim /etc/nginx/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name opstkyumy; root /data; location / { autoindex on; autoindex_exact_size off; autoindex_localtime on; charset utf-8,gbk; index index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
[root@opstkyumy nginx]# systemctl start nginx [root@opstkyumy nginx]# systemctl stop firewalld [root@opstkyumy nginx]# systemctl disable firewalld [root@opstkyumy nginx]# setenforce 0 setenforce: SELinux is disabled [root@opstkyumy nginx]# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.servi
5、OpenStack客戶端部署本地yum源倉庫
配置網卡
[root@localhost ~]# ifconfig ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.254.40 netmask 255.255.255.0 broadcast 192.168.254.255 inet6 fe80::172f:76ba:bad8:2ef7 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:8d:1e:35 txqueuelen 1000 (Ethernet) RX packets 3712 bytes 632590 (617.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 176 bytes 15930 (15.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]# ping 192.168.254.152 PING 192.168.254.152 (192.168.254.152) 56(84) bytes of data. 64 bytes from 192.168.254.152: icmp_seq=1 ttl=64 time=1.23 ms 64 bytes from 192.168.254.152: icmp_seq=2 ttl=64 time=0.773 ms --- 192.168.254.152 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 0.773/1.003/1.234/0.232 ms
搭建私網倉庫
[root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls bak local.repo [root@localhost yum.repos.d]# rm -rf local.repo [root@localhost yum.repos.d]# vim openstack.repo [base] name=CentOS-$releasever - Base - data.template.com baseurl=http://192.168.254.152/base/ enabled=1 gpgcheck=0 [updates] name=CentOS-$releasever - Updates - data.template.com baseurl=http://192.168.254.152/updates/ enabled=1 gpgcheck=0 [extras] name=CentOS-$releasever - Extras - datas.template.com baseurl=http://192.168.254.152/extras/ enabled=1 gpgcheck=0 [epel] name=CentOS-$releasever - epel - datas.template.com baseurl=http://192.168.254.152/epel/ failovermethod=priority enabled=1 gpgcheck=0 #[openstack-queens] #name=openstack-queens #baseurl=http://192.168.254.152/openstack-queens/ #gpgcheck=0 #enabled=1 #[openstack-rocky] #name=openstack-rocky #baseurl=http://192.168.254.152/openstack-rocky/ #gpgcheck=0 #enabled=1 #[openstack-stein] #name=openstack-stein #baseurl=http://192.168.254.152/openstack-stein/ #gpgcheck=0 #enabled=1 [openstack-train] name=openstack-train baseurl=http://192.168.254.152/openstack-train/ gpgcheck=0 enabled=1 #[centos-ceph-luminous] #name=centos-ceph-luminous #baseurl=http://192.168.254.152/centos-ceph-luminous/ #gpgcheck=0 #enabled=1 #[centos-ceph-nautilus] #name=centos-ceph-nautilus #baseurl=http://192.168.254.152/centos-ceph-nautilus/ #gpgcheck=0 #enabled=1 #[centos-nfs-ganesha28] #name=centos-nfs-ganesha28 #baseurl=http://192.168.254.152/centos-nfs-ganesha28/ #gpgcheck=0 #enabled=1 [centos-qemu-ev] name=centos-qemu-ev baseurl=http://192.168.254.152/centos-qemu-ev/ gpgcheck=0 enabled=1 [nginx] name=nginx baseurl=http://192.168.254.152/nginx/ gpgcheck=0 enabled=1 #[ceph-noarch] #name=ceph-noarch #baseurl=http://192.168.254.152/ceph-noarch/ #gpgcheck=0 #enabled=1
[root@localhost yum.repos.d]# yum clean all [root@localhost yum.repos.d]# yum makecache
測試是否能夠下載RPM包
[root@localhost yum.repos.d]# cd /opt [root@localhost opt]# ls rh [root@localhost opt]# yumdownloader openstack-swift-account [root@localhost opt]# ll 總用量 24 -rw-r--r-- 1 root root 21264 10月 25 22:27 openstack-swift-account-2.23.1-1.el7.noarch.rpm drwxr-xr-x. 2 root root 6 10月 31 2018 rh
能夠正常下載,部署成功
6、配置阿里雲時間同步服務、配置NTP服務
配置同步阿里時鐘,在本地源配置
[root@opstkyumy data]# yum -y install ntpdate [root@opstkyumy data]# ntpdate ntp.aliyun.com 19 Feb 23:19:01 ntpdate[54480]: adjust time server 203.107.6.88 offset -0.002603 sec [root@opstkyumy ~]# crontab -e */30 * * * * /usr/sbin/ntpdate ntp.aliyun.com >>/var/log/ntpdate.log //能夠先把時間調小一點,測試是否生效
[root@opstkyumy data]# cd /var/log/ [root@opstkyumy log]# systemctl restart crond [root@opstkyumy log]# systemctl enable crond [root@opstkyumy log]# ll | grep "ntp" -rw-r--r-- 1 root root 84 Feb 19 23:22 ntpdate.log [root@opstkyumy log]# tail -f /var/log/ntpdate.log 19 Feb 23:22:09 ntpdate[57911]: adjust time server 203.107.6.88 offset 0.005077 sec 19 Feb 23:23:09 ntpdate[59092]: adjust time server 203.107.6.88 offset -0.0019
NTP時鐘同步完畢,便開始安裝NTP服務,讓別人同步本身
[root@opstkyumy log]# yum -y install ntp [root@opstkyumy log]# vim /etc/ntp.conf 8 restrict default nomodify notrap 17 restrict 192.168.254.0 mask 255.255.255.0 nomodify notrap //原有的21-24行刪除,加入下面配置 21 fudeg 127.127.1.0 stratum 10 22 server 127.127.1.0
NTP設置開機自啓而後reboot以後出現沒有自啓動的bug解決:
經過禁止chronyd服務開啓自啓動以後再將系統重啓
chronyd是linux自帶的時間服務
[root@opstkyumy log]# systemctl disable chronyd.service Removed symlink /etc/systemd/system/multi-user.target.wants/chronyd.service. [root@opstkyumy log]# systemctl restart ntpd [root@opstkyumy log]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
部署所有完成