Openstack安装与配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Openstack安装与配置相关的知识,希望对你有一定的参考价值。

  • 安装环境

    Memcached编译安装环境
    L:Linux(centos 7.2)

    主机信息:

    CPU >=2C,开启支持虚拟化

    内存 >=3072MB

    HD =100GB

    部署规划:
    172.24.77.221linux1-host.jay.com):运行

    172.24.77.222linux2-host.jay.com):运行

    查看 openstack yum 版本

    yum list centos-release-openstack*

    centos-release-openstack-queens.noarch 1-2.el7.centos extras
    centos-release-openstack-rocky.noarch 1-1.el7.centos extras
    centos-release-openstack-stein.noarch 1-1.el7.centos extras
    centos-release-openstack-train.noarch 1-1.el7.centos extras

    各服务器安装 ocata 的 yum 源

    yum install centos-release-openstack-ocata #旧版本安装,需要yum源支持

    yum install –y centos-release-openstack-queens.noarch

    yum install -y https://rdoproject.org/repos/rdo-release.rpm

    安装文档

    https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/

    各服务器安装 openstack 客户端

    yum install -y python-openstackclient

    各服务器安装 openstack SElinux 管理包

    yum install -y openstack-selinux

    安装数据库服务器:224

    可以单独安装至其他服务器, openstack 的各组件都要使用数据库保存数据, 除了nova 使用
    API 与其他组件进行调用之外

    控制端安 python 连接 SQL 模块:用于控制端连接数据库

    安装 mariadb

    yum install -y mariadb python2-Pymysql

    yum install -y mariadb mariadb-server

    配置数据库

    vim /etc/my.cnf.d/openstack.cnf

    [mysqld]
    bind-address = 172.24.77.224
    default-storage-engine = innodb
    innodb_file_per_table = on
    max_connections = 4096
    collation-server = utf8_general_ci
    character-set-server = utf8

    配置 my.cnf

    vim /etc/my.cnf

    datadir=/data/mysql
    socket=/var/lib/mysql/mysql.sock
    user=mysql
    symbolic-links=0
    innodb_file_per_table=1
    relay-log=/data/mysql
    server-id=10
    log-error=/data/mysql-log/mysql_error.txt
    log-bin=/data/mysql-bin/master-log
    long_query_time=5
    slow_query_log=1
    slow_query_log_file=/data/mysql-log/slow_mysql.txt
    max_connections=1000
    bind-address=172.24.77.224
    port=3306
    socket=/var/lib/mysql/mysql.sock
    log-error=/data/mysql-log/mysqld-safe.log
    pid-file=/var/lib/mysql/mysql.sock

    创建数据目录并授权

    mkdir -pv /data/{mysql,mysql-log,mysql-binlog}

    chown mysql.mysql /data/*

    启动 Mariadb 并验证

    systemctl start mariadb

    systemctl enable mariadb

    初始化设置

    mysql_secure_installation

    root password:123456

    部署 keepalived:在两台负载服务器同时执行以下操作

    wget http://www.keepalived.org/software/keepalived-1.3.6.tar.gz

    tar xvf keepalived-1.3.6.tar.gz

    cd keepalived-1.3.6

    yum install libnfnetlink-devel libnfnetlink ipvsadm libnl libnl-devel libnl3 libnl3-devel lm_sensors-libs net-snmp-agent-libs net-snmp-libs openssh-server openssh-clients openssl openssl-devel tree sudo psmisc lrzsz gcc gcc-c++ automake pcre pcredevel zlib zlib-devel openssl openssl-devel iproute

    ./configure --prefix=/usr/local/keepalived --disable-fwmark
    make && make install

    准备 keepalived 配置文件 :master 服务器

    mkdir /etc/keepalived

    vim /etc/keepalived/keepalived.conf

    vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 1
    priority 100
    advert_int 1
    unicast_src_ip 172.24.77.224
    unicast_peer {
    172.24.77.225
    }
    authentication {
    auth_type PASS
    auth_pass 123456
    }
    virtual_ipaddress {
    172.24.77.226/25 dev eth0 label eth0:0
    }
    }

    启动keepalive

    systemctl start keepalived

    systemctl enable keepalived

    [root@linux4-host keepalived-1.3.6]# ps -ef |grep keepalive
    root 8478 1 0 01:08 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 8479 8478 0 01:08 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 8480 8478 0 01:08 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 8499 2645 0 01:09 pts/0 00:00:00 grep --color=auto keepalive

    准备 keepalived 配置文件 :backup服务器

    mkdir /etc/keepalived

    vim /etc/keepalived/keepalived.conf

    vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 1
    priority 100
    advert_int 1
    unicast_src_ip 172.24.77.225
    unicast_peer {
    172.24.77.224
    }
    authentication {
    auth_type PASS
    auth_pass 123456
    }
    virtual_ipaddress {
    172.24.77.226/25 dev eth0 label eth0:0
    }
    }

    启动keepalive

    systemctl start keepalived

    systemctl enable keepalived

    [root@localhost keepalived-1.3.6]# ps -ef |grep keepalive
    root 9961 1 0 01:11 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 9962 9961 0 01:11 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 9963 9961 0 01:11 ? 00:00:00 /usr/local/keepalived/sbin/keepalived -D
    root 9982 3165 0 01:12 pts/0 00:00:00 grep --color=auto keepalive

部署 haproxy

分别在两台负载服务器同时执行以下操作安装 haproxy(版本自定)

wget http://www.haproxy.org/download/1.7/src/haproxy-1.7.9.tar.gz

tar xvf haproxy-1.8.20.tar.gz

cd haproxy-1.8.20

make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 PREFIX=/usr/local/haproxy

make install PREFIX=/usr/local/haproxy

准备 haproxy 启动脚本

vim /usr/lib/systemd/system/haproxy.service

[Unit]
Description=HAProxy Load Balancer
After=syslog.target network.target
[Service]
EnvironmentFile=/etc/sysconfig/haproxy
ExecStart=/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
$OPTIONS
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target

cp ./haproxy-systemd-wrapper /usr/sbin/haproxy-systemdwrapper#1.8版本无此文件

cp ./haproxy /usr/sbin/haproxy

准备系统配置文件

vim /etc/sysconfig/haproxy

# Add extra options to the haproxy daemon here. This can be useful for
# specifying multiple configuration files with multiple -f options.
# See haproxy(1) for a complete list of options.
OPTIONS=""

配置主配置文件

mkdir /var/lib/haproxy

mkdir /etc/haproxy

vim /etc/haproxy/haproxy.cfg

global
maxconn 100000
uid 99
gid 99
daemon
nbproc 1
log 127.0.0.1 local0 info
chroot /usr/local/haproxy
stats socket /var/lib/haproxy/haproxy.socket mode 600 level admin
defaults
option redispatch
option abortonclose
option http-keep-alive
option forwardfor
maxconn 100000
mode http
timeout connect 10s
timeout client 20s
timeout server 30s
timeout check 5s
listen stats
mode http
bind 0.0.0.0:9999
stats enable
log global
stats uri /haproxy-status
stats auth haadmin:3344521
frontend test
bind 172.24.77.226:80
mode http
default_backend test_http_nodes
backend test_http_nodes
mode http
balance source
server 127.0.0.1 127.0.0.1:80 check inter 2000 fall 3 rise 5

各负载服务器配置内核参数

vim /etc/sysctl.conf

net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1

sysctl -p

启动 haproxy 并验证

systemctl start haproxy

或者

/usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg

systemctl enable haproxy

[root@linux4-host ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 172.24.77.224:3306 :
LISTEN 0 128 :9999 :
LISTEN 0 128 172.24.77.226:80
:
LISTEN 0 128
:22 :
LISTEN 0 100 127.0.0.1:25 :
LISTEN 0 128 [::]:22 [::]:
LISTEN 0 100 [::1]:25 [::]:

[root@linux-host5 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :9999 :
LISTEN 0 128 172.24.77.226:80
:
LISTEN 0 128
:22 :
LISTEN 0 100 127.0.0.1:25 :
LISTEN 0 128 [::]:22 [::]:
LISTEN 0 100 [::1]:25 [::]:

安装 rabbitMQ 服务器225

可以单独安装至其他服务器:各组件通过消息发送与接收是实现组件之间的通信

yum install ncurses ncurses-base ncurses-devel ncurses-libs ncurses-static ncurses-term ocaml-curses ocaml-curses-devel openssl-devel zlib-devel make ncurses-devel gcc gcc-c++ unixODBC unixODBC-devel openssl openssl-devel -y
cd /usr/local/src

安装erlang
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm

安装rpm仓库
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm

安装erlang
yum -y install erlang

安装RabbitMQ

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el6.noarch.rpm
yum -y install rabbitmq-server-3.6.6-1.el6.noarch.rpm

启动rabbitmq服务:
service rabbitmq-server start

[root@linux-host5 ~]# service rabbitmq-server start
Starting rabbitmq-server (via systemctl): [ OK ]

安装插件
启动web管理界面
rabbitmq-plugins enable rabbitmq-management

增加访问用户,默认用户guest只能本地访问。
rabbitmqctl add_user admin passwd

设置角色:
rabbitmqctl set_user_tags admin administrator

设置默认vhost("/")访问权限
rabbitmqctl set_permissions -p "/" admin "." "." ".*"

浏览器访问:http://IP:15672

用户名admin,密码passwd进行登录

最好登录console的时候,删除默认账户guest

安装 memcached-225

yum install memcached -y

openstack 安装 python 模块

yum install python-memcached –y

编辑配置文件

vim /etc/sysconfig/memcached
PORT="11212"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS="-l 172.24.77.225"

systemctl start memcached

systemctl enable memcached

[root@linux-host5 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 :11212 :*

未完待续。。。

以上是关于Openstack安装与配置的主要内容,如果未能解决你的问题,请参考以下文章

Apache Stratos的安装与配置

openstack-mitaka之计算服务controller节点的安装配置与部署

OpenStack——自动安装部署

OpenStack——自动安装部署

openstack详解——openstack rabbitmq安装与启动

OpenStack 运维 - 部署Keystone组件 [T版]