环境:Openstack(T)
CentOS Linux release 7.9.2009 (Core)
正文:
1.控制节点安装trove软件包
# yum install openstack-trove-guestagent openstack-trove python-troveclient openstack-trove-ui –y
2.创建数据库,用户,endpint和API端点
#创建数据库
# mysql -u root -p
mysql> CREATE DATABASE trove;
mysql> GRANT ALL PRIVILEGES ON trove.* TO trove@'localhost' IDENTIFIED BY 'admin123'; mysql> GRANT ALL PRIVILEGES ON trove.* TO trove@'%' IDENTIFIED BY 'admin123';#创建用户
# openstack user create --domain default --password admin123 trove
# openstack role add --project service --user trove admin
# openstack service create --name trove --description "Database" database#创建endpoint和API端点---tenant_id不用进行改动
# openstack endpoint create --region RegionOne database public http:// controller:8779/v1.0/%\(tenant_id\)s
# openstack endpoint create --region RegionOne database internal http:// controller:8779/v1.0/%\(tenant_id\)s
# openstack endpoint create --region RegionOne database admin http:// controller:8779/v1.0/%\(tenant_id\)s
3.去/etc/trove/目录下 编辑如下四个配置文件
[root@controller trove]# cat trove-conductor.conf
[DEFAULT]
log_dir = /var/log/trove
log_file = trove-conductor.log
trove_auth_url = http://controller:5000/v3/
notifier_queue_hostname = controller
nova_proxy_admin_user = admin
nova_proxy_admin_pass = admin123
nova_proxy_admin_tenant_name = admin
rpc_backend = rabbit[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = admin123[database]
connection = mysql://trove:admin123@controller/trove
[root@controller trove]# cat trove.conf
[DEFAULT]
log_dir = /var/log/trove
log_file = trove-api.log
trove_auth_url = http://controller:5000/v3/
notifier_queue_hostname = controller
rpc_backend = rabbit
nova_proxy_admin_user = admin
nova_proxy_admin_pass = admin123
nova_proxy_admin_tenant_name = admin
nova_compute_service_type = compute
cinder_service_type = volumev2
network_driver = trove.network.neutron.NeutronDriver
default_neutron_networks = c44901e1-39a1-4336-8417-9de533a3f0fe
auth_strategy = keystone
add_addresses = True
network_label_regex = .*
api_paste_config = api-paste.ini[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = admin123[database]
connection = mysql://trove:admin123@controller/trove[keystone_authtoken]
auth_uri = http://controller:5000/v3/
auth_url = http://controller:5000/v3/
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = trove
password = admin123
[root@controller trove]# cat trove-guestagent.conf
[DEFAULT]
rpc_backend = rabbit
nova_proxy_admin_user = admin
nova_proxy_admin_pass = admin123
nova_proxy_admin_user = admin
nova_proxy_admin_tenant_id = 06d5998c61e64c0d8fbcfd4e961ecee8
trove_auth_url = http://controller:5000/v3/
swift_url = http://controller:8080/v1/AUTH_06d5998c61e64c0d8fbcfd4e961ecee8
os_region_name = RegionOne
swift_service_type = object-store
log_file = trove-guestagent.log
rabbit_password = admin123
rabbit_host = 192.168.222.10
rabbit_userid = openstack
rabbit_port = 5672[oslo_messaging_rabbit]
rabbit_host = 192.168.222.10
rabbit_userid = openstack
rabbit_password = admin123
[root@controller trove]# cat trove-taskmanager.conf
[DEFAULT]
log_dir = /var/log/trove
log_file = trove-taskmanager.log
trove_auth_url = http://controller:5000/v3/
nova_compute_url = http://controller:8774/v2.1
notifier_queue_hostname = controller
rpc_backend = rabbit
nova_proxy_admin_user = admin
nova_proxy_admin_pass = admin123
nova_proxy_admin_tenant_id = 06d5998c61e64c0d8fbcfd4e961ecee8
taskmanager_manager = trove.taskmanager.manager.Manager
notification_driver = messagingv2
network_driver = trove.network.neutron.NeutronDriver
default_neutron_networks = c44901e1-39a1-4336-8417-9de533a3f0fe
network_label_regex = .*
guest_config = /etc/trove/trove-guestagent.conf
guest_info = guest_info.conf
injected_config_location = /etc/trove/conf.d
cloudinit_location = /etc/trove/cloudinit[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = admin123[database]
connection = mysql://trove:admin123@controller/trove
上述配置文件,host 密码 网络ID project_ID auth_url 该替换的都要进行替换
下面详细说几个地方:
3.1.管理员项目的租户ID:
nova_proxy_admin_tenant_id = 06d5998c61e64c0d8fbcfd4e961ecee8
3.2.你要使用的网络ID
default_neutron_networks = c44901e1-39a1-4336-8417-9de533a3f0fe
3. 3.获取 Trove 认证 URL
trove_auth_url = http://controller:5000/v3/
3.4.获取 Swift 服务 URL
swift_url = http://controller:8080/v1/AUTH_06d5998c61e64c0d8fbcfd4e961ecee8
4.同步数据库
# su -s /bin/sh -c "trove-manage db_sync" trove
执行完该命令如果出现错误,Command failed, please check log for more info
查看位于 /var/log/trove/下的
日志文件
解决:
这个错误意味着在执行 `trove-manage db_sync` 命令时,Python 缺少 MySQL 数据库驱动程序。通常情况下,Trove 使用 SQLAlchemy 来与数据库进行交互,而 SQLAlchemy 又需要特定的数据库驱动程序来连接到数据库。在这种情况下,错误消息指出缺少名为 `MySQLdb` 的 Python 模块,这是 MySQL 数据库的一个常用驱动程序。要解决这个问题,你需要安装适用于 Python 2.7 的 MySQL 数据库驱动程序。如果你使用的是 Python 2.7,可以尝试使用以下命令来安装 `MySQLdb`:pip install MySQL-python (注意:没有pip 就 yum install )或者,如果你使用的是 Python 3,可以安装 `mysqlclient`:
pip install mysqlclient安装完成后,再次尝试运行 `trove-manage db_sync` 命令,应该就不会再出现缺少 MySQLdb 模块的错误了。
5.启动服务
# service httpd restart
# systemctl enable openstack-trove-api.service openstack-trove-taskmanager.service openstack-trove-conductor.service
# systemctl restart openstack-trove-api.service openstack-trove-taskmanager.service openstack-trove-conductor.service
OK!!!