关于shell脚本部署openstack平台controller节点(CentOS,Pike)
**首先声明:此脚本只适合用于实验环境,比如虚拟机等,不适合实际生产环境操作(新手,大神勿喷)
**本脚本由 shell 编写执行,部署的是 openstackPike 版本
因为我把 memcached 、 rabbitMQ 和 MariaDB 全部集成在了 controller 节点上,
所以建议controller节点的配置相对高一些
实验环境:
VMware 14 Pro CentOS7虚拟机
controller节点虚拟机的配置是这样的:
操作系统和内核版本如下:
在运行脚本之前,首先要做一些如下准备:
关闭 SELINUX ,(虽然加了 openstack-selinux 的安装包,但是感觉还是关掉比较好)
更改主机名,
更改IP地址,更改成如下的样子:
其中第二块为controller节点的网卡,第三块可以改成disabled,第四块为桥接网卡,方便外部连接
至于【/etc/yum.repos.d/】的 【 * .repo】源文件就靠自己动手啦~
然后就可以执行脚本了(后面有脚本文件和具体内容),以 root 用户身份执行
整个安装过程没有任何交互,只需要安静等待安装完毕就好
安装完毕后,检查一下服务有没有全部开启
正常情况下所有的服务应该是 active running
进入 root 文件夹,下面有一个 admin-openrc 文件,以 bash 或者. 执行一下就可以,获取 admin 权限,
以后如果出现权限不够的情况就再执行一次即可
打开浏览器,输入【controllerIP/dashboard】,就可以看到登陆面板了
**登陆域是 defualt,用户名是 admin,密码是 iforgot
登录成功界面
**
分
割
线
**
下面就是脚本的具体内容了,感谢Louis
#!/bin/bash
#set -x
PASSWORD=iforgot
yum remove firewalld-filesystem NetworkManager-libnm -y
FIRST_PKG=centos-release-openstack-pike
CONTROLLER_PKGS=(
net-tools
chrony
python-openstackclient
openstack-selinux
mariadb
mariadb-server
python2-PyMySQL
rabbitmq-server
memcached
python-memcached
openstack-keystone
httpd
mod_wsgi
openstack-glance
openstack-nova-api
openstack-nova-conductor
openstack-nova-console
openstack-nova-novncproxy
openstack-nova-scheduler
openstack-nova-placement-api
openstack-neutron
openstack-neutron-ml2
openstack-neutron-linuxbridge
ebtables
openstack-cinder
openstack-dashboard
)
declare -A SERVICE_USERS
SERVICE_USERS=(
="keystone"
="glance"
="nova"
="placement"
="neutron"
="cinder"
)
ENDPOINTS=(
"admin"
"internal"
"public"
)
#yum install $FIRST_PKG -y
yum upgrade -y
yum install ${CONTROLLER_PKGS
[*]} -y
NIC_NAME=(ip addr | grep '^' | awk -F':' '{print $2}')
MGMT_IP=ifconfig ${NIC_NAME} | grep -w inet | awk '{print $2}'
echo "$MGMT_IP controller" >> /etc/hosts
sed -i "s/#ServerName www.example.com:80/ServerName controller/g" /etc/httpd/conf/httpd.conf
cat > /etc/chrony.conf/etc/my.cnf.d/openstack.cnf
mysql -uroot -p$PASSWORD -e "GRANT ALL PRIVILEGES ON $USER. TO '$USER'@'%'> mysql -uroot -p$PASSWORD -e "GRANT ALL PRIVILEGES ON nova_cell0. TO '$USER'@'localhost'>
mysql -uroot -p$PASSWORD -e "GRANT ALL PRIVILEGES ON nova_cell0. TO '$USER'@'%'> else
mysql -uroot -p$PASSWORD -e "CREATE DATABASE $USER"
mysql -uroot -p$PASSWORD -e "GRANT ALL PRIVILEGES ON $USER. TO '$USER'@'localhost'>
mysql -uroot -p$PASSWORD -e "GRANT ALL PRIVILEGES ON $USER. TO '$USER'@'%'> fi
done
cat > /etc/keystone/keystone.conf/etc/httpd/conf.d/00-nova-placement-api.conf
Require all granted
Order allow,deny
Allow from all
EOF
systemctl restart httpd
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
su -s /bin/sh -c "nova-manage db sync" nova
cat > /etc/neutron/neutron.conf/etc/neutron/plugins/ml2/ml2_conf.ini/etc/neutron/plugins/ml2/linuxbridge_agent.ini/etc/neutron/l3_agent.ini/etc/neutron/dhcp_agent.ini/etc/neutron/metadata_agent.ini/etc/cinder/cinder.conf/etc/openstack-dashboard/local_settings
"ramdiskid": ("Ramdisk> "imagestate": ("Euca2ools state"),
"projectid": ("Project> "imagetype": ("Image Type"),
}
IMAGE_RESERVED_CUSTOM_PROPERTIES = []
API_RESULT_LIMIT = 1000
API_RESULT_PAGE_SIZE = 20
SWIFT_FILE_TRANSFER_CHUNK_SIZE = 512 * 1024
INSTANCE_LOG_LENGTH = 35
DROPDOWN_MAX_ITEMS = 30
TIME_ZONE = "UTC"
POLICY_FILES_PATH = '/etc/openstack-dashboard'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'operation': {
'format': '%(asctime)s %(message)s'
},
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
},
'operation': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'operation',
},
},
'loggers': {
'django.db.backends': {
'handlers': ['null'],
'propagate': False,
},
'requests': {
'handlers': ['null'],
'propagate': False,
},
'horizon': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'horizon.operation_log': {
'handlers': ['operation'],
'level': 'INFO',
'propagate': False,
},
'openstack_dashboard': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'novaclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'cinderclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'keystoneclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'glanceclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'neutronclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'heatclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'ceilometerclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'swiftclient': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'openstack_auth': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'nose.plugins.manager': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'django': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
},
'iso8601': {
'handlers': ['null'],
'propagate': False,
},
'scss': {
'handlers': ['null'],
'propagate': False,
},
},
}
SECURITY_GROUP_RULES = {
'alltcp': {
'name': ('All TCP'),
'ip_protocol': 'tcp',
'from_port': '1',
'to_port': '65535',
},
'alludp': {
'name': ('All UDP'),
'ip_protocol': 'udp',
'from_port': '1',
'to_port': '65535',
},
'allicmp': {
'name': ('All ICMP'),
'ip_protocol': 'icmp',
'from_port': '-1',
'to_port': '-1',
},
'ssh': {
'name': 'SSH',
'ip_protocol': 'tcp',
'from_port': '22',
'to_port': '22',
},
'smtp': {
'name': 'SMTP',
'ip_protocol': 'tcp',
'from_port': '25',
'to_port': '25',
},
'dns': {
'name': 'DNS',
'ip_protocol': 'tcp',
'from_port': '53',
'to_port': '53',
},
'http': {
'name': 'HTTP',
'ip_protocol': 'tcp',
'from_port': '80',
'to_port': '80',
},
'pop3': {
'name': 'POP3',
'ip_protocol': 'tcp',
'from_port': '110',
'to_port': '110',
},
'imap': {
'name': 'IMAP',
'ip_protocol': 'tcp',
'from_port': '143',
'to_port': '143',
},
'ldap': {
'name': 'LDAP',
'ip_protocol': 'tcp',
'from_port': '389',
'to_port': '389',
},
'https': {
'name': 'HTTPS',
'ip_protocol': 'tcp',
'from_port': '443',
'to_port': '443',
},
'smtps': {
'name': 'SMTPS',
'ip_protocol': 'tcp',
'from_port': '465',
'to_port': '465',
},
'imaps': {
'name': 'IMAPS',
'ip_protocol': 'tcp',
'from_port': '993',
'to_port': '993',
},
'pop3s': {
'name': 'POP3S',
'ip_protocol': 'tcp',
'from_port': '995',
'to_port': '995',
},
'ms_sql': {
'name': 'MS SQL',
'ip_protocol': 'tcp',
'from_port': '1433',
'to_port': '1433',
},
'mysql': {
'name': 'MYSQL',
'ip_protocol': 'tcp',
'from_port': '3306',
'to_port': '3306',
},
'rdp': {
'name': 'RDP',
'ip_protocol': 'tcp',
'from_port': '3389',
'to_port': '3389',
},
}
REST_API_REQUIRED_SETTINGS = ['OPENSTACK_HYPERVISOR_FEATURES',
'LAUNCH_INSTANCE_DEFAULTS',
'OPENSTACK_IMAGE_FORMATS']
ALLOWED_PRIVATE_SUBNET_CIDR = {'ipv4': [], 'ipv6': []}
EOF
chown root:apache /etc/openstack-dashboard/local_settings
systemctl restart httpd
echo "######### Start ALL Services ##########"
systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
systemctl start openstack-glance-api.service \
openstack-glance-registry.service
systemctl enable openstack-nova-api.service \
openstack-nova-consoleauth.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl start openstack-nova-api.service \
openstack-nova-consoleauth.service openstack-nova-scheduler.service \
openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl restart openstack-nova-api.service
systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service neutron-l3-agent.service
systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service neutron-l3-agent.service
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
页:
[1]