#!/bin/bash
控制节点-环境准备
基本规划
控制节点 | 计算节点 |
---|---|
10.130.0.31 | 10.130.0.87 |
一、环境准备
1.hostname主机名配置
hostnamectl set-hostname controller
exec bash
#添加host
controller_ip=“10.130.0.31”
computer_ip=“10.130.0.87”
echo “ c o n t r o l l e r i p c o n t r o l l e r " > > / e t c / h o s t s e c h o " controller_ip controller" >> /etc/hosts echo " controlleripcontroller">>/etc/hostsecho"computer_ip computer” >> /etc/hosts
注释:设置完主机名后需要重启,否则在rabbitmq-server启动时会出错
2.免密登录(可选)
ssh-keygen
选取默认路径存储:/root/.ssh/id_rsa
ssh-copy-id -i /root/.ssh/id_rsa.pub root@10.130.0.87
3.禁用防火墙
#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
#关闭SELinux
setenforce 0
sed -i “s/SELINUX=enforcing/SELINUX=disabled/g” /etc/selinux/config
#关闭swap分区
swapoff -a
sed -i ‘/ swap / s/^(.*)$/#\1/g’ /etc/fstab
4.设置内核
modprobe bridge
modprobe br_netfilter
cat > /etc/sysconfig/modules/neutron.modules <<EOF
#!/bin/bash
modprobe – bridge
modprobe – br_netfilter
EOF
chmod 755 /etc/sysconfig/modules/neutron.modules && bash /etc/sysconfig/modules/neutron.modules
echo “vm.max_map_count=262144” >> /etc/sysctl.conf
echo “net.ipv4.ip_forward=1” >> /etc/sysctl.conf
echo “net.bridge.bridge-nf-call-iptables=1” >> /etc/sysctl.conf
echo “net.bridge.bridge-nf-call-ip6tables=1” >> /etc/sysctl.conf
sysctl -p
5.yum源配置
#loongnix-server源准备
#配置openstack及虚拟化相关源,打开Loongnix-Plus.repo和Loongnix-PowerTools.repo两个源
yum install -y loongnix-release-epel loongnix-release-openstack-ussuri loongnix-release-advanced-virtualization
#配置完成后,通常需要清除yum中原有的cache,并重新生成cache。清除yum陈旧cache的命令如下
yum clean all
yum makecache
系统基础软件工具安装与配置
1.基础
2.NTP时间同步
#设置时间同步
yum install -y chrony && yum -y autoremove
sed -i ‘/^pool/d’ /etc/chrony.conf
sed -i ‘/^server/d’ /etc/chrony.conf
echo “pool ntp.aliyun.com iburst” >> /etc/chrony.conf
systemctl start chronyd.service && systemctl enable chronyd.service
二、 OpenStack基础软件安装
1.Openstack配置工具安装
yum install -y openstack-utils
2.OpenStack客户端相关软件
#安装openstack命令
yum install -y python3-openstackclient
3.基础服务:数据库SQL database
#安装sql
yum install -y mariadb mariadb-server python3-PyMySQL
#创建/etc/my.cnf.d/openstack.cnf并进行配置
sudo tee /etc/my.cnf.d/openstack.cnf <<-‘EOF’
[mysqld]
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
EOF
systemctl enable mariadb.service
systemctl start mariadb.service
4.基础服务:消息队列Message queue
方法一:rpm包安装
#安装rabbitmq-server
yum install rabbitmq-server -y
#启动消息队列并将其配置为随系统启动
systemctl enable rabbitmq-server.service
systemctl start rabbitmq-server.service
systemctl status rabbitmq-server.service
#增加guest用户,并设置密码为loongson
rabbitmqctl add_user guest loongson
#给guest用户配置权限
rabbitmqctl set_permissions guest “." ".” “.*”
方法二、采用容器方式安装
#安装docker-ce
yum install -y docker-ce
mkdir -p /etc/docker/
tee /etc/docker/daemon.json <<-‘EOF’
{
“insecure-registries”:[“harbor.loongnix.cn”]
}
EOF
sudo systemctl daemon-reload
sudo systemctl enable docker
sudo systemctl restart docker
#使用龙芯harbor帐号密码登录
docker login -u loongsoncloud -p loongson@SYS3 harbor.loongnix.cn
#安装消息队列服务
#注意,需要手动配置远程访问功能
docker run --restart=always -dit --name Myrabbitmq -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=loongson -p 15672:15672 -p 5672:5672 harbor.loongnix.cn/mirrorloongsoncontainers/rabbitmq:3.8.16-management-alpine
#给guest赋予远程访问权限
docker exec -it Myrabbitmq /bin/sh
#查看用户
rabbitmqctl list_users
#赋予远程访问权限
rabbitmqctl set_permissions -p “/” guest “." ".” “.*”
#进行简单验证
lsof -i:15672
6.基础服务:Memcached
#内存缓存
yum install -y memcached python3-memcached
sed -i ‘/OPTIONS/d’ /etc/sysconfig/memcached
echo ‘OPTIONS=“-l 127.0.0.1,::1,controller”’ >> /etc/sysconfig/memcached
systemctl enable memcached.service
systemctl start memcached.service
systemctl status memcached.service