Cài đặt và cấu hình Liberty OpenStack – Phần 1
Mô hình triển khai (xem file đính kèm)
Các thiết lập cơ bản
1.Cài đặt Controller
apt-get -y install software-properties-common
add-apt-repository -y cloud-archive:liberty
Thiết lập IP, hostname
echo "controller" > /etc/hostname
hostname -F /etc/hostname
Thiết lập địa chỉ IP
cp /etc/network/interfaces /etc/network/interfaces.bak
cat << EOF > /etc/network/interfaces
# NIC loopback
auto lo
iface lo inet loopback
# NIC MGNG
auto eth0
iface eth0 inet static
address 10.10.10.40
netmask 255.255.255.0
# NIC EXTERNAL
auto eth1
iface eth1 inet static
address 172.16.69.40
netmask 255.255.255.0
gateway 172.16.69.1
dns-nameservers 8.8.8.8
EOF
Cấu hình file /etc/hosts để phân giản IP cho các node
cat << EOF > /etc/hosts
127.0.0.1 controller localhost
10.10.10.40 controller
10.10.10.41 compute1
EOF
Update và khởi động lại node controller
apt-get update -y && apt-get upgrade -y && apt-get dist-upgrade -y && init 6
Đăng nhập với IP mới của node controller
2. Cài đăt các gói phần mềm
Cài đặt gói OpenStack Client
apt-get -y install python-openstackclient
Cài đặt My SQL
Trong quá trình cài đặt yêu cầu nhập mật khẩu My SQL, sử dụng mật khẩu Openstack12345 để thống nhất.
apt-get -y install mariadb-server python-pymysql
Tạo file với nội dung sau
cat << EOF > /etc/mysql/conf.d/mysqld_openstack.cnf
[mysqld]
bind-address = 10.10.10.40
[mysqld]
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
EOF
Khởi động lại MYSQL
service mysql restart
Cài đặt Message queue
Cài đặt gói rabbitmq
apt-get -y install rabbitmq-server
Tạo tài khoản openstack cho rabbitmq
rabbitmqctl add_user openstack Openstack12345
Cấp quyền cho tài khoản openstack
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Cài đặt dịch vụ Keystone
Tạo database cho keystone
Đăng nhập vào MariaDB
mysql -u root -pOpenstack12345
Tạo DB tên là keystone và gán quyền
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'Openstack12345';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'Openstack12345';
flush privileges;
exit;
Cài đặt Keystone
Cấu hình không cho Keystone tự động khởi động.
echo "manual" > /etc/init/keystone.override
Cài đặt các gói dành cho Keystone
apt-get -y install keystone apache2 libapache2-mod-wsgi memcached python-memcache
cp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak
rm /etc/keystone/keystone.conf
[DEFAULT]
log_dir = /var/log/keystone
admin_token = Openstack12345
public_bind_host = 10.10.10.40
admin_bind_host = 10.10.10.40
[assignment]
[auth]
[cache]
[catalog]
[cors]
[cors.subdomain]
[credential]
[database]
connection = mysql+pymysql://keystone:Openstack12345@10.10.10.40/keystone
[domain_config]
[endpoint_filter]
[endpoint_policy]
[eventlet_server]
[eventlet_server_ssl]
[federation]
[fernet_tokens]
[identity]
[identity_mapping]
[kvs]
[ldap]
[matchmaker_redis]
[matchmaker_ring]
[memcache]
servers = localhost:11211
[oauth1]
[os_inherit]
[oslo_messaging_amqp]
[oslo_messaging_qpid]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
[policy]
[resource]
[revoke]
driver = sql
[role]
[saml]
[signing]
[ssl]
[token]
provider = uuid
driver = memcache
[tokenless_auth]
[trust]
[extra_headers]
Distribution = Ubuntu
Đồng bộ database cho keystone
su -s /bin/sh -c "keystone-manage db_sync" keystone
echo "ServerName 10.10.10.40" > /etc/apache2/conf-available/servername.conf
Tạo file /etc/apache2/sites-available/wsgi-keystone.conf với nội dung sau
Listen 5000
Listen 35357
<VirtualHost *:5000>
WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-public
WSGIScriptAlias / /usr/bin/keystone-wsgi-public
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/apache2/keystone.log
CustomLog /var/log/apache2/keystone_access.log combined
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>
<VirtualHost *:35357>
WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
WSGIProcessGroup keystone-admin
WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/apache2/keystone.log
CustomLog /var/log/apache2/keystone_access.log combined
<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>
Cấu hình virtual host cho keystone
ln -s /etc/apache2/sites-available/wsgi-keystone.conf /etc/apache2/sites-enabled
Khởi động lại apache
service apache2 restart
Xóa SQLite mặc định của keystone
rm -f /var/lib/keystone/keystone.db
Khai báo biến môi trường để cài đặt KeyStone
export OS_TOKEN=Openstack12345
export OS_URL=http://10.10.10.40:35357/v3
export OS_IDENTITY_API_VERSION=3
Tạo user, endpoint, role, tenant cho Keystone
openstack service create --name keystone --description "OpenStack Identity" identity
openstack endpoint create --region RegionOne identity public http://10.10.10.40:5000/v2.0
openstack endpoint create --region RegionOne identity internal http://10.10.10.40:5000/v2.0
openstack endpoint create --region RegionOne identity admin http://10.10.10.40:35357/v2.0
openstack project create --domain default --description "Admin Project" admin
openstack user create --domain default --password Openstack12345 admin
openstack role create admin
openstack role add --project admin --user admin admin
openstack project create --domain default --description "Service Project" service
openstack project create --domain default --description "Demo Project" demo
openstack user create --domain default --password Openstack12345 demo
openstack role create user
openstack role add --project demo --user demo user
unset OS_TOKEN OS_URL
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=Openstack12345
export OS_AUTH_URL=http://10.10.10.40:35357/v3
export OS_IDENTITY_API_VERSION=3
chmod +x admin.sh
source admin.sh
openstack token issue
+------------+----------------------------------+
| Field | Value |
+------------+----------------------------------+
| expires | 2015-11-17T09:53:40.242778Z |
| id | de796ac24b2545efb99487d9ff4e981a |
| project_id | c685a5fa3e474261b678aeb59332ce0d |
| user_id | 818e335d15484101b6a2a69e5f9d4f61 |
+------------+----------------------------------+
Cài đặt GLANCE
mysql -u root -pOpenstack12345
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'Openstack12345';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'Openstack12345';
quit;
openstack user create --domain default --password Openstack12345 glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image service" image
openstack endpoint create --region RegionOne image public http://10.10.10.40:9292
openstack endpoint create --region RegionOne image internal http://10.10.10.40:9292
openstack endpoint create --region RegionOne image admin http://10.10.10.40:9292
apt-get -y install glance python-glanceclient
cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
rm /etc/glance/glance-api.conf
[DEFAULT]
notification_driver = noop
verbose = True
[database]
connection = mysql+pymysql://glance:Openstack12345@10.10.10.40/glance
backend = sqlalchemy
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[keystone_authtoken]
auth_uri = http://10.10.10.40:5000
auth_url = http://10.10.10.40:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = Openstack12345
[matchmaker_redis]
[matchmaker_ring]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_qpid]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone
[store_type_location_strategy]
[task]
[taskflow_executor]
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
rm /etc/glance/glance-registry.conf
[DEFAULT]
notification_driver = noop
verbose = True
[database]
connection = mysql+pymysql://glance:Openstack12345@10.10.10.40/glance
backend = sqlalchemy
[glance_store]
[keystone_authtoken]
auth_uri = http://10.10.10.40:5000
auth_url = http://10.10.10.40:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = Openstack12345
[matchmaker_redis]
[matchmaker_ring]
[oslo_messaging_amqp]
[oslo_messaging_qpid]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone
su -s /bin/sh -c "glance-manage db_sync" glance
rm -f /var/lib/glance/glance.sqlite
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin.sh
source admin.sh
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
glance image-create --name "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--visibility public --progress
(Xem tiếp phần 2)
» Danh sách Tập tin đính kèm:
» Tin mới nhất:
» Các tin khác: