CentOS 7 构建 Openstack docker rally 测试环境

来源:互联网 发布:eclipse js提示插件 编辑:程序博客网 时间:2024/04/29 08:01

参照官方手顺使用 docker rally-centos 镜像构建 rally 性能测试环境
地址:
        https://hub.docker.com/r/adrahon/rally-centos/

1. 准备 docker 环境
        [root@localhost ~]# yum install docker -y
        [root@localhost ~]# systemctl enable docker
        [root@localhost ~]# systemctl start docker
        [root@localhost ~]# systemctl status docker

2. docker 加载 rally-centos 镜像
        #下载镜像并启动一个 rally 环境
                [root@localhost ~]# docker pull adrahon/rally-centos
                [rally@15342920e3d2 ~]$ exit
        #确认镜像信息
                [root@localhost ~]# docker images
                REPOSITORY                       TAG                 IMAGE ID            CREATED             SIZE
                docker.io/adrahon/rally-centos   latest              9ed84ac7514e        14 months ago       376.5 MB
        #确认 rally 环境信息
                [root@localhost ~]# docker ps -l
                CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                      PORTS               NAMES
                15342920e3d2        adrahon/rally-centos   "/bin/sh -c 'bash --l"   22 minutes ago      Exited (0) 22 minutes ago                       elegant_colden
        #启动 rally 环境
                [root@localhost ~]# docker start 15342920e3d2
                15342920e3d2
        #登陆 rally 环境
                [root@localhost ~]# docker exec -it 15342920e3d2  /bin/bash
                [rally@15342920e3d2 ~]$

3. 创建 root 用户的 rally 环境
        上述 2 创建的 rally 环境是 rally 用户,权限受限,重新新建 root 用户环境
        #创建 root 用户 rally 环境
                [root@localhost ~]# docker run -i -u root -t docker.io/adrahon/rally-centos /bin/bash
                [root@21a62e8c09bd ~]# exit
                exit
        #获取环境信息
                [root@localhost ~]# docker ps -l
                CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS                     PORTS               NAMES
                21a62e8c09bd        docker.io/adrahon/rally-centos   "/bin/bash"         5 minutes ago       Exited (0) 3 minutes ago                       reverent_noyce
        #启动 rally 环境
                [root@localhost ~]# docker start 21a62e8c09bd
                21a62e8c09bd
        #登陆 rally 环境
                [root@localhost ~]# docker exec -it 21a62e8c09bd  /bin/bash
                [root@21a62e8c09bd ~]#

