Home > Virtualization > Notes of Openstack Essex Installation (III)

Notes of Openstack Essex Installation (III)

What do we have so far? That’s an instance running inside the server and our ability to remotely control the instance by using ssh tool. It’s time do something more fascinating on that instance, we’re going to make it become a web server to provide a blog service. Let do our first move by ssh to that instance, and make sure that the following commands are executed on the instance.
$sudo apt-get install lamp-server^:lamp here stands for (Linux, Apache, MySQL, PHP), the password of root is set to wp-admin. Never forget the ^ character of the command. If everything is ok, you will see something like this:

Just continue with below commands:
$sudo -i
$mkdir blog
$cd blog
$wget http://wordpress.org/latest.tar.gz
$tar -xzvf latest.tar.gz
$cp -r blog /var/www
$sudo nano /etc/apache2/apache2.conf,  append this line to the end of the file:

AddType application/x-httpd-php .html

$sudo /etc/init.d/apache2 restart
$mysql -u root -p
$mysql>CREATE DATABASE wpdb;
$mysql>GRANT ALL PRIVILEGES ON wpdb.* TO “wpadmin”@”localhost” IDENTIFIED BY “wpsecret”;

$FLUSH PRIVILEGES;
$exit
$apt-get install memcached
Hereby, we installed all three wordpress, mysql and memcached on the same instance, however we also can do that on three separate ones.
Go to wordpress install directory and rename the file wp-config-sample.php to wp-config.php then correct the configs of DB_NAME,DB_USER, DB_PASSWORD, DB_HOST. Now begin to set up the your blog by running the install.php:

Make a snapshot for the instance. Whenever later we user this snapshot to launch a new instance, that instance will already have a blog running on it.


Swift installation
$sudo apt-get install swift swift-proxy swift-account swift-container swift-object
$sudo apt-get install xfsprogs curl python-pastedeploy
We use Loopback File as a storage device
$sudo dd if=/dev/zero of=/srv/swift-disk bs=1024 count=0 seek=1000000
$sudo mkfs.xfs -i size=1024 /srv/swift-disk
$file /srv/swift-disk

$sudo mkdir /mnt/swift_backend
$sudo nano /etc/fstab, add this line:

/srv/swift-disk /mnt/swift_backend xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0

