openstack-M版,学习笔记二

笔记为根据老男孩视频+官方文档学习,并记录,如有错漏,心情好的可以指出一下。
视频地址

安装基础服务

基础服务,需要一开始就完成安装配置,因为后续安装的任何一个服务,都会使用到这些服务

时间同步服务

(所有节点安装)

chronyd这个服务,虚拟机安装的时候,默认就安装成功了。所以就不需要重复安装了。

[root@controller01 ~]# rpm -qa chrony    #检查包是否安装
chrony-3.4-1.el7.x86_64
[root@computer01 ~]# systemctl status chronyd    #检查服务器是否启动
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-09-24 11:07:24 CST; 5min ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 1406 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 1403 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 1405 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─1405 /usr/sbin/chronyd
Sep 24 11:07:24 computer01 systemd[1]: Starting NTP client/server...
Sep 24 11:07:24 computer01 chronyd[1405]: chronyd version 3.4 starting (+CMDMON +NTP +...G)
Sep 24 11:07:24 computer01 chronyd[1405]: Frequency -18.024 +/- 1.399 ppm read from /v...ft
Sep 24 11:07:24 computer01 systemd[1]: Started NTP client/server.
Sep 24 11:07:34 computer01 chronyd[1405]: Selected source 192.168.137.11
Sep 24 11:08:29 computer01 chronyd[1405]: System clock was stepped by 0.000004 seconds
Sep 24 11:10:22 computer01 chronyd[1405]: System clock was stepped by 0.001961 seconds
Hint: Some lines were ellipsized, use -l to show in full.

[root@controller01 ~]# systemctl is-enabled chronyd    #检查服务是否配置了开机启动
enabled

因为同步的方法是,控制节点同步外部时间源,计算节点通过同步控制节点的时间;因为假设计算节点有1000台服务器,都全部去同步外部时间,可能会存在因为网络传输的问题,导致时间的延迟;

chronyd默认同步时间的服务监听的端口是323
服务端端口是123

控制节点

(配置修改完记得重启chrony服务)systemctl restart chronyd

vim /etc/chrony.conf
改标记的两个配置即可

  1 # Use public servers from the pool.ntp.org project.
  2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).#时间源
  3 server ntp6.aliyun.com iburst
  4
  5 # Record the rate at which the system clock gains/losses time.
  6 driftfile /var/lib/chrony/drift
  7
  8 # Allow the system clock to be stepped in the first three updates
  9 # if its offset is larger than 1 second.
10 makestep 1.0 3
11
12 # Enable kernel synchronization of the real-time clock (RTC).
13 rtcsync
14
15 # Enable hardware timestamping on all interfaces that support it.
16 #hwtimestamp *
17
18 # Increase the minimum number of selectable sources required to adjust
19 # the system clock.
20 #minsources 2
21
22 # Allow NTP client access from local network.#允许同步的本地网络
23 allow 192.168.137.0/24
24
25 # Serve time even if not synchronized to a time source.
26 #local stratum 10
27
28 # Specify file containing keys for NTP authentication.
29 #keyfile /etc/chrony.keys
30
31 # Specify directory for log files.
32 logdir /var/log/chrony
33
34 # Select which information is logged.
35 #log measurements statistics tracking

计算节点

修改第三行的时间源为控制节点的ip即可(配置修改完记得重启chrony服务)systemctl restart chronyd

  1 # Use public servers from the pool.ntp.org project.
  2 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  3 server 192.168.137.11 iburst

PS:chrony配置相关的参考链接https://chegva.com/3265.html
因为我创建虚拟机的时候,采用的为默认配置,所以失去可能有一些问题。强行同步时间以后,时间还是不正确的

[root@controller01 ~]# chronyc -a makestep
200 OK
[root@controller01 ~]# date
Thu Sep 23 23:08:33 EDT 2021
  • 更改时区
    查看当前时区(因为我这里时区已经调整过了。所以现在看到time zone就显示为asia/shanghai)
[root@controller01 ~]# timedatectl
      Local time: Fri 2021-09-24 11:15:44 CST
  Universal time: Fri 2021-09-24 03:15:44 UTC
        RTC time: Fri 2021-09-24 03:15:44
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
      DST active: n/a
  • 查看可用的时区
[root@controller01 ~]# timedatectl list-timezones |  grep  -E "Asia/S.*" #筛选式查看在亚洲S开的上海可用时区
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
  • 设置当前系统为Asia/Shanghai上海时区:
[root@controller01 ~]# timedatectl set-timezone Asia/Shanghai    #设置时区为上海
[root@controller01 ~]# chronyc -a makestep    #强制同步时区
chronyc -a makestep
200 OK
  • 最后的设置
[root@controller01 ~]# timedatectl set-local-rtc 1    #设置硬件时间,硬件时间默认为UTC
[root@controller01 ~]# timedatectl set-ntp yes    #启用NTP时间同步
timedatectl set-ntp yes
[root@controller01 ~]# chronyc tracking    #校准时间服务器
chronyc tracking
Reference ID    : CB6B0658 (203.107.6.88)
Stratum         : 3
Ref time (UTC)  : Fri Sep 24 03:21:32 2021
System time     : 0.000239469 seconds slow of NTP time
Last offset     : -0.000245555 seconds
RMS offset      : 0.002138308 seconds
Frequency       : 13.478 ppm slow
Residual freq   : -0.072 ppm
Skew            : 10.151 ppm
Root delay      : 0.069443129 seconds
Root dispersion : 0.003981409 seconds
Update interval : 64.6 seconds
Leap status     : Normal

