Openstack单控制节点灾难恢复

Scope:openstack 单 ctrl 节点环境机器发生故障之后,在不影响现有 vm 的状态下。利用备 份的配置文件,数据库,重新搭建一个 ctrl 节点,使集群恢复正常运行。

Openstack version Rocky , System version centos CentOS Linux release 7.2.1511 (Core)

IPHostnameServiceScope
192.168.8.134openstack-keystonemysql,memcache dashboard解析 3306 11211 80
192.168.8.134ctrlkeystone解析 5000
192.168.8.135openstack-ctrlnova neutron rabbitmq glance故障前 ctrl
192.168.8.136openstack-novanova-computevm
192.168.8.138openstack-ctrlnova neutron rabbitmq glance故障后 ctrl

host解析

192.168.8.134 openstack-keystone
192.168.8.134 ctrl
192.168.8.135 openstack-ctrl
192.168.8.136 openstack-nova

Env install:192.168.8.134

 yum install mariadb mariadb-server python2-PyMySQL
[root@openstack-keystone ~]# cat /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.8.134
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
# systemctl enable mariadb.service
# systemctl start mariadb.service
# mysql_secure_installation
yum install rabbitmq-server
# systemctl enable rabbitmq-server.service
 systemctl start rabbitmq-server.service
# rabbitmqctl add_user openstack passw0rd
# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
# yum install memcached python-memcached
[root@openstack-keystone ~]# cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="192.168.8.134"
# systemctl enable memcached.service
# systemctl start memcached.service
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY
'passw0rd';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'passw0r
d';
# yum install openstack-keystone httpd mod_wsgi
[root@openstack-keystone ~]# cat /etc/keystone/keystone.conf |grep -v ^$ |gr
ep -v ^#
[database]
connection = mysql+pymysql://keystone:passw0rd@openstack-keystone/keystone
# su -s /bin/sh -c "keystone-manage db_sync" keystone
# keystone-manage fernet_setup --keystone-user keystone --keystone-group key
stone
# keystone-manage credential_setup --keystone-user keystone --keystone-grou
p keystone
# keystone-manage bootstrap --bootstrap-password passw0rd \
 --bootstrap-admin-url http://ctrl:5000/v3/ \
 --bootstrap-internal-url http://ctrl:5000/v3/ \
 --bootstrap-public-url http://ctrl:5000/v3/ \
 --bootstrap-region-id RegionOne
Edit the /etc/httpd/conf/httpd.conf file and configure the ServerName
# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
# systemctl enable httpd.service
# systemctl start httpd.service
[root@openstack-keystone ~]# cat openrc
export OS_USERNAME=admin
export OS_PASSWORD=passw0rd
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://ctrl:5000/v3
export OS_IDENTITY_API_VERSION=3

Env install:192.168.8.135

192.168.8.134 执行
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'p
assw0rd';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'passw0rd
';
$ openstack user create --domain default --password-prompt glance
$ openstack role add --project service --user glance admin
$ openstack service create --name glance --description "OpenStack Image" ima
ge
$ openstack endpoint create --region RegionOne image public http://openstack
-keystone:9292
$ openstack endpoint create --region RegionOne image internal http://opensta
ck-keystone:9292
 openstack endpoint create --region RegionOne image admin http://openstackkeystone:9292
192.168.8.135 执行
# yum install openstack-glance
[root@openstack-ctrl ~]# cat /etc/glance/glance-api.conf |grep -v ^$ |grep -
v ^#
[DEFAULT]
[cors]
[database]
connection = mysql+pymysql://glance:passw0rd@openstack-keystone/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[keystone_authtoken]
www_authenticate_uri = http://ctrl:5000
auth_url = http://ctrl:5000
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = passw0rd
[paste_deploy]
flavor = keystone
[root@openstack-ctrl ~]# cat /etc/glance/glance-registry.conf |grep -v ^$ |g
rep -v ^#
[database]
connection = mysql+pymysql://glance:passw0rd@openstack-keystone/glance
[keystone_authtoken]
www_authenticate_uri = http://ctrl:5000
auth_url = http://ctrl:5000
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = passw0rd
[paste_deploy]
flavor = keystone
# systemctl enable openstack-glance-api.service openstack-glance-registry.s
ervice
# systemctl start openstack-glance-api.service openstack-glance-registry.se
rvice
192.168.8.134 执行
CREATE DATABASE nova_api;
CREATE DATABASE nova;
CREATE DATABASE nova_cell0;
CREATE DATABASE placement;
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'p
assw0rd';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'passw0rd
';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'passw
0rd';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'passw0rd';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY
'passw0rd';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'passw0r
d';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED
BY 'passw0rd';
GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'pas
sw0rd';
$ openstack user create --domain default --password-prompt nova
$ openstack role add --project service --user nova admin
$ openstack service create --name nova --description "OpenStack Compute" com
pute
$ openstack endpoint create --region RegionOne compute public http://opensta
ck-keystone:8774/v2.1
$ openstack endpoint create --region RegionOne compute internal http://opens
tack-keystone:8774/v2.1
$ openstack endpoint create --region RegionOne compute admin http://openstac
k-keystone:8774/v2.1
$ openstack user create --domain default --password-prompt placement
$ openstack role add --project service --user placement admin
$ openstack service create --name placement --description "Placement API" pl
acement
$ openstack endpoint create --region RegionOne placement public http://opens
tack-keystone:8778
$ openstack endpoint create --region RegionOne placement internal http://ope
nstack-keystone:8778
$ openstack endpoint create --region RegionOne placement admin http://openst
ack-keystone:8778
# yum install openstack-nova-api openstack-nova-conductor openstack-nova-co
nsole openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-pla
cement-api
192.168.8.135 执行
[root@openstack-ctrl ~]# cat /etc/nova/nova.conf |grep -v ^$ |grep -v ^#
[DEFAULT]
my_ip = 192.168.8.135
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:passw0rd@openstack-keystone
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
connection = mysql+pymysql://nova:passw0rd@openstack-keystone/nova_api
[database]
connection = mysql+pymysql://nova:passw0rd@openstack-keystone/nova
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://openstack-ctrl:9292
[keystone_authtoken]
auth_url = http://ctrl:5000/v3
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = passw0rd
[libvirt]
virt_type=qemu
[neutron]
url = http://openstack-ctrl:9696
auth_url = http://ctrl:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = passw0rd
service_metadata_proxy = true
metadata_proxy_shared_secret = passw0rd
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://ctrl:5000/v3
username = placement
password = passw0rd
[placement_database]
connection = mysql+pymysql://placement:passw0rd@openstack-keystone/placemen
t
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
novncproxy_base_url = http://openstack-ctrl:6080/vnc_auto.html
# su -s /bin/sh -c "nova-manage api_db sync" nova
# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose"
nova
# su -s /bin/sh -c "nova-manage db sync" nova
# nova-manage cell_v2 list_cells
# systemctl enable openstack-nova-api.service openstack-nova-scheduler.serv
ice openstack-nova-conductor.service openstack-nova-novncproxy.service
# systemctl start openstack-nova-api.service openstack-nova-scheduler.servi
ce openstack-nova-conductor.service openstack-nova-novncproxy.service
192.168.8.134 执行
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY
'passw0rd';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'passw0r
d';
$ openstack user create --domain default --password-prompt neutron
$ openstack role add --project service --user neutron admin
$ openstack service create --name neutron --description "OpenStack Networkin
g" network
$ openstack endpoint create --region RegionOne network public http://opensta
ck-keystone:9696
$ openstack endpoint create --region RegionOne network internal http://opens
tack-keystone:9696
$ openstack endpoint create --region RegionOne network admin http://openstac
k-keystone:9696
192.168.8.135 执行
# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-lin
uxbridge ebtables
[DEFAULT]
core_plugin = ml2
service_plugins =
transport_url = rabbit://openstack:passw0rd@openstack-keystone
uth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[database]
connection = mysql+pymysql://neutron:passw0rd@openstack-keystone/neutron
[keystone_authtoken]
www_authenticate_uri = http://ctrl:5000
auth_url = http://ctrl:5000
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = passw0rd
[nova]
auth_url = http://ctrl:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = passw0rd
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
[root@openstack-ctrl ~]# cat /etc/neutron/plugins/ml2/ml2_conf.ini |grep -v
^$ |grep -v ^#
[ml2]
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[securitygroup]
enable_ipset = true
[root@openstack-ctrl ~]# cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini
|grep -v ^$ |grep -v ^#
[linux_bridge]
physical_interface_mappings = provider:eno16777736 ##后面跟自己的网卡
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDri
ver
[vxlan]
enable_vxlan = false
[root@openstack-ctrl ~]# cat /etc/neutron/dhcp_agent.ini|grep -v ^$ |grep -v
^#
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
[root@openstack-ctrl ~]# cat /etc/neutron/metadata_agent.ini |grep -v ^$ |gr
ep -v ^#
[DEFAULT]
nova_metadata_host = openstack-ctrl
metadata_proxy_shared_secret = passw0rd
# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.con
f --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
# systemctl enable neutron-server.service neutron-linuxbridge-agent.service
neutron-dhcp-agent.service neutron-metadata-agent.service
# systemctl start neutron-server.service neutron-linuxbridge-agent.service
neutron-dhcp-agent.service neutron-metadata-agent.service

Env install:192.168.8.136

# yum install openstack-nova-compute openstack-neutron-linuxbridge ebtables
ipset
[root@openstack-nova ~]# cat /etc/nova/nova.conf |grep -v ^# |grep -v ^$
[DEFAULT]
my_ip = 192.168.8.136
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:passw0rd@openstack-keystone
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
connection = mysql+pymysql://nova:passw0rd@openstack-keystone/nova_api
[database]
connection = mysql+pymysql://nova:passw0rd@openstack-keystone/nova
[glance]
api_servers = http://openstack-ctrl:9292
[keystone_authtoken]
auth_url = http://ctrl:5000/v3
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = passw0rd
[libvirt]
virt_type=qemu
[neutron]
url = http://openstack-ctrl:9696
auth_url = http://ctrl:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = passw0rd
service_metadata_proxy = true
metadata_proxy_shared_secret = passw0rd
[osapi_v21]
[oslo_concurrency]
lock_path = /var/lib/nova/tmp
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://ctrl:5000/v3
username = placement
password = passw0rd
[placement_database]
connection = mysql+pymysql://placement:passw0rd@openstack-keystone/placemen
t
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
novncproxy_base_url = http://openstack-ctrl:6080/vnc_auto.html
[root@openstack-nova ~]# cat /etc/neutron/neutron.conf |grep -v ^# |grep -
v ^$
[DEFAULT]
core_plugin = ml2
service_plugins =
transport_url = rabbit://openstack:passw0rd@openstack-keystone
uth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[database]
connection = mysql+pymysql://neutron:passw0rd@openstack-keystone/neutron
[keystone_authtoken]
www_authenticate_uri = http://ctrl:5000
auth_url = http://ctrl:5000
memcached_servers = openstack-keystone:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = passw0rd
[nova]
auth_url = http://ctrl:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = passw0rd
[oslo_concurrency]
lock_path = /var/lib/neutron/tmp
[root@openstack-nova ~]# cat /etc/neutron/plugins/ml2/linuxbridge_agent.in
i
[DEFAULT]
[agent]
[linux_bridge]
physical_interface_mappings = provider:eno16777736
[network_log]
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDri
ver
[vxlan]
enable_vxlan = false
# systemctl enable neutron-linuxbridge-agent.service
# systemctl start neutron-linuxbridge-agent.service
# systemctl enable libvirtd.service openstack-nova-compute.service
# systemctl start libvirtd.service openstack-nova-compute.service

验证:

集群现在正常运行。我们模拟故障关闭 192.168.8.135 节点。

新创建一个 vm 192.168.8.138 hostname 使用 openstack-ctrl,

修改所有机器的 h osts 文件如下。 此时操作是在 192.168.8.138。

[root@openstack-ctrl ~]# cat /etc/hosts

192.168.8.134 openstack-keystone

192.168.8.134 ctrl

192.168.8.138 openstack-ctrl

192.168.8.136 openstack-nova

安装 nova glance neutron,

配置文件使用 192.168.8.135 的配置文件。

启动服务,创建 vm,验证即可。

keystone memcache openstack-dashboard 故障切换方法一样。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

python知行通

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值