Openstack DBBS Trove部署

本文是基于Trove Kilo版本部署的

配置环境变量

source /opt/osdeploy/admin_openrc.sh

下载源码

1
2
git clone https://github.com/openstack/trove.git /opt/openstack/trove
git clone https://github.com/openstack/python-troveclient.git /opt/openstack/python-troveclient

安装 troveclient

1
2
3
4
5
cd /opt/openstack/python-troveclient
git checkout stable/kilo
python setup.py egg_info
pip install -r python_troveclient.egg-info/requires.txt
python setup.py develop

安装 trove kilo版本

1
2
3
4
5
cd /opt/openstack/trove
git checkout stable/kilo
python setup.py egg_info
pip install -r trove.egg-info/requires.txt
python setup.py develop

问题

IOError: [Errno 2] No such file or directory: ‘/opt/openstack/.venv/build/oslo.serialization/oslo.serialization-2.2.0.dist-info/METADATA’

解决

把build下面的所有东西都删除就行了。rm -rf /opt/openstack/.venv/build/*

创建用户

创建trove用户,trove用户添加admin角色,创建trove服务,给 trove 服务添加 api 访问地址

1
2
3
4
openstack user create --password 22116ccf32a trove
openstack role add --project service --user trove admin
openstack service create --name trove --description "OpenStack Trove" database
openstack endpoint create --publicurl 'http://10.10.1.1:8779/v1.0/$(tenant_id)s' --internalurl 'http://10.10.1.1:8779/v1.0/$(tenant_id)s' --adminurl 'http://10.10.1.1:8779/v1.0/$(tenant_id)s' --region RegionOne database

创建trove相关目录,并修改权限

1
2
3
mkdir /opt/etc/trove; chown openstack:openstack /opt/etc/trove
mkdir /var/log/cloud/openstack/trove; chown openstack:openstack /var/log/cloud/openstack/trove
mkdir /var/lib/trove; chown openstack:openstack /var/lib/trove

使用mysql作为trove后端db

在mysql的机器上执行:(查看/opt/etc/nova/nova.conf找到mysql服务所在机器)

1
2
3
mysql -uroot -p
> create database trove default character set utf8;
> grant all on trove.* to 'trove'@'%' identified by 'trove';

注:需要输入mysql的密码

拷贝trove相关配置到/opt/etc/trove目录

1
2
3
4
5
cp /opt/openstack/trove/etc/trove/api-paste.ini /opt/etc/trove/api-paste.ini
cp /opt/openstack/trove/etc/trove/trove.conf.sample /opt/etc/trove/trove.conf
cp /opt/openstack/trove/etc/trove/trove-taskmanager.conf.sample /opt/etc/trove/trove-taskmanager.conf
cp /opt/openstack/trove/etc/trove/trove-conductor.conf.sample /opt/etc/trove/trove-conductor.conf
cp -r /opt/openstack/trove/etc/trove/cloudinit/ /opt/etc/trove/

修改/opt/etc/trove目录里的conf文件

  1. trove.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    rabbit_hosts = 127.0.0.1:5672
    rabbit_userid=openstack
    rabbit_password=iafdhewak2

    trove_auth_url = http://127.0.0.1:5000/v2.0
    nova_compute_url = http://127.0.0.1:8774/v2
    cinder_url = http://127.0.0.1:8776/v2
    neutron_url = http://127.0.0.1:9696/

    log_dir = /var/log/openstack/trove
    log_file = trove-api.log

    connection = mysql://trove:trove@127.0.0.1/trove

    [keystone_authtoken]
    auth_uri = http://127.0.0.1:5000
    auth_url = http://127.0.0.1:35357
    auth_plugin = password
    project_domain_id = default
    user_domain_id = default
    project_name = service
    username = trove
    password = 221***6d42d8ca
  2. trove-taskmanager.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    rabbit_host=127.0.0.1
    rabbit_userid=openstack
    rabbit_password=iafdhewak2

    trove_auth_url = http://127.0.0.1:5000/v2.0
    nova_compute_url = http://127.0.0.1:8774/v2
    cinder_url = http://127.0.0.1:8776/v2
    swift_url = http://127.0.0.1:8080/v1/AUTH_
    neutron_url = http://127.0.0.1:9696/

    log_dir = /var/log/openstack/trove
    log_file = trove-taskmanager.log

    # ================= Guestagent related ========================
    guest_config = /opt/etc/trove/trove-guestagent.conf
    injected_config_location = /etc/trove/conf.d
    cloudinit_location = /opt/etc/trove/cloudinit

    connection = mysql://trove:trove@127.0.0.1/trove
  3. trove-conductor.conf

    1
    2
    3
    4
    5
    trove_auth_url = http://127.0.0.1:5000/v2.0
    rabbit_host = 127.0.0.1
    rabbit_userid = openstack
    rabbit_password = iafdhewak2
    connection = mysql://trove:trove@127.0.0.1/trove
  4. trove-guestagent.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    rabbit_hosts = 192.168.1.3:5672
    rabbit_userid = openstack
    rabbit_password = iafdhewak2
    swift_url = http://192.168.1.3:8080/v1/AUTH_
    os_region_name = RegionOne
    swift_service_type = object-store
    datastore_registry_ext = mysql:trove.guestagent.datastore.mysql.manager.Manager, percona:trove.guestagent.datastore.mysql.manager.Manager
    ignore_users = os_admin
    ignore_dbs = lost+found, mysql, information_schema, performance_schema
    root_grant = ALL
    root_grant_option = True

    storage_strategy = SwiftStorage
    storage_namespace = trove.guestagent.strategies.storage.swift
    backup_swift_container = database_backups

    [keystone_authtoken]
    auth_uri = http://192.168.1.3:5000
    auth_url = http://192.168.1.3:35357
    auth_plugin = password
    project_name = service
    project_domain_id = default
    user_domain_id = default
    username = trove
    password = 221***6d42d8ca

添加包含mysql的ubuntu镜像到glance里

1
2
3
4
5
6
7
8
glance --debug image-create --name "mysql-ubuntu"  --file ~/mysql.qcow2 --disk-format qcow2 --container-format bare --is-public True --progress

(.venv)openstack@cloud01:~$ glance image-list
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+
| 0ad5a403-09fa-4be3-81f8-74caac155be0 | mysql-ubuntu | qcow2 | bare | 533397504 | active |
+--------------------------------------+---------------------+-------------+------------------+-----------+--------+

初始化trove database

因为mysql外键的问题,可能需要执行括号内的额外步骤:

1
2
3
[mysql -uroot -ppwd -e"use trove;SET GLOBAL foreign_key_checks=0;"]
trove-manage --config-file=/opt/etc/trove/trove.conf db_sync
[mysql -uroot -ppwd -e"use trove;SET GLOBAL foreign_key_checks=1;"]

初始化Trove Datastores

1
2
3
4
5
6
7
8
export DATASTORE_TYPE="mysql"
export DATASTORE_VERSION="5.6"
export PACKAGES="mysql-server-5.6"
export IMAGEID="0ad5a403-09fa-4be3-81f8-74caac155be0"
trove-manage --config-file /opt/etc/trove/trove.conf datastore_update ${DATASTORE_TYPE} ""
trove-manage --config-file /opt/etc/trove/trove.conf datastore_version_update ${DATASTORE_TYPE} ${DATASTORE_VERSION} ${DATASTORE_TYPE} ${IMAGEID} ${PACKAGES} 1
trove-manage --config-file /opt/etc/trove/trove.conf datastore_update ${DATASTORE_TYPE} ${DATASTORE_VERSION}
trove datastore-version-show ${DATASTORE_VERSION} --datastore ${DATASTORE_TYPE}

重启trove service

1
service trove-api restart; service trove-taskmanager restart; service trove-conductor restart;

配置datastore的默认值

修改trove.conf,在[default]字段添加:

1
default_datastore = mysql

查看datastore mysql的default version值:

1
2
3
4
5
6
7
8
9
10
11
$ trove datastore-show mysql
...
| default_version | 9b8987aa-282b-46b9-af19-900aadfa8d9b |
...
$ trove datastore-version-list mysql
+--------------------------------------+------+
| ID | Name |
+--------------------------------------+------+
| 1832c3bd-3233-45ef-b6fe-c00fc6b4750e | 5.7 |
| 9b8987aa-282b-46b9-af19-900aadfa8d9b | 5.6 |
+--------------------------------------+------+

配置mysql, 5.6版本的config parameters

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
trove-manage --config-file /opt/etc/trove/trove.conf db_load_datastore_config_parameters mysql 5.6 /opt/openstack/trove/trove/templates/mysql/validation-rules.json

$ openstack endpoint show trove
+--------------+------------------------------------------+
| Field | Value |
+--------------+------------------------------------------+
| adminurl | http://127.0.0.1:8779/v1.0/$(tenant_id)s |
| enabled | True |
| id | 677e119b1309446590e174f1f2fb2d80 |
| internalurl | http://127.0.0.1:8779/v1.0/$(tenant_id)s |
| publicurl | http://127.0.0.1:8779/v1.0/$(tenant_id)s |
| region | RegionOne |
| service_id | 4f456705ce124c62918f29b4b70b5ed1 |
| service_name | trove |
| service_type | database |
+--------------+------------------------------------------+
(.venv)openstack@cloud01:~$ trove datastore-list
+--------------------------------------+-------+
| ID | Name |
+--------------------------------------+-------+
| 2f2c8eee-cac5-4a52-9f89-9c39a140f611 | mysql |
+--------------------------------------+-------+
(.venv)openstack@cloud01:~$ trove create myFirstDB 1 --size 2 --databases trovedb --users ictfox:ictfox --datastore_version 5.6 --datastore mysql
+-------------------+--------------------------------------+
| Property | Value |
+-------------------+--------------------------------------+
| created | 2016-01-22T11:41:48 |
| datastore | mysql |
| datastore_version | 5.6 |
| flavor | 2 |
| id | 31dbea3e-1117-407e-82f0-cdf7ecd3ac3b |
| name | myFirstDB |
| status | BUILD |
| updated | 2016-01-22T11:41:48 |
| volume | 2 |
+-------------------+--------------------------------------+

参考资料

http://docs.openstack.org/kilo/config-reference/content/ch_configuring-trove.html
http://docs.openstack.org/developer/trove/dev/manual_install.html
https://github.com/openstack/trove/blob/master/doc/source/dev/manual_install.rst
https://www.youtube.com/watch?v=zk42zzc_38o
http://blog.csdn.net/myproudcodelife/article/details/39839891

支持原创