安装openstack客户端和openstack-selinux(所有节点)

yum install python-openstackclient openstack-selinux -y

安装配置mariadb(控制节点)

安装服务

yum install mariadb mariadb-server pythont2-PyMySQL

ps:pythont2-PyMySQL用于python语言和数据库进行连接的模块工具

调整mysql的配置

echo '[mysqld]
bind-address = 192.168.137.11
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server =utf8_general_ci
character-set-server = utf8' >/etc/my.cnf.d/openstack.cnf

bind-address = 192.168.137.11    #监听的IP地址
default-storage-engine = innodb    # 默认的引擎为innodb
innodb_file_per_table    #让每一种innodb独立表空间文件,默认为共享
max_connections = 4096    #最大连接数
collation-server =utf8_general_ci  #用默认的字符集为utf8
character-set-server = utf8

启动mariadb并配置开机启动

[root@controller01 yum.repos.d]# systemctl start mariadb
[root@controller01 yum.repos.d]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@controller01 yum.repos.d]# systemctl is-enabled mariadb
enabled

执行mysql的安全初始化(默认的mariadb密码为空,还有匿名用户存在等等)ps:如果不执行,后续同步数据库的时候可能会有坑
mysql_secure_installation

[root@controller01 yum.repos.d]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):    #输出你的root密码,新安装的mariadb默认的root密码为空,直接回车即可
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y    #是否设置你的root密码,我设置的密码为hl044sdvwTT1LZ7Oa4wp
New password:
Re-enter new password:    #重复输入
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y    #是否移出匿名用户
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y    #是否禁止root远程登录
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y    #是否移出test数据库和访问他的权限
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y    #是否重载权限表
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

PS:

  1. 因为是SOA的架构,这个传统的架构里面就多了一些东西,独立的web服务和web服务器之间调用的时候需要传送消息,这里面就用到消息队列;openstack支持多种消息队列出了RabbitMQ,Qpid和 ZeroMQ。
  2. 官方文档中安装不中,还需要安装NoSQL数据库,里面用到的工具为MongoDB,这个工具一般是用于监控计费(目前我们部署的这个是当私有云进行部署,所以不需要安装NoSQL)

安装消息队列(控制节点)

安装服务

yum install rabbitmq-server -y

启动并配置开机自启

[root@controller01 yum.repos.d]# systemctl start rabbitmq-server
[root@controller01 yum.repos.d]# systemctl enable rabbitmq-server
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@controller01 yum.repos.d]# systemctl is-enabled rabbitmq-server
enabled

在rabbitmq中添加openstack用户并配置密码

[root@controller01 yum.repos.d]# rabbitmqctl add_user openstack R4odtEJzSDNTe9LoHYfF
Creating user "openstack" ...

在rabbitmq中添加openstack的权限

命令中的"." "." ".*",分别表示,第一个可读,第二个可写,第三可配置

[root@controller01 yum.repos.d]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...

ps:rabbitmq服务启动以后就会监听两个端口,5672是给rabbitmq客户端使用的;25672是给rabbitmq集群之间通信用的

启用rabbitmq插件

[root@controller01 yum.repos.d]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management
Applying plugin configuration to rabbit@controller01... started 6 plugins.
[root@controller01 yum.repos.d]# !net
netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      3212/beam.smp       
tcp        0      0 192.168.137.11:3306     0.0.0.0:*               LISTEN      2991/mysqld         
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      941/sshd            
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      3212/beam.smp       
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1118/master         
tcp6       0      0 :::5672                 :::*                    LISTEN      3212/beam.smp       
tcp6       0      0 :::22                   :::*                    LISTEN      941/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1118/master         
udp        0      0 0.0.0.0:123             0.0.0.0:*                           1354/chronyd        
udp        0      0 127.0.0.1:323           0.0.0.0:*                           1354/chronyd        
udp6       0      0 ::1:323                 :::*                                1354/chronyd

启用插件以后,rabbitmq会多监听一个端口,15672;
rabbitmq的账户和密码是guest
rabbitmq的监控指标就是看它的队列。是否异常增加,是否超出数据库可以接收最大量

安装memcache

使用memcached缓存token

安装服务

yum install memcached python-memcached -y

ps:因为openstack是用python开发的,每个服务都需要安装对用的python模块才能正确和openstack进行交互

修改配置

安装完毕后,需要修改配置文件里面服务的监听地址,如果不修改,那么其他主机将无法访问这个memcached服务

[root@controller01 ~]# sed -i 's#127.0.0.1#192.168.137.11#g' /etc/sysconfig/memcached
[root@controller01 ~]# cat !$
cat /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 192.168.137.11,::1"

ps:在openstack,M版的官方文档中,是没有这一项说明的。但在后需要就增加了这一项说明。(这是官方文档中的一个BUG)

启动并配置开机自启

systemctl start memcached
systemctl enable memcached
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值