4. rally 测试实施(all in one openstack kilo 环境)
        #添加 openstack host 信息(controller host)
                [root@21a62e8c09bd ~]# cat /etc/hosts
                127.0.0.1       localhost
                ::1     localhost ip6-localhost ip6-loopback
                fe00::0 ip6-localnet
                ff00::0 ip6-mcastprefix
                ff02::1 ip6-allnodes
                ff02::2 ip6-allrouters
                172.17.0.3      21a62e8c09bd
                [root@21a62e8c09bd ~]# vi /etc/hosts
                [root@21a62e8c09bd ~]# cat /etc/hosts
                127.0.0.1       localhost
                ::1     localhost ip6-localhost ip6-loopback
                fe00::0 ip6-localnet
                ff00::0 ip6-mcastprefix
                ff02::1 ip6-allnodes
                ff02::2 ip6-allrouters
                172.17.0.3      21a62e8c09bd
                # controller
                10.167.218.104 controller
                [root@21a62e8c09bd ~]#
        #新建自己的测试目录
                [root@21a62e8c09bd ~]# mkdir /home/yenai
        #创建测试使用相关文件
                #环境变量文件
                        [root@21a62e8c09bd yenai]# vi /home/yenai/openrc
                        [root@21a62e8c09bd yenai]# cat /home/yenai/openrc
                        export OS_PROJECT_DOMAIN_ID=default
                        export OS_USER_DOMAIN_ID=default
                        export OS_PROJECT_NAME=admin
                        export OS_TENANT_NAME=admin
                        export OS_USERNAME=admin
                        export OS_PASSWORD=pass
                        export OS_AUTH_URL=http://controller:35357/v3
                        export OS_VOLUME_API_VERSION=2
                        [root@21a62e8c09bd yenai]#
                #nova vm create delete
                        [root@21a62e8c09bd yenai]# vi /home/yenai/1-nova_boot_and_delete.json
                        [root@21a62e8c09bd yenai]# cat /home/yenai/1-nova_boot_and_delete.json
                        {
                            "NovaServers.boot_and_delete_server": [
                                {
                                    "args": {
                                        "flavor": {
                                            "name": "m1.tiny"
                                        },
                                        "image": {
                                            "name": "cirros-0.3.4-x86_64"
                                        },
                                        "force_delete": false
                                    },
                                    "runner": {
                                        "type": "constant",
                                        "times": 1,
                                        "concurrency":1
                                    },
                                    "context": {
                                        "users": {
                                            "tenants": 1,
                                            "users_per_tenant": 1
                                        }
                                    }
                                }
                            ]
                        }
                        [root@21a62e8c09bd yenai]#
                        关键配置项说明:
                                "name": "m1.tiny"                               vm配置,nova flavor-list结果的Name
                                "name": "cirros-0.3.4-x86_64"            vm操作系统,nova image-list结果的Name
                                "times": 1,                                            并发总量
                                "concurrency":1                                  并发数量
                                "tenants": 1,                                        使用多少个tenants(操作中遇到quota制限时可使用多个tenant避免错误)


                #cinder volume create delete
                        [root@21a62e8c09bd yenai]# vi /home/yenai/2-create_and_delete_volume.json
                        [root@21a62e8c09bd yenai]# cat /home/yenai/2-create_and_delete_volume.json
                        {
                            "CinderVolumes.create_and_delete_volume": [
                                {
                                    "args": {
                                        "size": 20,
                                        "volume_type": "yenai_210_s2_tpp"
                                    },
                                    "runner": {
                                        "type": "constant",
                                        "times": 1,
                                        "concurrency": 1
                                    },
                                    "context": {
                                        "users": {
                                            "tenants": 1,
                                            "users_per_tenant": 1
                                        }
                                    }
                                }
                            ]
                        }
                        [root@21a62e8c09bd yenai]#
                        关键配置项说明:
                                "size": 20                                              创建卷大小
                                "volume_type": "yenai_210_s2_tpp"   创建卷类型,cinder type-lis结果的Name(通过cinder extra-specs-list查询配置的正确性)
                                "times": 1,                                            并发总量
                                "concurrency":1                                  并发数量
                                "tenants": 1,                                        使用多少个tenants(操作中遇到quota制限时可使用多个tenant避免错误)


                #vm create cinder volume create attach detach delete vm delete
                        [root@21a62e8c09bd yenai]# vi /home/yenai/3-create_and_attach_volume.json
                        [root@21a62e8c09bd yenai]# cat /home/yenai/3-create_and_attach_volume.json
                        {% set availability_zone = "nova" %}
                        {
                            "CinderVolumes.create_and_attach_volume": [
                                {
                                    "args": {
                                        "size": 20,
                                        "image": {
                                            "name": "cirros-0.3.4-x86_64"
                                        },
                                        "flavor": {
                                            "name": "m1.tiny"
                                        },
                         "nics":[{"net-id": "7d912784-9175-4bbd-9fd2-993b78c43b96"}],
                                        "volume_type": "yenai_210_s2_tpp"
                                    },
                                    "runner": {
                                        "type": "constant",
                                        "times": 1,
                                        "concurrency": 1
                                    },
                                    "context": {
                                        "users": {
                                            "tenants": 1,
                                            "users_per_tenant": 1
                                        }
                                    }
                                }
                            ]
                        }
                        [root@21a62e8c09bd yenai]# ll /home/yenai/
                        total 16
                        -rw-r--r--. 1 root root 625 Oct 17 05:33 1-nova_boot_and_delete.json
                        -rw-r--r--. 1 root root 490 Oct 17 05:41 2-create_and_delete_volume.json
                        -rw-r--r--. 1 root root 769 Oct 17 05:43 3-create_and_attach_volume.json
                        -rw-r--r--. 1 root root 252 Oct 17 05:28 openrc
                        关键配置项说明:
                                availability_zone = "nova"                                                 创建vm使用的zone,nova availability-zone-list结果的Name
                                "size": 20                                                                              创建卷大小
                                "name": "cirros-0.3.4-x86_64"                                             vm操作系统,nova image-list结果的Name
                                "name": "m1.tiny"                                                                vm配置,nova flavor-list结果的Name
                                "net-id": "7d912784-9175-4bbd-9fd2-993b78c43b96"      vm网络配置,nova net-list结果的ID
                                "volume_type": "yenai_210_s2_tpp"                                    创建卷类型,cinder type-lis结果的Name(通过cinder extra-specs-list查询配置的正确性)
                                "times": 1,                                                                             并发总量
                                "concurrency":1                                                                   并发数量
                                "tenants": 1,                                                                         使用多少个tenants(操作中遇到quota制限时可使用多个tenant避免错误)


        #rally测试
                #创建rally数据库
                        [root@21a62e8c09bd yenai]# rally-manage db recreate
                #创建deployment
                        [root@21a62e8c09bd yenai]# source /home/yenai/openrc
                        [root@21a62e8c09bd yenai]# rally deployment create --fromenv --name=rally_test
                        2016-10-17 05:48:16.456 140 INFO rally.deployment.engine [-] Deployment 8777ab36-22ee-4641-9cd4-70200a15848c | Starting:  OpenStack cloud deployment.
                        2016-10-17 05:48:16.803 140 INFO rally.deployment.engine [-] Deployment 8777ab36-22ee-4641-9cd4-70200a15848c | Completed: OpenStack cloud deployment.
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                        | uuid                                 | created_at                 | name       | status           | active |
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                        | 8777ab36-22ee-4641-9cd4-70200a15848c | 2016-10-17 05:48:16.266792 | rally_test | deploy->finished |        |
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                        Using deployment: 8777ab36-22ee-4641-9cd4-70200a15848c
                        ~/.rally/openrc was updated


                        HINTS:
                        * To get your cloud resources, run:
                                rally show [flavors|images|keypairs|networks|secgroups]


                        * To use standard OpenStack clients, set up your env by running:
                                source ~/.rally/openrc
                          OpenStack clients are now configured, e.g run:
                                glance image-list
                        [root@21a62e8c09bd yenai]# rally deployment list
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                        | uuid                                 | created_at                 | name       | status           | active |
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                        | 8777ab36-22ee-4641-9cd4-70200a15848c | 2016-10-17 05:48:16.266792 | rally_test | deploy->finished | *      |
                        +--------------------------------------+----------------------------+------------+------------------+--------+
                #检查服务情况
                        [root@21a62e8c09bd yenai]# rally deployment check
                        keystone endpoints are valid and following services are available:
                        +----------+--------------+-----------+
                        | services | type         | status    |
                        +----------+--------------+-----------+
                        | cinder   | volume       | Available |
                        | cinderv2 | volumev2     | Available |
                        | glance   | image        | Available |
                        | keystone | identity     | Available |
                        | nova     | compute      | Available |
                        | swift    | object-store | Available |
                        +----------+--------------+-----------+
                #开始测试
                        [root@21a62e8c09bd yenai]# cd /home/yenai/
                        [root@21a62e8c09bd yenai]# ll
                        total 16
                        -rw-r--r--. 1 root root 625 Oct 17 05:33 1-nova_boot_and_delete.json
                        -rw-r--r--. 1 root root 490 Oct 17 05:41 2-create_and_delete_volume.json
                        -rw-r--r--. 1 root root 769 Oct 17 05:43 3-create_and_attach_volume.json
                        -rw-r--r--. 1 root root 252 Oct 17 05:28 openrc
                        [root@21a62e8c09bd yenai]# rally task start 1-nova_boot_and_delete.json
                        [root@21a62e8c09bd yenai]# rally task start 2-create_and_delete_volume.json
                        [root@21a62e8c09bd yenai]# rally task start 3-create_and_attach_volume.json


