IT/openstack

OpenStack 설치 (5) - Compute 노드 (Cinder, Swift 포함)

울티마 2015. 8. 19. 17:21

1. 가상화 지원 확인
# egrep -c '(vmx|svm)' /proc/cpuinfo
# cat /proc/cpuinfo | egrep '(vmx|svm)'

2. Nove - Compute 서비스 설치
- 패키지 설치
# sudo apt-get install nova-compute-kvm python-guestfs qemu-kvm

# sudo dpkg-statoverride  --update --add root root 0644 /boot/vmlinuz-$(uname -r)
# sudo vi /etc/kernel/postinst.d/statoverride
   #!/bin/sh
   version="$1"
   # passing the kernel version is required
   [ -z "${version}" ] && exit 0
   dpkg-statoverride --update --add root root 0644 /boot/vmlinuz-${version}
# sudo chmod +x /etc/kernel/postinst.d/statoverride

- config 수정
$ sudo vi /etc/nova/nova.conf
[DEFAULT]
auth_strategy = keystone
rpc_backend = rabbit
rabbit_host = 192.168.0.221
rabbit_password = rabbitpass
my_ip = 192.168.0.223
vnc_enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = 192.168.0.223
novncproxy_base_url = http://192.168.0.221:6080/vnc_auto.html
glance_host =192.168.0.221
[database]
# The SQLAlchemy connection string used to connect to the database
connection = mysql://nova:novadbpass@10.10.15.11/nova
[keystone_authtoken]
auth_uri = http://192.168.0.221:5000
auth_host =192.168.0.221
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = nova
admin_password = novapass

- 가상화 환경에서 구성할 경우 적용
$ sudo vi /etc/nova/nova-compute.conf
[libvirt]
virt_type = qemu

- 서비스 재가동
$ sudo rm /var/lib/nova/nova.sqlite
$ sudo service nova-compute restart

3. Neutron - Network 서비스 설치
- Kernel 파라미터 수정
# sudo vi /etc/sysctl.conf
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0

# sysctl -p
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0

- 패키지 설치 : Neutron, ML2, OpenvSwitch
# sudo apt-get install neutron-common neutron-plugin-ml2 neutron-plugin-openvswitch-agent openvswitch-datapath-dkms

- config 수정
$ sudo vi /etc/neutron/neutron.conf
[DEFAULT]
# Identity service
auth_strategy = keystone
# Message broker
rpc_backend = neutron.openstack.common.rpc.impl_kombu
rabbit_host = 192.168.0.221
rabbit_userid = guest
rabbit_password = rabbitpass

# Modular Layer 2 plugin
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

[keystone_authtoken]
auth_uri = http://192.168.0.221:5000
auth_host =192.168.0.221
auth_protocol = http
auth_port = 35357
admin_tenant_name = service
admin_user = neutron
admin_password = neutronpass

[database]
connection = mysql://neutron:neutrondbpass@192.168.0.221/neutron

$ sudo vi /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = gre
tenant_network_types = gre
mechanism_drivers = openvswitch

[ml2_type_gre]
tunnel_id_ranges = 1:1000

[ovs]
local_ip = 10.10.10.223 #eth1 IP Address
tunnel_type = gre
enable_tunneling = True

[securitygroup]
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
enable_security_group = True

- OpenvSwitch 재가동
# service openvswitch-switch restart
# sudo ovs-vsctl del-br br-int
# sudo ovs-vsctl add-br br-int

- Nova config 수정
# sudo vi /etc/nova/nova.conf
[DEFAULT]
network_api_class = nova.network.neutronv2.api.API
neutron_url = http://192.168.0.221:9696
neutron_auth_strategy = keystone
neutron_admin_tenant_name = service
neutron_admin_username = neutron
neutron_admin_password = neutronpass
neutron_admin_auth_url = http://192.168.0.221:35357/v2.0
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
security_group_api = neutron

# sudo service nova-compute restart
# sudo service neutron-plugin-openvswitch-agent restart


4. Cinder Volume 설치
- LVM 구성
$ sudo apt-get install lvm2
$ sudo fdisk -l
$ sudo pvcreate /dev/sdc
$ sudo vgcreate cinder-volumes /dev/sdc
$ sudo vi /etc/lvm/lvm.conf
devices {
filter = [ "a/sda1/", "a/sdc/", "r/.*/"]
}

- 패키지 설치
$ sudo apt-get install cinder-volume

- config 수정
$ sudo vi /etc/cinder/cinder.conf
[DEFAULT]
my_ip = 10.10.10.223
rpc_backend = cinder.openstack.common.rpc.impl_kombu
rabbit_host = 192.168.0.221
rabbit_port = 5672
rabbit_userid = guest
rabbit_password = rabbitpass
glance_host = 192.168.0.221
[keystone_authtoken]
auth_uri = http://192.168.0.221:5000
auth_host = 192.168.0.221
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = cinder
admin_password = cinderpass
[database]
connection = mysql://cinder:cinderdbpass@192.168.0.221/cinder

- 서비스 재가동
$ sudo service cinder-volume restart
$ sudo service tgt restart

- 서비스 확인
* controller에서 서비스 및 볼륨 생성
root@controller:/etc/cinder# cinder-manage host list
host                            zone
controller                      nova
compute1                        nova
root@controller:/etc/cinder# cinder-manage service list
Binary           Host                                 Zone             Status     State Updated At
cinder-scheduler controller                           nova             enabled    :-)   2015-08-16 03:07:45
cinder-volume    compute1                             nova             enabled    :-)   2015-08-16 03:07:41

root@controller:/etc/cinder# cinder create --display-name testVol1 10
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2015-08-16T03:08:43.522134      |
| display_description |                 None                 |
|     display_name    |               testVol1               |
|      encrypted      |                False                 |
|          id         | eee160b0-f658-4f19-b5b7-f7c2850e3a9d |
|       metadata      |                  {}                  |
|         size        |                  10                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+
root@controller:/etc/cinder# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| eee160b0-f658-4f19-b5b7-f7c2850e3a9d | available |   testVol1   |  10  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

* compute 서비스에서
root@compute1:~# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| eee160b0-f658-4f19-b5b7-f7c2850e3a9d | available |   testVol1   |  10  |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
root@compute1:~#
root@compute1:~# vgs
  VG             #PV #LV #SN Attr   VSize   VFree
  cinder-volumes   1   1   0 wz--n- 500.00g 490.00g
root@compute1:~# lvs
  LV                                          VG             Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  volume-eee160b0-f658-4f19-b5b7-f7c2850e3a9d cinder-volumes -wi-a- 10.00g

5. Swift Storage Node 설치
- 사전 준비
$ sudo mkdir -p /etc/swift
$ openssl rand -hex 10
  <rand_suffix>    <== 145e2e0bde099c923b6d
$ sudo vi /etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = <rand_suffix>

# sudo cat /etc/swift/swift.conf
[swift-hash]
swift_hash_path_suffix = 145e2e0bde099c923b6d

- 패키지 설치
$ sudo apt-get install swift swift-account swift-container swift-object xfsprogs python-swiftclient python-keystoneclient

- 디스크 파티션 생성, 포맷, 마운트
root@compute1:~# fdisk /dev/sdb
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-2097151999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151999, default 2097151999):
Using default value 2097151999

Command (m for help): w
root@compute1:~# ls /dev/sdb1
/dev/sdb1

$ sudo mkfs.xfs /dev/sdb1

$ sudo echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab

$ sudo mkdir -p /srv/node/sdb1
$ sudo mount /srv/node/sdb1
$ sudo chown -R swift:swift /srv/node

- rsync 설정
$ sudo vi /etc/rsyncd.conf
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.0.223
[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock
[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock
[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock
-
$ sudo vi /etc/default/rsync
RSYNC_ENABLE=true

$ sudo service rsync start
$ sudo mkdir -p /var/swift/recon
$ sudo chown -R swift:swift /var/swift/recon

- controller에서 ring.gz 파일 복사
$ scp swift@192.168.0.221:/etc/swift/*.ring.gz /etc/swift
$ for service in swift-object swift-object-replicator swift-object-updater swift-object-auditor swift-container swift-container-replicator swift-container-updater \
  swift-container-auditor swift-account swift-account-replicator swift-account-reaper swift-account-auditor; \
  do service $service start; done