一、初始化环境:
1、更换yum源:
yum install -y wget mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoyum clean allyum makecache
2、下载openstack的软件包
yum -y install centos-release-openstack-ocatayum -y upgradeyum -y install python-openstackclientyum -y install chronyyum -y install mariadb mariadb-server python2-PyMySQLyum -y install rabbitmq-serveryum -y install memcached python-memcachedyum -y install openstack-keystone httpd mod_wsgiyum -y install openstack-glanceyum -y install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-apiyum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtable
3、安装python3
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc makecd /usr/local/srcwget "https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz"tar -zxvf Python-3.5.0.tgz && cd Python-3.5.0mkdir /usr/local/python3./configure --prefix=/usr/local/python3 make && make install ln -s /usr/local/python3/bin/python3 /usr/bin/python3 注:需要安装Paramiko,详见:http://www.cnblogs.com/chimeiwangliang/p/7193187.html
4、关闭selinux
5、关闭防火墙
systemctl stop firewalldsystemctl disable firewalld
6、配置好ip地址
ip addr add dev eth0 10.0.0.11/24echo 'ip addr add dev eth0 10.0.0.11/24' >> /etc/rc.local chmod +x /etc/rc.d/rc.local
7、更改hosts文件
1、vi /etc/hosts# controller10.0.0.11 controller# compute110.0.0.21 compute1# compute210.0.0.22 compute2# compute310.0.0.23 compute3# compute410.0.0.24 compute4# block110.0.0.51 block1# object110.0.0.52 object1# object210.0.0.53 object2 2、重启服务器: reboot
二、执行脚本:
1、配置时间同步:
1、修改/etc/chrony.conf:vi /etc/chrony.confallow 10.0.0.0/24 #改为2、启动服务:systemctl enable chronyd.servicesystemctl start chronyd.service3、可以配置时区(选配)timedatectl set-timezone Asia/Shanghaichronyc sources
2、执行脚本:
1、下载文件:http://pan.baidu.com/s/1eSyCc2u 密码:39jp解压到任一目录:openstack├── admin-openrc├── cirros-0.3.5-x86_64-disk.img├── command_compute.txt├── command.txt├── compute-install.py├── demo-openrc├── down_upload│ ├── linuxbridge_agent.ini│ ├── linuxbridge_agent.ini.bak│ ├── neutron.conf│ ├── neutron.conf.bak│ ├── nova.conf│ └── nova.conf.bak├── http│ └── httpd.conf├── log│ ├── compote_install.log│ └── controller_install.log├── memcached│ └── memcached├── mysql│ └── openstack.cnf├── nova│ └── 00-nova-placement-api.conf├── openstack-install.py├── opentack-dashboard│ └── local_settings├── order_configfile.py├── __pycache__│ ├── order_configfile.cpython-35.pyc│ └── run_sys.cpython-35.pyc└── run_sys.py2、执行以下命令:export OS_USERNAME=adminexport OS_PASSWORD=keystoneexport OS_PROJECT_NAME=adminexport OS_USER_DOMAIN_NAME=Defaultexport OS_PROJECT_DOMAIN_NAME=Defaultexport OS_AUTH_URL=http://controller:35357/v3export OS_IDENTITY_API_VERSION=33、执行脚本:python3 openstack-install.py 注:1.有mysql初始化密码为order_configfile.py文件里mysql_root变量的值。 2.order_configfile.py文件里bridge_port变量的值是桥接网卡名。 3.order_configfile.py文件里mysql_database_user为各服务的数据库密码。 4.order_configfile.py文件里keystone_user为各服务的keystone密码。 执行过程中有报错的话会有提示是否继续执行。
三、创建虚拟机:
1、装好计算节点后,不会自动注册(运行下面命令进行注册):
1、openstack hypervisor list
+----+---------------------+-----------------+-----------+-------+
| ID | Hypervisor Hostname | Hypervisor Type | Host IP | State |+----+---------------------+-----------------+-----------+-------+| 1 | compute1 | QEMU | 10.0.0.21 | up |+----+---------------------+-----------------+-----------+-------+2、su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
2、也可以修改/etc/nova/nova.conf文件进行检查:
[scheduler]discover_hosts_in_cells_interval = 300
3、创建虚拟机:
1、创建网络: openstack network create --share --external --provider-physical-network provider --provider-network-type flat provideropenstack subnet create --network provider --allocation-pool start=192.168.72.0,end=192.168.72.100 --dns-nameserver 8.8.8.8 --gateway 192.168.79.254 --subnet-range 192.168.64.1/20 provideropenstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano2、创建秘钥: ssh-keygen -q -N ""openstack keypair create --public-key ~/.ssh/id_rsa.pub mykeyopenstack keypair list 3、创建安全组:openstack security group rule create --proto icmp defaultopenstack security group rule create --proto tcp --dst-port 22 default 4、创建虚拟机:openstack flavor listopenstack image listopenstack network listopenstack security group listopenstack server create --flavor m1.nano --image cirros --nic net-id=(网络的ID) --security-group default --key-name mykey provider-instance 5、检查是否创建成功:openstack server listopenstack console url show provider-instance