1. 程式人生 > >KeyStone服務部署與驗證

KeyStone服務部署與驗證

1、建立資料庫

  

mysql -u root -p

MariaDB [(none)]> create database keystone;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create database nova;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create database nova_api;
Query OK, 
1 row affected (0.00 sec) MariaDB [(none)]> create database neutron; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> create database cinder; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on keystone.* to 'keystone'@'localhost' identified by 'keystone'; Query OK, 0 rows affected (0.00
sec) MariaDB [(none)]> grant all on keystone.* to 'keystone'@'%' identified by 'keystone'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on glance.* to 'glance'@'localhost' identified by 'glance'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on glance.* to '
glance'@'%' identified by 'glance'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on nova.* to 'nova'@'localhost' identified by 'nova'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on nova.* to 'nova'@'%' identified by 'nova'; Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> grant all on nova_api.* to 'nova'@'localhost' identified by 'nova'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on nova_api.* to 'nova'@'%' identified by 'nova'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \ IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \ IDENTIFIED BY 'nova'; MariaDB [(none)]> grant all on neutron.* to 'neutron'@'localhost' identified by 'neutron'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on neutron.* to 'neutron'@'%' identified by 'neutron'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on cinder.* to 'cinder'@'localhost' identified by 'cinder'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on cinder.* to 'cinder'@'%' identified by 'cinder'; Query OK, 0 rows affected (0.00 sec)

 

2、配置keystone.conf配置檔案

vim /etc/keystone/keystone.conf


[database]

connection = mysql+pymysql://keystone:[email protected]/keystone

3、初始化資料庫

su -s /bin/sh -c "keystone-manage db_sync" keystone

4、驗證資料庫是否成功

mysql -h 192.168.90.254 -u keystone -pkeystone -e "use keystone;show tables;";

5、memcache配置

vim /etc/keystone/keystone.conf

[memchache]

servers=192.168.90.254:11211

6、安裝memcache並配置

yum install memcached python-memcached

systemctl enable memcached.service
systemctl start memcached.service

7、更改連線memcache連線地址

vim /etc/sysconf/memcached

OPTIONS="-l 192.168.90.254,::1"

8、驗證

netstat -tlp

9、更改令牌的提供者和驅動

vim /etc/keystone/keystone.conf

provider = fernet

driver = memcache

10、檢視keystone.conf做了什麼編輯

grep '^[a-z]' /etc/keystone/keystone.conf

connection = mysql+pymysql://keystone:[email protected]/keystone
servers = 192.168.90.254:11211
provider = fernet
driver = memcache

11、初始化key

keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone

keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

12、keystone服務註冊

keystone-manage bootstrap --bootstrap-password admin \
  --bootstrap-admin-url http://192.168.90.254:35357/v3/ \
  --bootstrap-internal-url http://192.168.90.254:5000/v3/ \
  --bootstrap-public-url http://192.168.90.254:5000/v3/ \
  --bootstrap-region-id RegionOne

13、配置Apache HTTP伺服器

vim /etc/httpd/conf/httpd.conf

ServerName 192.168.90.254:80

14、建立軟連結

ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

15、啟動httpd

systemctl enable httpd.service

systemctl start httpd.service

16、配置keystone環境變數

export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://192.168.90.254:35357/v3
export OS_IDENTITY_API_VERSION=3

17、建立一個service專案

openstack project create --domain default \
  --description "Service Project" service

18、建立demo專案、使用者、角色,將demo使用者加入demo專案賦予user角色

openstack project create --domain default \
  --description "Demo Project" demo

openstack user create --domain default \
  --password-prompt demo

openstack role create user

openstack role add --project demo --user demo user

19、建立使用者

openstack user create --domain default   --password-prompt glance

openstack role add --project service --user glance admin

openstack user create --domain default   --password-prompt nova

openstack role add --project service --user nova admin

openstack user create --domain default   --password-prompt neutron

openstack role add --project service --user neutron admin

openstack user create --domain default   --password-prompt cinder

openstack role add --project service --user cinder admin

20、驗證是否能請求到令牌

unset OS_AUTH_URL OS_PASSWORD

openstack --os-auth-url http://192.168.90.254:35357/v3 \
  --os-project-domain-name default --os-user-domain-name default \
  --os-project-name admin --os-username admin token issue


openstack --os-auth-url http://192.168.90.254:5000/v3 \
  --os-project-domain-name default --os-user-domain-name default \
  --os-project-name demo --os-username demo token issue

21、建立環境變數指令碼

vim admin-openstack

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL=http://192.168.90.254:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2


vim demo-openstack

export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://192.168.90.254:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2