CentOS7和OpenStack的笔记(一)

CentOS7OpenStack笔记(一)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
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

 

七、安装经常使用软件和工具

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
View Code

 

未完待续。。。

 

参考网址:

一、controllerha的博客   https://blog.csdn.net/controllerha/article/list/5 

二、shhnwangjian https://www.cnblogs.com/shhnwangjian/category/942049.html