CentOS7和OpenStack的笔记(一)
CentOS7和OpenStack的笔记(一)
CentOS7和OpenStack的笔记(一)
最近搞CentOS7系统和OpenStack框架,整了近一个星期,系统装了好几次,框架搭了又从搭。虽然最后的实例没能启动成功,但是在这专研的一个星期里,也算是有了很多的心得体会,在此记下,方便以后查看。
一、CentOS7
1、主机名修改
- hostnamectl set-hostname MyHostname
2、修改网卡名
在顺利的条件下改网卡名很简单:
在/etc/sysconfig/network-scripts/目录下,查看是否有网卡接口文件,名字一般为ifcfg-eno16777736类似的文件。
编辑文件 vi ifcfg-eno16777736
将里面的DEVICE=eno16777736和NAME=eno16777736修改成
- DEVICE=eth0
- NAME=eth0
重启即可改网卡名。如果不成功,网上很多教程。
3、防火墙和SELinux
关闭防火墙firewalld,CentOS7应该是不再使用iptables了,关闭firewall即可关闭防火墙
- systemctl stop firewalld.service
- systemctl disable firewalld.service
关闭SELinux
- vim /etc/selinux/config
- 修改
- SELINUX=disable
- 退出后使用命令即时生效
- setenforce 0
4、系统镜像DVD镜像文件里有很多软件,可以设置成yum源,即做成本地yum仓库
- vi /etc/yum.repos.d/local.repo
- [centos]
- name=centos
- baseurl=file:///opt/centos/
- gpgcheck=0
- enabled=1
5、安装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是否关闭。
6、修改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
TUNA源
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
EPEL-TUNA
7、安装常用软件和工具
- yum install -y net-tools vim lrzsz tree screen lsof tcpdump
8、更新系统并重启
- yum update -y && reboot
给虚拟机做快照
9、踢掉用户
使用w命令可以看到在线的用户
踢掉pts/1用户
- pkill -kill -t pts/1
10、ssh登录很久都上不去
- 使用root权限修改ssh的配置文件
- vim /etc/ssh/sshd_config
- 最后增加一行记录:
- UseDNS no
二、OpenStack
1、虚拟机要记得开启CPU虚拟化
2、可以设置两块网卡,也可以设置一块网卡来启动实例
两块网卡:一块是连接公网使用,一块是内部网络使用
一块网卡:一块网卡,即是内部管理网络,也是连接公网的网络。
虚拟机网络设置,如果是自己设置的IP地址,发现是上不了网。不清楚有什么办法解决。如果是DHCP获取的地址就可以正常上网。
3、内存大小设置
我这里是双节点设置,即,controller节点和compute节点
controller节点比较重要,设置内存4G;建议内存不要太小,不然很吃力。
compute节点,设置内存2G;
4、时间同步
- 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
进行一次性的同步
5、数据库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
7、查看日志排错
目录:/var/log/nova/、/var/log/neutron/、/var/log/glance/、/var/log/keystone/
使用tail -20 /var/log/nova/nova-server.log可以看到ERROR字样的就是错误信息。
8、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
View Code
未完待续。。。
参考网址:
1、controllerha的博客 https://blog.csdn.net/controllerha/article/list/5
2、shhnwangjian https://www.cnblogs.com/shhnwangjian/category/942049.html
posted on 2018-06-15 14:47 FA-learning 阅读(…) 评论(…) 编辑 收藏