From ad74d5116f2ef9473466270845f840f6a8f1a1a0 Mon Sep 17 00:00:00 2001 From: Francisco Redondo Marchena Date: Wed, 17 Dec 2014 18:07:16 +0000 Subject: Configure neutron to use postgres instead of sqlite Sqlite does not support some ALTER TABLE required on neutron-db-manage upgrade. Therefore sqlite is not a valid database to use for neutron. NOTE: juno requires to "upgrade" the database from icehouse because "stamp" the database directly to juno does not create all the tables required for using ml2 plugin --- openstack/etc/neutron/neutron.conf | 3 +- .../systemd/system/openstack-neutron-setup.service | 4 +-- .../usr/share/openstack/openstack-neutron-setup | 33 ++++++++++++++++------ 3 files changed, 28 insertions(+), 12 deletions(-) (limited to 'openstack') diff --git a/openstack/etc/neutron/neutron.conf b/openstack/etc/neutron/neutron.conf index 440457ac..40c57054 100644 --- a/openstack/etc/neutron/neutron.conf +++ b/openstack/etc/neutron/neutron.conf @@ -575,7 +575,8 @@ admin_password = ##NEUTRON_SERVICE_PASSWORD## # be set in the corresponding core plugin '.ini' file. However, it is suggested # to put the [database] section and its connection attribute in this # configuration file. -connection=sqlite:////var/lib/neutron/neutron.sqlite +#connection=sqlite:////var/lib/neutron/neutron.sqlite +connection=postgresql://##NEUTRON_DB_USER##:##NEUTRON_DB_PASSWORD##@127.0.0.1/neutron # Database engine for which script will be generated when using offline # migration diff --git a/openstack/etc/systemd/system/openstack-neutron-setup.service b/openstack/etc/systemd/system/openstack-neutron-setup.service index c90e7122..ae6da897 100644 --- a/openstack/etc/systemd/system/openstack-neutron-setup.service +++ b/openstack/etc/systemd/system/openstack-neutron-setup.service @@ -1,7 +1,7 @@ [Unit] Description=Run openstack-neutron-setup (once) -Requires=openstack-keystone-setup.service openstack-neutron-network-configuration-one-node.service -After=openstack-keystone-setup.service openstack-neutron-network-configuration-one-node.service +Requires=openstack-keystone-setup.service openstack-neutron-network-configuration-one-node.service postgres-server.service +After=openstack-keystone-setup.service openstack-neutron-network-configuration-one-node.service postgres-server.service [Service] Type=oneshot diff --git a/openstack/usr/share/openstack/openstack-neutron-setup b/openstack/usr/share/openstack/openstack-neutron-setup index 9955e9c6..94b0791c 100644 --- a/openstack/usr/share/openstack/openstack-neutron-setup +++ b/openstack/usr/share/openstack/openstack-neutron-setup @@ -24,8 +24,9 @@ getent passwd neutron >/dev/null || \ useradd --uid 166 -r -g neutron -d /var/lib/neutron -s /sbin/nologin \ -c "OpenStack Neutron Daemons" neutron -# Create the keystone user and services +chown -R neutron:neutron /var/lib/neutron +# Create the keystone user and services export OS_SERVICE_TOKEN=##KEYSTONE_TEMPORARY_ADMIN_TOKEN## export OS_SERVICE_ENDPOINT='http://localhost:35357/v2.0' @@ -55,25 +56,39 @@ if [ ! -d /var/log/neutron ]; then fi # Setup the neutron database -if [ ! -e /var/lib/neutron/neutron.sqlite ]; then - chown -R neutron:neutron /var/lib/neutron - # Stamp the database with the version of neutron we are using. This is - # needed before we can run any neutron services. - sudo -u neutron neutron-db-manage --config-file /etc/neutron/neutron.conf \ - --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ - stamp --sql juno +if ! sudo -u postgres psql -lqt | grep -q neutron; then + # Create postgresSQL user + sudo -u postgres createuser \ + --pwprompt --encrypted \ + --no-adduser --no-createdb \ + --no-password \ + ##NEUTRON_DB_USER## + sudo -u postgres createdb \ + --owner=##NEUTRON_DB_USER## \ + neutron + # Stamp neutron database with the latest stamped version available, + # in this case "icehouse" + sudo -u neutron neutron-db-manage \ + --config-file /etc/neutron/neutron.conf \ + --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ + stamp icehouse + # Upgrade database to "juno" + sudo -u neutron neutron-db-manage \ + --config-file /etc/neutron/neutron.conf \ + --config-file /etc/neutron/plugins/ml2/ml2_conf.ini \ + upgrade juno fi # Remove the one-shot setup service rm /etc/systemd/system/multi-user.target.wants/openstack-neutron-setup.service # Start neutron services +systemctl start openstack-neutron-server systemctl start openstack-neutron-metadata-agent systemctl start openstack-neutron-plugin-openvswitch-agent systemctl start openstack-neutron-ovs-cleanup systemctl start openstack-neutron-dhcp-agent systemctl start openstack-neutron-l3-agent -systemctl start openstack-neutron-server # Create the links to run neutron services when system start next times. ln -s "/etc/systemd/system/openstack-neutron-server.service" \ -- cgit v1.2.1