当前位置: 代码迷 >> 综合 >> OpenStack Cinder服务安装脚本
  详细解决方案

OpenStack Cinder服务安装脚本

热度:65   发布时间:2023-12-09 03:46:59.0

Controller

#!/bin/shinstall_cinder(){
    set -o errexitset -xreadonly passwd=openstackreadonly my_ip=172.16.199.11	echo "-------------安装和配置控制节点-------------"#数据库source ./sql_scripts/cinder.sqlsource ./admin-openrc	openstack user create --domain default --password $passwd cinderopenstack role add --project service --user cinder adminopenstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)sopenstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)sopenstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)sopenstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)sopenstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)sopenstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s(echo 'y')|apt install cinder-api cinder-scheduler#/etc/cinder/cinder.conf#[database]sed -i "15s/^connection\s.*/connection = mysql+pymysql:\/\/cinder:$passwd@controller\/cinder/" /etc/cinder/cinder.confhead -n 15 /etc/cinder/cinder.conf | tail -n 1#[DEFAULT]sed -i "12s/^enabled_backends\s.*/enabled_backends = nfs/" /etc/cinder/cinder.confhead -n 12 /etc/cinder/cinder.conf | tail -n 1	sed -i "13i transport_url = rabbit://openstack:$passwd@controller" /etc/cinder/cinder.confhead -n 13 /etc/cinder/cinder.conf | tail -n 1sed -i "14i my_ip=$my_ip" /etc/cinder/cinder.confhead -n 14 /etc/cinder/cinder.conf | tail -n 1#[keystone_authtoken]sed -i '$a\ ' /etc/cinder/cinder.confsed -i '$a\[keystone_authtoken]' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\www_authenticate_uri = http://controller:5000' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\auth_url = http://controller:5000' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.conf	sed -i '$a\memcached_servers = controller:11211' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\auth_type = password' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\project_domain_id = default' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\user_domain_id = default' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\project_name = service' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\username = cinder' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i "\$a\password = $passwd" /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.conf#[oslo_concurrency]sed -i '$a\ ' /etc/cinder/cinder.confsed -i '$a\[oslo_concurrency]' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.confsed -i '$a\lock_path = /var/lib/cinder/tmp' /etc/cinder/cinder.conftail -n 1 /etc/cinder/cinder.conf#填充数据库su -s /bin/sh -c "cinder-manage db sync" cinder#4246#nova /etc/nova/nova.confsed -i "4229s/^#os_region_name\s.*/os_region_name = RegionOne/" /etc/nova/nova.confhead -n 4229 /etc/nova/nova.conf | tail -n 1/etc/init.d/nova-api restart/etc/init.d/cinder-scheduler restart/etc/init.d/apache2 restart	}install_cinder

SQL

mysql << EOF
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \ IDENTIFIED BY '$passwd'; GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \ IDENTIFIED BY '$passwd';
EOF

Compute

#!/bin/shinstall_cinder(){
    
set -o errexit
set -x
readonly passwd=openstack
readonly my_ip=172.16.199.31echo "-------------安装和配置存储节点-------------"
#安装配置nfs server
(echo 'y')|apt-get install nfs-kernel-server
mkdir /vol/cinder -p
chmod 777 /vol/cinder
sed -i '$a\/vol/cinder *(rw,sync,no_root_squash,no_subtree_check)' /etc/exports
systemctl restart nfs-kernel-server
systemctl enable nfs-kernel-server#cinder package
(echo 'y')|apt install cinder-volume#/etc/cinder/cinder.conf
#[database]
sed -i "15s/^connection\s.*/connection = mysql+pymysql:\/\/cinder:$passwd@controller\/cinder/" /etc/cinder/cinder.conf
head -n 15 /etc/cinder/cinder.conf | tail -n 1#[DEFAULT] 
sed -i "12s/^enabled_backends\s.*/enabled_backends = nfs/" /etc/cinder/cinder.conf
head -n 12 /etc/cinder/cinder.conf | tail -n 1
sed -i "13i transport_url = rabbit://openstack:$passwd@controller" /etc/cinder/cinder.conf
head -n 13 /etc/cinder/cinder.conf | tail -n 1
sed -i "14i my_ip=$my_ip" /etc/cinder/cinder.conf
head -n 14 /etc/cinder/cinder.conf | tail -n 1
sed -i "15i glance_api_servers = http://controller:9292" /etc/cinder/cinder.conf
head -n 15 /etc/cinder/cinder.conf | tail -n 1#[keystone_authtoken]
sed -i '$a\ ' /etc/cinder/cinder.conf
sed -i '$a\[keystone_authtoken]' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\www_authenticate_uri = http://controller:5000' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\auth_url = http://controller:5000' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf 
sed -i '$a\memcached_servers = controller:11211' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\auth_type = password' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\project_domain_id = default' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\user_domain_id = default' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\project_name = service' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\username = cinder' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i "\$a\password = $passwd" /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf#[oslo_concurrency]
sed -i '$a\ ' /etc/cinder/cinder.conf
sed -i '$a\[oslo_concurrency]' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf
sed -i '$a\lock_path = /var/lib/cinder/tmp' /etc/cinder/cinder.conf
tail -n 1 /etc/cinder/cinder.conf#创建挂载目录
mkdir /var/lib/cinder/mnt -p
chown -R cinder. /var/lib/cinder/mnt#创建nfs_shares
echo "$my_ip:/vol/cinder" >> /etc/cinder/nfs_shares
chmod 640 /etc/cinder/nfs_shares 
chgrp cinder /etc/cinder/nfs_shares#[nfs]
sed -i '$a\ ' /etc/cinder/cinder.conf
sed -i '$a\[nfs]' /etc/cinder/cinder.conf
sed -i '$a\volume_driver = cinder.volume.drivers.nfs.NfsDriver' /etc/cinder/cinder.conf
sed -i '$a\nfs_shares_config = /etc/cinder/nfs_shares' /etc/cinder/cinder.conf
sed -i '$a\nfs_mount_point_base = $state_path/mnt' /etc/cinder/cinder.conf
sed -i '$a\volume_backend_name = nfs' /etc/cinder/cinder.conf#nfs_snapshot_support = True
#nas_secure_file_operations = False
#nas_secure_file_permissions = False
sed -i '$a\nfs_snapshot_support = True' /etc/cinder/cinder.conf
sed -i '$a\nas_secure_file_operations = False' /etc/cinder/cinder.conf
sed -i '$a\nas_secure_file_permissions = False' /etc/cinder/cinder.conf/etc/init.d/tgt restart
/etc/init.d/cinder-volume restart}install_cinder

参考

Cinder Installation Guide