CentOS7和OpenStack的筆記(一)html
最近搞CentOS7系統和OpenStack框架,整了近一個星期,系統裝了好幾回,框架搭了又從搭。雖然最後的實例沒能啓動成功,可是在這專研的一個星期裏,也算是有了不少的心得體會,在此記下,方便之後查看。python
1、CentOS7mysql
1、主機名修改linux
hostnamectl set-hostname MyHostname
二、修改網卡名sql
在順利的條件下改網卡名很簡單:數據庫
在/etc/sysconfig/network-scripts/目錄下,查看是否有網卡接口文件,名字通常爲ifcfg-eno16777736相似的文件。vim
編輯文件 vi ifcfg-eno16777736centos
將裏面的DEVICE=eno16777736和NAME=eno16777736修改爲api
DEVICE=eth0
NAME=eth0
重啓便可改網卡名。若是不成功,網上不少教程。網絡
三、防火牆和SELinux
關閉防火牆firewalld,CentOS7應該是再也不使用iptables了,關閉firewall便可關閉防火牆
systemctl stop firewalld.service
systemctl disable firewalld.service
關閉SELinux
vim /etc/selinux/config 修改 SELINUX=disable 退出後使用命令即時生效 setenforce 0
四、系統鏡像DVD鏡像文件裏有不少軟件,能夠設置成yum源,即作成本地yum倉庫
vi /etc/yum.repos.d/local.repo [centos] name=centos baseurl=file:///opt/centos/ gpgcheck=0 enabled=1
五、安裝vsftp共享本地yum源
yum install vsftpd -y
vi /etc/vsftpd/vsftpd.service 在最後新增一行 anon_root=/opt 啓動vsftp並開機自啓 systemctl start vsftpd.service systemctl enable vsftpd.service
另外一臺機器使用ftp源
vi /etc/yum.repos.d/local.repo [centos] name=centos baseurl=ftp://192.168.100.10/centos/ gpgcheck=0 enabled=1
測試yum源
yum list
若是計算節點yum list出錯,檢查一下雙方節點是否能ping通,檢查防火牆和selinux是否關閉。
六、修改yum源爲清華源,安裝EPEL 倉庫
使用清華源比較穩定,阿里源不是很好用,有些鏡像點不能訪問到,或者速度很慢。
網站: https://mirrors.tuna.tsinghua.edu.cn/help/centos/
刪除開始全部的yum源 rm -f /etc/yum.repos.d/* vim /etc/yum.repos.d/CentOS-Base.repo 將如下內容寫入 # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/ #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EPEL(Extra Packages for Enterprise Linux)是由Fedora Special Interest Group維護的Enterprise Linux(RHEL、CentOS)中常常用到的包。
這個倉庫的包很是多,是很棒的倉庫,原來在清華鏡像站上有國內源。
網站:https://mirrors.tuna.tsinghua.edu.cn/help/epel/
yum install epel-release -y vim /etc/yum.repos.d/epel.repo [epel] name=Extra Packages for Enterprise Linux 7 - $basearch baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 yum makecache yum update
七、安裝經常使用軟件和工具
yum install -y net-tools vim lrzsz tree screen lsof tcpdump
八、更新系統並重啓
yum update -y && reboot
給虛擬機作快照
九、踢掉用戶
使用w命令能夠看到在線的用戶
踢掉pts/1用戶
pkill -kill -t pts/1
十、ssh登陸好久都上不去
使用root權限修改ssh的配置文件 vim /etc/ssh/sshd_config 最後增長一行記錄: UseDNS no
2、OpenStack
一、虛擬機要記得開啓CPU虛擬化
二、能夠設置兩塊網卡,也能夠設置一塊網卡來啓動實例
兩塊網卡:一塊是鏈接公網使用,一塊是內部網絡使用
一塊網卡:一塊網卡,便是內部管理網絡,也是鏈接公網的網絡。
虛擬機網絡設置,若是是本身設置的IP地址,發現是上不了網。不清楚有什麼辦法解決。若是是DHCP獲取的地址就能夠正常上網。
三、內存大小設置
我這裏是雙節點設置,即,controller節點和compute節點
controller節點比較重要,設置內存4G;建議內存不要過小,否則很吃力。
compute節點,設置內存2G;
四、時間同步
yum install ntpdate -y
ntpdate ntp.tuna.tsinghua.edu.cn
若是運行 ntpd 服務,通常來講 ntpd 會逐漸調整時鐘,避免時間跳變。
在 /etc/ntp.conf
中添加一行 server ntp.tuna.tsinghua.edu.cn
便可。
使用 ntpdate ntp.tuna.tsinghua.edu.cn
進行一次性的同步
五、數據庫MariaDB
yum install -y mariadb mariadb-server python2-PyMySQL cd /etc/my.cnf.d/ vim openstack.cnf [mysqld] bind-address = 192.168.137.11 # 監聽的IP地址(也能夠寫0.0.0.0) default-storage-engine = innodb # 默認存儲引擎[innodb] innodb_file_per_table # 使用獨享表空間 max_connections = 4096 # 最大鏈接數是4096 (默認是1024) collation-server = utf8_general_ci # 數據庫默認校對規則 character-set-server = utf8 # 默認字符集 或者 vim /etc/my.cnf [mysqld] bind-address = 192.168.100.10 default-storage-engine = innodb innodb_file_per_table max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8
七、查看日誌排錯
目錄:/var/log/nova/、/var/log/neutron/、/var/log/glance/、/var/log/keystone/
使用tail -20 /var/log/nova/nova-server.log能夠看到ERROR字樣的就是錯誤信息。
八、PlacementNotConfigured: This compute is not configured to talk to the placement service的解決辦法
PlacementNotConfigured: This compute is not configured to talk to the placement service 緣由:官方文檔中遺漏了-nova-placement-api的安裝 安裝步驟 1、先安裝openstack octca版本的yum源 yum install https://rdoproject.org/repos/rdo-release.rpm 2、控制節點 yum install openstack-nova-placement-api firewall-cmd --zone=public --add-port=8778/tcp --permanent firewall-cmd --reload systemctl restart httpd 3、計算節點 編輯 /etc/nova/nova.conf 增長 [placement] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = ****** os_region_name = RegionOne 重啓 systemctl restart openstack-nova-compute.service
未完待續。。。
參考網址:
一、controllerha的博客 https://blog.csdn.net/controllerha/article/list/5
二、shhnwangjian https://www.cnblogs.com/shhnwangjian/category/942049.html