$sudo mount /mnt/swift_backend
$pushd /mnt/swift_backend
$sudo mkdir node1 node2 node3 node4
$popd
$sudo chown swift.swift /mnt/swift_backend/*
$for i in {1..4}; do sudo ln -s /mnt/swift_backend/node$i /srv/node$i; done;
$sudo mkdir -p /etc/swift/account-server /etc/swift/container-server /etc/swift/object-server /srv/node1/device /srv/node2/device /srv/node3/device /srv/node4/device
$sudo mkdir /run/swift
$sudo chown -L -R swift.swift /etc/swift /srv/node[1-4]/ /run/swift
Append the following lines in /etc/rc.local just before “exit 0”

sudo mkdir /run/swift
sudo chown swift.swift /run/swift

$sudo nano /etc/default/rsync,change RSYNC_ENABLE=false to RSYNC_ENABLE=true
$sudo nano /etc/rsyncd.conf,edit the file like this:

# General stuff
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /run/rsyncd.pid
address = 127.0.0.1

# Account Server replication settings

[account6012]
max connections = 25
path = /srv/node1/
read only = false
lock file = /run/lock/account6012.lock

[account6022]
max connections = 25
path = /srv/node2/
read only = false
lock file = /run/lock/account6022.lock

[account6032]
max connections = 25
path = /srv/node3/
read only = false
lock file = /run/lock/account6032.lock

[account6042]
max connections = 25
path = /srv/node4/
read only = false
lock file = /run/lock/account6042.lock

# Container server replication settings

[container6011]
max connections = 25
path = /srv/node1/
read only = false
lock file = /run/lock/container6011.lock

[container6021]
max connections = 25
path = /srv/node2/
read only = false
lock file = /run/lock/container6021.lock

[container6031]
max connections = 25
path = /srv/node3/
read only = false
lock file = /run/lock/container6031.lock

[container6041]
max connections = 25
path = /srv/node4/
read only = false
lock file = /run/lock/container6041.lock

# Object Server replication settings

[object6010]
max connections = 25
path = /srv/node1/
read only = false
lock file = /run/lock/object6010.lock

[object6020]
max connections = 25
path = /srv/node2/
read only = false
lock file = /run/lock/object6020.lock

[object6030]
max connections = 25
path = /srv/node3/
read only = false
lock file = /run/lock/object6030.lock

[object6040]
max connections = 25
path = /srv/node4/
read only = false
lock file = /run/lock/object6040.lock

$sudo service rsync restart
$sudo nano /etc/swift/swift.conf, append these lines:

[swift-hash]
# random unique string that can never change (DO NOT LOSE). I’m using 03c9f48da2229770.
# od -t x8 -N 8 -A n < /dev/random
# The above command can be used to generate random a string.
swift_hash_path_suffix = 03c9f48da2229770

$sudo nano /etc/swift/proxy-server.conf, append the followings:

[DEFAULT]
bind_port = 8080
user = swift
swift_dir = /etc/swift

[pipeline:main]
# Order of execution of modules defined below
pipeline = catch_errors healthcheck cache authtoken keystone proxy-server

[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
set log_name = swift-proxy
set log_facility = LOG_LOCAL0
set log_level = INFO
set access_log_name = swift-proxy
set access_log_facility = SYSLOG
set access_log_level = INFO
set log_headers = True
account_autocreate = True

[filter:healthcheck]
use = egg:swift#healthcheck

[filter:catch_errors]
use = egg:swift#catch_errors

[filter:cache]
use = egg:swift#memcache
set log_name = cache

[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
auth_protocol = http
auth_host = 127.0.0.1
auth_port = 35357
auth_token = admin
service_protocol = http
service_host = 127.0.0.1
service_port = 5000
admin_token = admin
admin_tenant_name = service
admin_user = swift
admin_password = swift
delay_auth_decision = 0

[filter:keystone]
paste.filter_factory = keystone.middleware.swift_auth:filter_factory
operator_roles = admin, swiftoperator
is_admin = true

$sudo nano /etc/swift/account-server/1.conf

[DEFAULT]
devices = /srv/node1
mount_check = false
bind_port = 6012
user = swift
log_facility = LOG_LOCAL2

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]
vm_test_mode = no

[account-auditor]

[account-reaper]

$sudo cp /etc/swift/account-server/1.conf /etc/swift/account-server/2.conf
$sudo cp /etc/swift/account-server/1.conf /etc/swift/account-server/3.conf
$sudo cp /etc/swift/account-server/1.conf /etc/swift/account-server/4.conf
$sudo sed -i ‘s/6012/6022/g;s/LOCAL2/LOCAL3/g;s/node1/node2/g’ /etc/swift/account-server/2.conf
$sudo sed -i ‘s/6012/6032/g;s/LOCAL2/LOCAL4/g;s/node1/node3/g’ /etc/swift/account-server/3.conf
$sudo sed -i ‘s/6012/6042/g;s/LOCAL2/LOCAL5/g;s/node1/node4/g’ /etc/swift/account-server/4.conf
$sudo nano /etc/swift/container-server/1.conf


[DEFAULT]
devices = /srv/node1
mount_check = false
bind_port = 6011
user = swift
log_facility = LOG_LOCAL2

[pipeline:main]
pipeline = container-server

[app:container-server]
use = egg:swift#container

[container-replicator]
vm_test_mode = no

[container-updater]

[container-auditor]

[container-sync]

$sudo cp /etc/swift/container-server/1.conf /etc/swift/container-server/2.conf
$sudo cp /etc/swift/container-server/1.conf /etc/swift/container-server/3.conf
$sudo cp /etc/swift/container-server/1.conf /etc/swift/container-server/4.conf
$sudo sed -i ‘s/6011/6021/g;s/LOG_LOCAL2/LOG_LOCAL3/g;s/node1/node2/g’ /etc/swift/container-server/2.conf
$sudo sed -i ‘s/6011/6031/g;s/LOG_LOCAL2/LOG_LOCAL4/g;s/node1/node3/g’ /etc/swift/container-server/3.conf
$sudo sed -i ‘s/6011/6041/g;s/LOG_LOCAL2/LOG_LOCAL5/g;s/node1/node4/g’ /etc/swift/container-server/4.conf

$sudo nano /etc/swift/container-server.conf, add this line:

[container-sync]

$sudo nano /etc/swift/object-server/1.conf

[DEFAULT]
devices = /srv/node1
mount_check = false
bind_port = 6010
user = swift
log_facility = LOG_LOCAL2

[pipeline:main]
pipeline = object-server

[app:object-server]
use = egg:swift#object

[object-replicator]
vm_test_mode = no

[object-updater]

[object-auditor]

 

$sudo cp /etc/swift/object-server/1.conf /etc/swift/object-server/2.conf
$sudo cp /etc/swift/object-server/1.conf /etc/swift/object-server/3.conf
$sudo cp /etc/swift/object-server/1.conf /etc/swift/object-server/4.conf
$sudo sed -i ‘s/6010/6020/g;s/LOG_LOCAL2/LOG_LOCAL3/g;s/node1/node2/g’ /etc/swift/object-server/2.conf
$sudo sed -i ‘s/6010/6030/g;s/LOG_LOCAL2/LOG_LOCAL4/g;s/node1/node3/g’ /etc/swift/object-server/3.conf
$sudo sed -i ‘s/6010/6040/g;s/LOG_LOCAL2/LOG_LOCAL5/g;s/node1/node4/g’ /etc/swift/object-server/4.conf

$pushd /etc/swift
$sudo swift-ring-builder object.builder create 18 3 1
$sudo swift-ring-builder container.builder create 18 3 1
$sudo swift-ring-builder account.builder create 18 3 1

$sudo swift-ring-builder object.builder add z1-127.0.0.1:6010/device 1
$sudo swift-ring-builder object.builder add z2-127.0.0.1:6020/device 1
$sudo swift-ring-builder object.builder add z3-127.0.0.1:6030/device 1
$sudo swift-ring-builder object.builder add z4-127.0.0.1:6040/device 1
$sudo swift-ring-builder object.builder rebalance
$sudo swift-ring-builder container.builder add z1-127.0.0.1:6011/device 1
$sudo swift-ring-builder container.builder add z2-127.0.0.1:6021/device 1
$sudo swift-ring-builder container.builder add z3-127.0.0.1:6031/device 1
$sudo swift-ring-builder container.builder add z4-127.0.0.1:6041/device 1
$sudo swift-ring-builder container.builder rebalance
$sudo swift-ring-builder account.builder add z1-127.0.0.1:6012/device 1
$sudo swift-ring-builder account.builder add z2-127.0.0.1:6022/device 1
$sudo swift-ring-builder account.builder add z3-127.0.0.1:6032/device 1
$sudo swift-ring-builder account.builder add z4-127.0.0.1:6042/device 1
$sudo swift-ring-builder account.builder rebalance

$sudo swift-init main start
$sudo swift-init rest start, you properly see this error:

Unable to locate config for object-expirer

It can be fixed by creating a new file like this:
$sudo nano /etc/swift/object-expirer.conf, with the content:

[DEFAULT]
# swift_dir = /etc/swift
# user = swift
# You can specify default log routing here if you want:
# log_name = swift
# log_facility = LOG_LOCAL0
# log_level = INFO
# log_address = /dev/log
# You can enable default statsD logging here if you want:
# log_statsd_host = localhost
# log_statsd_port = 8125
# log_statsd_default_sample_rate = 1
# log_statsd_metric_prefix =

[object-expirer]
# interval = 300
# auto_create_account_prefix = .
# report_interval = 300

[pipeline:main]
pipeline = catch_errors cache proxy-server

[app:proxy-server]
use = egg:swift#proxy
# See proxy-server.conf-sample for options

[filter:cache]
use = egg:swift#memcache
# See proxy-server.conf-sample for options

[filter:catch_errors]
use = egg:swift#catch_errors
# See proxy-server.conf-sample for options

$sudo chown -R swift.swift /etc/swift
$swift -v -V 2.0 -A http://127.0.0.1:5000/v2.0/ -U service:swift -K swift stat


Due to official guide’s inadequate consideration, when you create a new user (using the web interface), this user cannot list retrieve its container information, you will receive an error like this “Error:Unable to retrieve container list.”. The reason is the default tole of new user is set to Member (you can check it in /etc/openstack-dashboard/local_settings.py), however we did not add it to the file etc/swift/proxy-server.conf. Now let open that file, find the line operator_roles = admin, swiftoperator and change it to operator_roles = admin, swiftoperator, Member (pay attention to the capital M), everything will be ok.

Categories: Virtualization Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: