Ironic - 裸机统一管理
环境
操作系统: CentOS 7.2 (x86_64)、
OpenStack版本: Newton
node-51 172.16.140.51(ironic controller)
node-52 172.16.140.52(ironic agent)
配置主机名解析
[root@node-51 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.140.51 node-51
安装chrony
[root@node-51 ~]# yum install chrony -y # chrony可以认为就是类似ntp的软件
[root@node-51 ~]# vim /etc/chrony.conf # 编辑chrony配置文件
allow 172.16.140.0/24 # 允许这段地址的ip连接
# 启动服务
[root@node-51 ~]# systemctl enable chronyd
[root@node-51 ~]# systemctl start chronyd
# 验证ntp同步情况
[root@node-51 ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 59.46.44.253 2 6 377 59 -4173us[-4173us] +/- 72ms
^* news.neu.edu.cn 2 6 377 59 -708us[ -666us] +/- 19ms
^? 2001:da8:9000::130 0 6 0 10y +0ns[ +0ns] +/- 0ns
^? dns2.synet.edu.cn 2 7 100 448 -45ms[ -47ms] +/- 68ms
准备OpenStack源
[root@node-51 ~]# yum install centos-release-openstack-newton -y
升级系统
[root@node-51 ~]# yum upgrade -y
安装OpenStack客户端
[root@node-51 ~]# yum install python-openstackclient -y
安装Mariadb
[root@node-51 ~]# yum install mariadb mariadb-server python2-PyMySQL -y # 安装mariadb相关包
[root@node-51 ~]# vim /etc/my.cnf.d/openstack.cnf # 创建openstack mariadb配置文件,添加如下内容
[mysqld]
bind-address = node-51
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
# 启动mariadb服务,并设置开机自启动
[root@node-51 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@node-51 ~]# systemctl start mariadb
[root@node-51 ~]# mysql_secure_installation # mariadb初始化,设置root密码为openstack
安装Rabbitmq
[root@node-51 ~]# yum install rabbitmq-server -y # 安装rabbitmq包
# 启动rabbitmq服务
[root@node-51 ~]# systemctl enable rabbitmq-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@node-51 ~]# systemctl start rabbitmq-server.service
# 创建openstack用户, 密码openstack
[root@node-51 ~]# rabbitmqctl add_user openstack openstack
Creating user "openstack" ...
# 设置openstack用户权限
[root@node-51 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...
安装Memcached
[root@node-51 ~]# yum install memcached python-memcached -y # 安装memcached包
# 启动memcached服务
[root@node-51 ~]# systemctl enable memcached.service
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
[root@node-51 ~]# systemctl start memcached.service
安装Keystone
# 创建keystone数据库
[root@node-51 ~]# mysql -u root -popenstack
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.1.17-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database keystone;
Query OK, 1 row affected (0.00 sec)
创建keystone数据库的keystone用户
MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'localhost' identified by 'keystone';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on keystone.* to 'keystone'@'%' identified by 'keystone';
Query OK, 0 rows affected (0.00 sec)
# http + mod_wsgi启动keystone服务
[root@node-51 ~]# yum install openstack-keystone httpd mod_wsgi # 安装keystone相关包
[root@node-51 ~]# yum install openstack-utils -y # 安装openstack工具包,方便修改配置文件
# 配置keystone连接数据库
[root@node-51 ~]# openstack-config --set \
/etc/keystone/keystone.conf \
database \
connection \
mysql+pymysql://keystone:keystone@node-51/keystone
# 使用fernet token
[root@node-51 ~]# openstack-config --set \
/etc/keystone/keystone.conf \
token \
provider \
fernet
# 同步keystone数据库
[root@node-51 ~]# keystone-manage db_sync
# 登录数据库,查看keystone库是否导入表成功
[root@node-51 ~]# mysql -u root -popenstackWelcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.1.17-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use keystone;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [keystone]> show tables;
+------------------------+
| Tables_in_keystone |
+------------------------+
| access_token |
| assignment |
| config_register |
| consumer |
| credential |
| endpoint |
| endpoint_group |
| federated_user |
| federation_protocol |
| group |
| id_mapping |
| identity_provider |
| idp_remote_ids |
| implied_role |
| local_user |
| mapping |
| migrate_version |
| nonlocal_user |
| password |
| policy |
| policy_association |
| project |
| project_endpoint |
| project_endpoint_group |
| region |
| request_token |
| revocation_event |
| role |
| sensitive_config |
| service |
| service_provider |
| token |
| trust |
| trust_role |
| user |
| user_group_membership |
| whitelisted_config |
+------------------------+
37 rows in set (0.00 sec)
MariaDB [keystone]> exit
Bye
# 初始化fernet key仓库
[root@node-51 ~]# keystone-manage fernet_setup \
--keystone-user keystone \
--keystone-group keystone
[root@node-51 ~]# keystone-manage credential_setup \
--keystone-user keystone \
--keystone-group keystone
# 初始化keystone admin用户,密码为openstack
[root@node-51 ~]# keystone-manage bootstrap \
--bootstrap-password openstack \
--bootstrap-admin-url http://node-51:35357/v3/ \
--bootstrap-internal-url http://node-51:35357/v3/ \
--bootstrap-public-url http://node-51:5000/v3/ \
--bootstrap-region-id RegionOne
# 配置http启动keystone服务
[root@node-51 ~]# vim /etc/httpd/conf/httpd.conf # 编辑httpd配置文件
ServerName node-51 # ServerName替换为node-51
# 创建软连接
[root@node-51 ~]# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
[root@node-51 ~]# ll /etc/httpd/conf.d/
total 16
-rw-r--r-- 1 root root 2926 Jul 18 23:30 autoindex.conf
-rw-r--r-- 1 root root 366 Jul 18 23:30 README
-rw-r--r-- 1 root root 1252 Jul 18 23:22 userdir.conf
-rw-r--r-- 1 root root 824 Jul 18 23:22 welcome.conf
lrwxrwxrwx 1 root root 38 Oct 19 11:35 wsgi-keystone.conf -> /usr/share/keystone/wsgi-keystone.conf
# 启动httpd服务
[root@node-51 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@node-51 ~]# systemctl start httpd
# 验证keystone
[root@node-51 ~]# vim ~/keystonerc # 创建keystonerc文件
export OS_USERNAME=admin
export OS_PASSWORD=openstack
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://node-51:35357/v3
export OS_IDENTITY_API_VERSION=3
[root@node-51 ~]# source ~/keystonerc # 加载keystonerc文件
[root@node-51 ~]# openstack user list # 测试keystone user api
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 48780bee4aed4daab77a44a75fe3b4b8 | admin |
+----------------------------------+-------+
# 创建service项目
[root@node-51 ~]# openstack project create --domain default \
> --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | default |
| enabled | True |
| id | 64fc665189d64d9d828dada15067f452 |
| is_domain | False |
| name | service |
| parent_id | default |
+-------------+----------------------------------+
安装Glance
# 创建glance数据库
[root@node-51 ~]# mysql -uroot -popenstack
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.1.17-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec)
# 创建glance数据库用户
MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'localhost' identified by 'glance';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'%' identified by 'glance';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
# 创建keystone glance用户
[root@node-51 ~]# openstack user create --domain default --password glance glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 6324fc62585d45c2bb13a66fdb1864d2 |
| name | glance |
| password_expires_at | None |
+---------------------+----------------------------------+
# 赋予glance用户admin角色
[root@node-51 ~]# openstack role add --project service --user glance admin
# 创建glance service
[root@node-51 ~]# openstack service create --name glance \
--description "OpenStack Image" p_w_picpath
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 7aecf5cc2c7f4f73a094fa49e0ea369e |
| name | glance |
| type | p_w_picpath |
+-------------+----------------------------------+
# 创建glance service API访问入口地址
[root@node-51 ~]# openstack endpoint create --region RegionOne \
p_w_picpath \
public http://172.16.140.51:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 12424a9794ee4fafa2da4d7dac84d662 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7aecf5cc2c7f4f73a094fa49e0ea369e |
| service_name | glance |
| service_type | p_w_picpath |
| url | http://172.16.140.51:9292 |
+--------------+----------------------------------+
[root@node-51 ~]# openstack endpoint create --region RegionOne \
p_w_picpath \
internal \
http://172.16.140.51:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 27ae33cfa6c24f6db1a11c1e9ad2afb0 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7aecf5cc2c7f4f73a094fa49e0ea369e |
| service_name | glance |
| service_type | p_w_picpath |
| url | http://172.16.140.51:9292 |
+--------------+----------------------------------+
[root@node-51 ~]# openstack endpoint create --region RegionOne \
p_w_picpath \
admin \
http://172.16.140.51:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 70b173108cd44750aea4fd01481459ef |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7aecf5cc2c7f4f73a094fa49e0ea369e |
| service_name | glance |
| service_type | p_w_picpath |
| url | http://172.16.140.51:9292 |
+--------------+----------------------------------+
# 安装glance相关包
[root@node-51 ~]# yum install openstack-glance -y
# 编辑glance配置文件,修改数据库连接部分配置
[root@node-51 ~]# openstack-config --set /etc/glance/glance-api.conf \
database \
connection \
mysql+pymysql://glance:glance@node-51/glance
[root@node-51 ~]# openstack-config --set /etc/glance/glance-registry.conf \
database \
connection \
mysql+pymysql://glance:glance@node-51/glance
# 修改glance api配置文件
[root@node-51 ~]# vim /etc/glance/glance-api.conf
[keystone_authtoken]
auth_uri = http://node-51:5000
auth_url = http://node-51:35357
memcached_servers = node-51:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/p_w_picpaths/
# 修改glance registry配置文件
[root@node-51 ~]# vim /etc/glance/glance-registry.conf
[keystone_authtoken]
auth_uri = http://node-51:5000
auth_url = http://node-51:35357
memcached_servers = node-51:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
[paste_deploy]
flavor = keystone
# 同步glance数据库, 出现deprecation的信息可以忽略
[root@node-51 ~]# glance-manage db_sync
Option "verbose" from group "DEFAULT" is deprecated for removal. Its value may be silently ignored in the future.
/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1171: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade
expire_on_commit=expire_on_commit, _conf=conf)
/usr/lib/python2.7/site-packages/pymysql/cursors.py:146: Warning: Duplicate index 'ix_p_w_picpath_properties_p_w_picpath_id_name' defined on the table 'glance.p_w_picpath_properties'. This is deprecated and will be disallowed in a future release.
result = self._query(query)
# 启动glance服务
[root@node-51 ~]# systemctl enable openstack-glance-api openstack-glance-registry
[root@node-51 ~]# systemctl start openstack-glance-api openstack-glance-registry
# 下载cirros镜像
[root@node-51 ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
# 上传镜像
[root@node-51 ~]# openstack p_w_picpath create "cirros" \
> --file cirros-0.3.4-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --public
+------------------+------------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2016-10-19T06:05:09Z |
| disk_format | qcow2 |
| file | /v2/p_w_picpaths/b23a6384-765b-4ae3-b4b0-4c95e26ac7ca/file |
| id | b23a6384-765b-4ae3-b4b0-4c95e26ac7ca |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 7121240f973245d4a758c5787211216b |
| protected | False |
| schema | /v2/schemas/p_w_picpath |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2016-10-19T06:05:09Z |
| virtual_size | None |
| visibility | public |
+------------------+------------------------------------------------------+
# 查看glance镜像列表
[root@node-51 ~]# openstack p_w_picpath list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| b23a6384-765b-4ae3-b4b0-4c95e26ac7ca | cirros | active |
+--------------------------------------+--------+--------+
安装Ironic
# 创建ironic数据库
[root@node-51 ~]# mysql -uroot -popenstack
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 28
Server version: 10.1.17-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> create database ironic;
Query OK, 1 row affected (0.00 sec)
# 创建数据库ironic用户
MariaDB [(none)]> grant all privileges on ironic.* to 'ironic'@'localhost' identified by 'ironic';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on ironic.* to 'ironic'@'%' identified by 'ironic';
Query OK, 0 rows affected (0.00 sec)
# 安装ironic相关包
[root@node-51 ~]# yum install openstack-ironic-api \
openstack-ironic-conductor \
python-ironicclient qemu-img-ev \
iscsi-initiator-utils \
psmisc \
fuse \
gdisk parted -y
# 编辑ironic配置文件,修改ironic数据库连接
[root@node-51 ~]# openstack-config --set /etc/ironic/ironic.conf \
database \
connection \
mysql+pymysql://ironic:ironic@node-51/ironic
# 修改ironic配置文件
[root@node-51 ~]# vim /etc/ironic/ironic.conf
[DEFAULT]
auth_strategy=keystone
my_ip=172.16.140.51
enabled_network_interfaces = noop
debug = True
[agent]
[amt]
[api]
[audit]
[cimc]
[cisco_ucs]
[conductor]
api_url=http://172.16.140.51:6385
automated_clean = false # 是否开启自动清除磁盘,开启比较耗时间
[console]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://ironic:ironic@172.16.140.51/ironic
[deploy]
[dhcp]
dhcp_provider = none
[disk_partitioner]
[disk_utils]
[drac]
[glance]
glance_host=172.16.140.51
[iboot]
[ilo]
[inspector]
[ipmi]
[irmc]
[ironic_lib]
[iscsi]
[keystone]
[keystone_authtoken]
auth_uri = http://172.16.140.51:5000
auth_url = http://172.16.140.51:35357
memcached_servers = 172.16.140.51:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ironic
password = ironic
[matchmaker_redis]
[metrics]
[metrics_statsd]
[neutron]
[oneview]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_hosts = 172.16.140.51:5672
rabbit_userid = openstack
rabbit_password = openstack
[oslo_messaging_zmq]
[oslo_policy]
[pxe]
tftp_server=172.16.140.51
tftp_root=/tftpboot
tftp_master_path=/tftpboot/master_p_w_picpaths
pxe_bootfile_name=pxelinux.0
pxe_append_params = coreos.autologin # 如果ironic deploy p_w_picpath用的是coreos的话,开启这个有助于排错
# 同步ironic数据库
[root@node-51 ~]# ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema
2016-10-19 14:31:30.992 21099 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
2016-10-19 14:31:30.993 21099 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Context impl MySQLImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running stamp_revision -> 60cf717201bc
# 启动ironic api、conductor服务
[root@node-51 ~]# systemctl enable openstack-ironic-api openstack-ironic-conductor.service
[root@node-51 ~]# systemctl start openstack-ironic-api.service openstack-ironic-conductor.service
# 创建keystone ironic用户
[root@node-51 ~]# openstack user create --password ironic ironic
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 0b284faf14f6407fb502e1c2804c3363 |
| name | ironic |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@node-51 ~]# openstack role add --project service --user ironic admin
# 创建ironic service
[root@node-51 ~]# openstack service create --name ironic --description \
"Ironic baremetal provisioning service" baremetal
+-------------+---------------------------------------+
| Field | Value |
+-------------+---------------------------------------+
| description | Ironic baremetal provisioning service |
| enabled | True |
| id | 1041fc80d30a4f33ac7620d99b239e78 |
| name | ironic |
| type | baremetal |
+-------------+---------------------------------------+
# 创建ironic service endpoint
[root@node-51 ~]# openstack endpoint create --region RegionOne \
baremetal admin http://172.16.140.51:6385
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | d1104db185414482b813c53809a26f26 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 1041fc80d30a4f33ac7620d99b239e78 |
| service_name | ironic |
| service_type | baremetal |
| url | http://172.16.140.51:6385 |
+--------------+----------------------------------+
[root@node-51 ~]# openstack endpoint create --region RegionOne \
baremetal \
public http://172.16.140.51:6385
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 7f6ccafa6fad4590b48ef1b05031aa69 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 1041fc80d30a4f33ac7620d99b239e78 |
| service_name | ironic |
| service_type | baremetal |
| url | http://172.16.140.51:6385 |
+--------------+----------------------------------+
[root@node-51 ~]# openstack endpoint create --region RegionOne \
baremetal \
internal http://172.16.140.51:6385
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 681149e943c849a48f98cf46358cd426 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 1041fc80d30a4f33ac7620d99b239e78 |
| service_name | ironic |
| service_type | baremetal |
| url | http://172.16.140.51:6385 |
+--------------+----------------------------------+
# tips
如果keystone endpoint写的是主机名、域名之类的话,用这条命令可以批量替换为ip地址
[root@node-51 ~]# mysql -uroot -popenstack
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 28
Server version: 10.1.17-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> use keystone;
MariaDB [(none)]> update endpoint set url=(replace(url,'node-51','172.16.140.51'));
创建PXE环境
# 创建tftp的根目录
[root@node-51 ~]# mkdir -p /tftpboot
[root@node-51 ~]# chown -R ironic /tftpboot
[root@node-51 ~]# mkdir -p /tftpboot/master_p_w_picpaths
# 安装tftp相关包
[root@node-51 ~]# yum install tftp-server syslinux-tftpboot xinetd -y
# 拷贝pxe p_w_picpath、chain.c32到/tftpboot目录下
[root@node-51 ~]# cp /var/lib/tftpboot/pxelinux.0 /tftpboot
[root@node-51 ~]# cp /var/lib/tftpboot/chain.c32 /tftpboot
# 创建tftp map file
[root@node-51 ~]# echo 're ^(/tftpboot/) /tftpboot/\2' > /tftpboot/map-file
[root@node-51 ~]# echo 're ^/tftpboot/ /tftpboot/' >> /tftpboot/map-file
[root@node-51 ~]# echo 're ^(^/) /tftpboot/\1' >> /tftpboot/map-file
[root@node-51 ~]# echo 're ^([^/]) /tftpboot/\1' >> /tftpboot/map-file
# 安装dnsmasq
[root@node-51 ~]# yum install -y dnsmasq
[root@node-51 ~]# cat /etc/dnsmasq.conf
dhcp-range=172.16.140.52,172.16.140.53,255.255.255.0,infinite
dhcp-host=0c:c4:7a:53:3f:ca,172.16.140.52,node-52 # 这里做了静态ip绑定mac
dhcp-leasefile=/var/lib/dnsmasq/dnsmasq.leases
dhcp-option=3,172.16.140.1
expand-hosts
domain-needed
no-resolv
no-poll
no-hosts
cache-size=500
log-queries
log-facility=/var/log/dnsmasq.log
log-async=20
enable-tftp
tftp-root=/tftpboot
dhcp-boot=pxelinux.0
# 启动&开机自启动dnsmasq
[root@node-51 ~]# systemctl enable dnsmasq
[root@node-51 ~]# systemctl start dnsmasq
下载Ironic Deploy镜像
[root@node-51 ~]# wget -c http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe-stable-newton.vmlinuz \
-p /tftpboot/
[root@node-51 ~]# wget -c http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_p_w_picpath-oem-stable-newton.cpio.gz \
-p /tftpboot/
制作Ironic系统镜像
参考这里:http://docs.openstack.org/project-install-guide/baremetal/draft/deploy-ramdisk.html#deploy-ramdisk
[root@node-51 ~]# ll /tftpboot/centos7/ # 这里做了个centos7的ironic镜像
total 1308684
-rw-r--r-- 1 ironic ironic 45767864 Oct 19 20:36 centos7.2.initrd
-rw-r--r-- 1 ironic ironic 1289164800 Oct 19 20:37 centos7.2.qcow2
-rwxr-xr-x 1 ironic ironic 5155536 Oct 19 20:37 centos7.2.vmlinuz
[root@node-51 ~]# chown -R ironic /tftpboot
创建Ironic节点
#添加主机到ironic
ironic node-create -d pxe_ipmitool \
-i ipmi_address=172.16.130.52 \
-i ipmi_username=ADMIN \
-i ipmi_password=admin \
-i deploy_kernel=file:///tftpboot/coreos_production_pxe-stable-newton.vmlinuz \
-i deploy_ramdisk=file:////tftpboot/coreos_production_pxe_p_w_picpath-oem-stable-newton.cpio
#创建dhcp端口
ironic port-create -n 5a0b47f8-98dc-4296-8d6c-9b7c25e6c893(ironic节点id) \
-a 0c:c4:7a:53:3f:ca(node-52实际mac地址)
#设置镜像信息
ironic node-update 5a0b47f8-98dc-4296-8d6c-9b7c25e6c893 \
add instance_info/p_w_picpath_source=file:///tftpboot/centos7/centos7.2.qcow2 \
instance_info/kernel=file:///tftpboot/centos7/centos7.2.vmlinuz \
instance_info/ramdisk=file:///tftpboot/centos7/centos7.2.initrd \
instance_info/root_gb=30
#部署操作系统
ironic node-set-provision-state 5a0b47f8-98dc-4296-8d6c-9b7c25e6c893 active
#取消部署操作系统
ironic node-set-provision-state 5a0b47f8-98dc-4296-8d6c-9b7c25e6c893 deleted
参考链接
http://docs.openstack.org/project-install-guide/baremetal/draft/deploy-ramdisk.html#deploy-ramdisk
http://docs.openstack.org/developer/ironic-python-agent/troubleshooting.html
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341