CentOS7OpenStack笔记(一)

  最近搞CentOS7系统和OpenStack框架,整了近一个星期,系统装了好几次,框架搭了又从搭。虽然最后的实例没能启动成功,但是在这专研的一个星期里,也算是有了很多的心得体会,在此记下,方便以后查看。

 


 

一、CentOS7

1、主机名修改

  1. hostnamectl set-hostname MyHostname

 

 2、修改网卡名

在顺利的条件下改网卡名很简单:

  在/etc/sysconfig/network-scripts/目录下,查看是否有网卡接口文件,名字一般为ifcfg-eno16777736类似的文件。

  编辑文件 vi ifcfg-eno16777736

  将里面的DEVICE=eno16777736和NAME=eno16777736修改成

  1. DEVICE=eth0
  2. NAME=eth0

  重启即可改网卡名。如果不成功,网上很多教程。

 

3、防火墙和SELinux

关闭防火墙firewalld,CentOS7应该是不再使用iptables了,关闭firewall即可关闭防火墙

  1. systemctl stop firewalld.service
  2. systemctl disable firewalld.service

关闭SELinux

  1. vim /etc/selinux/config
  2. 修改
  3. SELINUX=disable
  4. 退出后使用命令即时生效
  5. setenforce 0

 

 4、系统镜像DVD镜像文件里有很多软件,可以设置成yum源,即做成本地yum仓库

  1. vi /etc/yum.repos.d/local.repo
  2. [centos]
  3. name=centos
  4. baseurl=file:///opt/centos/
  5. gpgcheck=0
  6. enabled=1

 

5、安装vsftp共享本地yum源

  1. yum install vsftpd -y
    vi
    /etc/vsftpd/vsftpd.service
  2. 在最后新增一行
  3. anon_root=/opt
  4. 启动vsftp并开机自启
  5. systemctl start vsftpd.service
  6. systemctl enable vsftpd.service

另一台机器使用ftp源

  1. vi /etc/yum.repos.d/local.repo
  2. [centos]
  3. name=centos
  4. baseurl=ftp://192.168.100.10/centos/
  5. gpgcheck=0
  6. enabled=1

测试yum源

  1. yum list

如果计算节点yum list出错,检查一下双方节点是否能ping通,检查防火墙和selinux是否关闭。

 

6、修改yum源为清华源,安装EPEL 仓库

使用清华源比较稳定,阿里源不是很好用,有些镜像点不能访问到,或者速度很慢。