追加信息:
        1. Rally测试中vm使用的image镜像的is_public 必须是True
                [root@controller cinder]# glance image-show fabe920c-e624-47ca-876a-d3198b4edf0c
                +------------------+--------------------------------------+
                | Property         | Value                                |
                +------------------+--------------------------------------+
                | checksum         | 133eae9fb1c98f45894a4e60d8736619     |
                | container_format | bare                                 |
                | created_at       | 2016-10-07T05:14:21.000000           |
                | deleted          | False                                |
                | disk_format      | qcow2                                |
                | id               | fabe920c-e624-47ca-876a-d3198b4edf0c |
                | is_public        | False                                |
                | min_disk         | 0                                    |
                | min_ram          | 0                                    |
                | name             | cirros-0.3.3-x86_64                  |
                | owner            | 8446e2d34e484a999d47abec616e0ed5     |
                | protected        | False                                |
                | size             | 13200896                             |
                | status           | active                               |
                | updated_at       | 2016-10-07T05:14:21.000000           |
                +------------------+--------------------------------------+


                [root@controller cinder]# glance image-update --is-public True fabe920c-e624-47ca-876a-d3198b4edf0c
                +------------------+--------------------------------------+
                | Property         | Value                                |
                +------------------+--------------------------------------+
                | checksum         | 133eae9fb1c98f45894a4e60d8736619     |
                | container_format | bare                                 |
                | created_at       | 2016-10-07T05:14:21.000000           |
                | deleted          | False                                |
                | deleted_at       | None                                 |
                | disk_format      | qcow2                                |
                | id               | fabe920c-e624-47ca-876a-d3198b4edf0c |
                | is_public        | True                                 |
                | min_disk         | 0                                    |
                | min_ram          | 0                                    |
                | name             | cirros-0.3.3-x86_64                  |
                | owner            | 8446e2d34e484a999d47abec616e0ed5     |
                | protected        | False                                |
                | size             | 13200896                             |
                | status           | active                               |
                | updated_at       | 2016-10-18T08:52:50.000000           |
                | virtual_size     | None                                 |
                +------------------+--------------------------------------+


        2. 如何导出image和导入image
                导出:docker save --help
                        9ed84ac7514e是image id
                        [root@controller yenai]# docker save -o /home/yenai/openstack-rally.tar 9ed84ac7514e
                导入:docker load --help
                        [root@controller yenai]# docker load --input openstack-rally.tar

1 0
原创粉丝点击