添加新的计算节点(老王笔记)

添加新的计算节点

一、克隆计算节点 (Networking服务安装完的快照)

修改ip地址

$ vi /etc/sysconfig/network-scripts/ifcfg-ens33
	IPADDR=192.168.100.42

重启网络

$ systemctl restart network

修改所有hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 compute2	#修改
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 compute2	#修改
192.168.100.41 controller controller.locallocaldomain
192.168.100.42 compute2 compute2.locallocaldomain	#添加
192.168.100.43 compute1 compute1.locallocaldomain
192.168.100.44 block1 block1.locallocaldomain

修改hostname

$ hostnamectl set-hostname compute2

二、修改nova配置文件(新计算节点)

修改 /etc/nova/nova.conf ,修改为对应ip

$ vi /etc/nova/nova.conf
[DEFAULT]
my_ip = 192.168.100.42
...
[libvirt]
virt_type = qemu
cpu_mode = none

重启计算服务

$ systemctl restart libvirtd.service openstack-nova-compute.service

重启Linuxbridge代理

$ systemctl restart neutron-linuxbridge-agent.service

三、加入计算节点(控制节点)

发现计算节点

$ su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova

查看服务状态

$ openstack hypervisor list

$ openstack compute service list --service nova-compute

$ openstack compute service list

$ openstack network agent list #缺少compute2则在compute2 重启Linuxbridge代理

创建实例,指定compute2节点

$ openstack server create --flavor m1.nano --image cirros --key-name mykey --availability-zone nova:compute2:compute2 computer2

迁移Glance到compute2

1、在控制节点停止glance服务(Controller)

$ systemctl stop openstack-glance-api.service openstack-glance-registry.service
$ systemctl disable openstack-glance-api.service openstack-glance-registry.service

2、compute2节点环境配置(Compute2)

  • 在computer2上安装数据库mariadb,启动服务

    $ yum install mariadb mariadb-server python2-PyMySQL -y
    $ vi /etc/my.cnf.d/openstack.cnf
    [mysqld]
    bind-address = 192.168.100.42
    default-storage-engine = innodb
    innodb_file_per_table
    max_connections = 4096
    collation-server = utf8_general_ci
    character-set-server = utf8
    
    $ systemctl enable mariadb.service
    $ systemctl start mariadb.service
    
  • 安全初始化 (n,y,y,y,y)

    $ mysql_secure_installation
    

3、对glance数据库进行修改(Controller)

  • 到控制节点备份数据库的数据

    $ mysqldump -B glance >glance.sql
    
  • 将备份文件推送到computer2

    $ scp glance.sql 192.168.100.42:/root
    
  • 在computer2导入数据库库文件

    $ mysql < glance.sql
    
  • 确认导入文件

    $ mysql glance -e 'show tables;'
    
  • 登录数据库创建授权命令

    mysql -u root -p
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
    

4、安装配置glance服务(Compute2)

  • 安装glance服务

    $ yum install openstack-glance -y
    
  • 获取配置文件

    $ scp -rp 192.168.100.41:/etc/glance/glance-api.conf /etc/glance/glance-api.conf
    $ scp -rp 192.168.100.41:/etc/glance/glance-registry.conf /etc/glance/glance-registry.conf
    
  • 修改配置文件 vim /etc/glance/glance-api.confvim /etc/glance/glance-registry.conf

    $ vi /etc/glance/glance-api.conf
    [database]
    ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@192.168.100.42/glance
    
    $ vi /etc/glance/glance-registry.conf
    [database]
    ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@192.168.100.42/glance
    
  • 启动服务

    $ systemctl start openstack-glance-api.service openstack-glance-registry.service
    $ systemctl enable openstack-glance-api.service openstack-glance-registry.service
    
  • 验证端口 netstat -lntup的9191和9292端口

5、镜像文件迁移(Compute2)

$ scp -rp 192.168.100.41:/var/lib/glance/images/* /var/lib/glance/images/

修改权限

$ chown glance:glance /var/lib/glance/images/*

6、修改keystone里的glance的服务命令(控制节点)

$ openstack endpoint list|grep image
# 备份endpoint表(也可以用数据库的update语句完成)
$ mysqldump keystone endpoint >endpoint.sql
$ cp endpoint.sql /opt/
$ vi endpoint.sql
	:%s#http://controller:9292#http://192.168.100.42:9292#gc
	:wq
# 或直接搜索修改
$ mysql keystone < endpoint.sql
$ openstack endpoint list|grep image
$ openstack image list

7、修改所有节点nova的配置文件(所有节点)

$ sed 's#api_servers = http://controller:9292#api_servers = http://192.168.100.42:9292#g' /etc/nova/nova.conf|grep 9292
$ sed -i 's#api_servers = http://controller:9292#api_servers = http://192.168.100.42:9292#g' /etc/nova/nova.conf|grep 9292

8、重启服务

控制节点:

$ systemctl restart openstack-nova-api

计算节点

$ systemctl restart openstack-nova-compute

9、验证以上所有操作

$ grep ERROR nova-api.log |tail -30
上一篇:openstack篇 glance组件概念和部署


下一篇:一文读懂OpenStack Glance是什么