网站: https://mirrors.tuna.tsinghua.edu.cn/help/centos/

  1. 删除开始所有的yum
  2. rm -f /etc/yum.repos.d/*
  3. vim /etc/yum.repos.d/CentOS-Base.repo
  4. 将以下内容写入
  5. # CentOS-Base.repo
  6. #
  7. # The mirror system uses the connecting IP address of the client and the
  8. # update status of each mirror to pick mirrors that are updated to and
  9. # geographically close to the client. You should use this for CentOS updates
  10. # unless you are manually picking other mirrors.
  11. #
  12. # If the mirrorlist= does not work for you, as a fall back you can try the
  13. # remarked out baseurl= line instead.
  14. #
  15. #
  16. [base]
  17. name=CentOS-$releasever - Base
  18. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
  19. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  20. gpgcheck=1
  21. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  22. #released updates
  23. [updates]
  24. name=CentOS-$releasever - Updates
  25. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
  26. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  27. gpgcheck=1
  28. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  29. #additional packages that may be useful
  30. [extras]
  31. name=CentOS-$releasever - Extras
  32. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
  33. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  34. gpgcheck=1
  35. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  36. #additional packages that extend functionality of existing packages
  37. [centosplus]
  38. name=CentOS-$releasever - Plus
  39. baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
  40. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  41. gpgcheck=1
  42. enabled=0
  43. 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/

  1. yum install epel-release -y
  2. vim /etc/yum.repos.d/epel.repo
  3. [epel]
  4. name=Extra Packages for Enterprise Linux 7 - $basearch
  5. baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch
  6. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
  7. failovermethod=priority
  8. enabled=1
  9. gpgcheck=1
  10. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  11. [epel-debuginfo]
  12. name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
  13. baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug
  14. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
  15. failovermethod=priority
  16. enabled=0
  17. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  18. gpgcheck=1
  19. [epel-source]
  20. name=Extra Packages for Enterprise Linux 7 - $basearch - Source
  21. baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS
  22. #mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
  23. failovermethod=priority
  24. enabled=0
  25. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
  26. gpgcheck=1
  27.  
  28. yum makecache
  29. yum update

EPEL-TUNA

 

7、安装常用软件和工具

  1. yum install -y net-tools vim lrzsz tree screen lsof tcpdump

 

8、更新系统并重启

  1. yum update -y && reboot

给虚拟机做快照

 

9、踢掉用户

  使用w命令可以看到在线的用户

 

  踢掉pts/1用户

  1. pkill -kill -t pts/1

 

10、ssh登录很久都上不去

  1. 使用root权限修改ssh的配置文件
  2. vim /etc/ssh/sshd_config
  3. 最后增加一行记录:
  4. UseDNS no

 

 


 

二、OpenStack

 1、虚拟机要记得开启CPU虚拟化

 

2、可以设置两块网卡,也可以设置一块网卡来启动实例

两块网卡:一块是连接公网使用,一块是内部网络使用

一块网卡:一块网卡,即是内部管理网络,也是连接公网的网络。

虚拟机网络设置,如果是自己设置的IP地址,发现是上不了网。不清楚有什么办法解决。如果是DHCP获取的地址就可以正常上网。

 

3、内存大小设置

我这里是双节点设置,即,controller节点和compute节点

 controller节点比较重要,设置内存4G;建议内存不要太小,不然很吃力。

compute节点,设置内存2G

 

4、时间同步

  1. 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

  1. yum install -y mariadb mariadb-server python2-PyMySQL
  2. cd /etc/my.cnf.d/
  3. vim openstack.cnf
  4. [mysqld]
  5. bind-address = 192.168.137.11 # 监听的IP地址(也可以写0.0.0.0
  6. default-storage-engine = innodb # 默认存储引擎[innodb]
  7. innodb_file_per_table # 使用独享表空间
  8. max_connections = 4096 # 最大连接数是4096 (默认是1024)
  9. collation-server = utf8_general_ci # 数据库默认校对规则
  10. character-set-server = utf8 # 默认字符集
  11. 或者
  12. vim /etc/my.cnf
  13. [mysqld]
  14. bind-address = 192.168.100.10
  15. default-storage-engine = innodb
  16. innodb_file_per_table
  17. max_connections = 4096
  18. collation-server = utf8_general_ci
  19. 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的解决办法

  1. PlacementNotConfigured: This compute is not configured to talk to the placement service
  2. 原因:官方文档中遗漏了-nova-placement-api的安装
  3. 安装步骤
  4. 1、先安装openstack octca版本的yum
  5. yum install https://rdoproject.org/repos/rdo-release.rpm
  6. 2、控制节点
  7. yum install openstack-nova-placement-api
  8. firewall-cmd --zone=public --add-port=8778/tcp --permanent
  9. firewall-cmd --reload
  10. systemctl restart httpd
  11. 3、计算节点
  12. 编辑 /etc/nova/nova.conf
  13. 增加
  14. [placement]
  15. auth_uri = http://controller:5000
  16. auth_url = http://controller:35357
  17. memcached_servers = controller:11211
  18. auth_type = password
  19. project_domain_name = default
  20. user_domain_name = default
  21. project_name = service
  22. username = nova
  23. password = ******
  24. os_region_name = RegionOne
  25. 重启 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 阅读() 评论() 编辑 收藏

版权声明:本文为fa-learning原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/fa-learning/p/9187258.html