5、查看neutron-openvswitch-agent运行状态
[iyunv@os-node3 abrt]# service neutron-openvswitch-agent status
neutron-openvswitch-agent (pid 7523) is running...
6、查看openvswitch运行状态
[iyunv@os-node3 abrt]# service openvswitch status
ovsdb-server is running with pid 7477
ovs-vswitchd is running with pid 7486
五、mysql
1、进入数据库
mysql -uroot -p 回车
默认没有密码
2、显示所有的数据库
show databases;
3、进入表
use nova; 进入nova表
4、查看表结构
desC agent_builds; 查看“agent_builds”的表结构
5、查看数据库表信息
mysql> show tables;
6、在数据库migrations表里查找所有东西
mysql> select * from migrations ;
7、在数据库中删除一条信息
mysql> delete * from ipallocationpools where id="041d7993-394b-4ec3-aae3-365aeb5dc10f";
8、变更云硬盘在数据库volumes表中的信息
mysql> update volumes set host="node-44.domain.tld" where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
9、查看云硬盘几个参数的状态
mysql> select status,attached_host,migration_status,deleted from volumes where id="0d883e29-1bc7-4e54-9eba-1883c4c32313";
10、变更云硬盘在数据库中的存储状态
变更前:
mysql> select status,attached_host,migration_status,deleted from volumes where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
+-----------+---------------+---------------------------------------------+---------+
| status | attached_host | migration_status | deleted |
+-----------+---------------+---------------------------------------------+---------+
| available | NULL | target:10de2dad-21c9-482f-b1c4-5afedef36dde | 0 |
+-----------+---------------+---------------------------------------------+---------+
1 row in set (0.00 sec)
变更后:
mysql> update volumes set migration_status="NULL" where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
mysql> select status,attached_host,migration_status,deleted from volumes where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
+-----------+---------------+------------------+---------+
| status | attached_host | migration_status | deleted |
+-----------+---------------+------------------+---------+
| available | NULL | NULL | 0 |
+-----------+---------------+------------------+---------+
1 row in set (0.00 sec)
11、彻底删除一个有问题的云硬盘
先修改该云硬盘的状态status="deleted"
mysql> update volumes set status="deleted" where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
然后修改该云硬盘删除状态
mysql> update volumes set deleted="1" where id="8266d5cc-9be5-4c3b-a46e-06aa055c66e1";
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> update volumes set deleted="1" where Status="deleting";
11、批量删除云硬盘
mysql> update volumes set deleted="1" where Status="deleting";
11、批量删除云硬盘快照
mysql> update snapshots set deleted="1" where Status="error_deleting";
11、彻底删除已删除状态的云硬盘
mysql> delete from volumes where Status="deleted";
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`cinder`.`volume_glance_metadata`, CONSTRAINT `volume_glance_metadata_ibfk_1` FOREIGN KEY (`volume_id`) REFERENCES `volumes` (`id`))
解决上面报错用下面的命令:
mysql> SET FOREIGN_KEY_CHECKS = 0;
Query OK, 0 rows affected (0.00 sec)
再次执行删除就可以删除了
mysql> delete from volumes where Status="deleted";
Query OK, 223 rows affected (0.06 sec)
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2 Changed: 2 Warnings: 0
12、在数据库中查看ip pool
进入neutron表
mysql> select * from ipallocationpools;
13、在数据库中查看已使用的vlan信息
进入neutron表
mysql> select * from ovs_vlan_allocations;
14、变更一个KVM虚拟机的任务状态
变更前的任务状态
mysql> select task_state from instances where hostname="sundaming-10.40.254.62";
+-----------------+
| task_state |
+-----------------+
| image_uploading |
+-----------------+
1 row in set (0.00 sec)
变更状态命令
update instances set task_state="none" where hostname="sundaming-10.40.254.62";
变更后的状态
mysql> select task_state from instances where hostname="sundaming-10.40.254.62";
+------------+
| task_state |
+------------+
| none |
+------------+
1 row in set (0.00 sec)
15、数据库主机用户权限问题
查看mysql中的用户
mysql> use mysql;
mysql> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | |
| os-node1 | |
| os-node1 | root |
+-----------+------+
5 rows in set (0.00 sec)
授权一个test用户从任何机器都可以远程登录mysql数据库
mysql> GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY 'test' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| % | test |
| 127.0.0.1 | root |
| localhost | |
| os-node1 | |
| os-node1 | root |
+-----------+------+
6 rows in set (0.00 sec)
在其他的一台机器上测试
[iyunv@os-node11 ~]# mysql -h 10.240.216.1 -utest -p'test'
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 277
Server version: 5.1.71-log Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
16、删除库
mysql> drop database jiayuan123;
17、备份mysql数据库中的keystone库
[iyunv@node-44 ~]# mysqldump -u root -p keystone > /mysql-bak/keystone.sql
18、查看cinder库中使用中的volumes
mysql> use cinder;
mysql> select * from volumes where status ="in-use";
19、查看一个虚拟机的状态
mysql> select vm_state from instances where uuid="5dc5c94b-0752-40a7-9fbf-49d3cf5e4097";
+----------+
| vm_state |
+----------+
| active |
+----------+
20、查看一个虚拟机的运行状态
mysql> select task_state from instances where uuid="9b57d145-d810-4ab2-92e1-11ec44c2cd85";
+------------+
| task_state |
+------------+
| NULL |
+------------+
1 row in set (0.00 sec)
20、修改虚拟机的IP
1)、查找虚拟机的网络端口
mysql> use neutron;
mysql> select * from ports where device_id="3ab73261-82ce-4b9a-9a1c-519624e19dc2";
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
| tenant_id | id | name | network_id | mac_address | admin_state_up | status | device_id | device_owner |
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
| 5855410282d54e0cac49f05b40282500 | eccd3444-bb81-4d3b-ae13-58040847da4a | | ed547aa7-af32-495a-8173-5a04be9c37c1 | fa:16:3e:a8:bd:e4 | 1 | DOWN | 3ab73261-82ce-4b9a-9a1c-519624e19dc2 | compute:nova |
+----------------------------------+--------------------------------------+------+--------------------------------------+-------------------+----------------+--------+--------------------------------------+--------------+
1 row in set (0.01 sec)
mysql>
2)、查找虚拟机网络端口的IP地址
mysql> select * from ipallocations where port_id="eccd3444-bb81-4d3b-ae13-58040847da4a";
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| port_id | ip_address | subnet_id | network_id |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
| eccd3444-bb81-4d3b-ae13-58040847da4a | 10.40.211.28 | e6e73775-ddbc-461a-92ff-b13202c23540 | ed547aa7-af32-495a-8173-5a04be9c37c1 |
+--------------------------------------+--------------+--------------------------------------+--------------------------------------+
1 row in set (0.00 sec)