openstack 管理二十六 - rpm 方式部署 openstack [mariadb]

目的

1.  配置 openstack 可用的 mariadb
2.  mariadb 用于存储 openstack 中的所有信息
3.  暂不以高可用为目的

软件源建议

新增 /etc/yum.repos.d/mariadb.repo ( gaiera + mariadb 专用 rpm repo)

[mariadb]
name=mariadb
baseurl=http://mirror.centos.org/centos/7.9.2009/cloud/x86_64/openstack-queens
enabled=1
gpgcheck=0

安装

yum install -y mariadb.x86_64 mariadb-server.x86_64 mariadb-server-galera galera mariadb-galera-common mariadb-server-galera

配置

必须要设定默认字符集为 utf8, 否则无法自动创建表

注 因测试环境, 暂无对 innodb 进行优化

/etc/my.cnf.d/mariadb-server.cnf

[mysql]
default_character_set=utf8

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

user    = mysql
port      = 3306
basedir   = /usr
tmpdir    = /tmp
skip-external-locking
innodb-log-file-size = 2048M
innodb_buffer_pool_size = 4G
innodb_file_per_table=1
bind-address    = 0.0.0.0

skip-name-resolve
key_buffer_size    = 384M
max_allowed_packet = 128M
thread_stack       = 192K
thread_cache_size  = 32
myisam-recover-options    = BACKUP
query_cache_limit  = 1M
query_cache_size   = 64M
max-connections    = 6000
open-files-limit = 6000
character_set_server = utf8
table_open_cache = 512
sort_buffer_size = 32M
read_buffer_size = 32M
read_rnd_buffer_size = 64M
myisam_sort_buffer_size = 64M
default-storage-engine = InnoDB
innodb_buffer_pool_size = 32768M
innodb_log_buffer_size = 256M
innodb_purge_threads = 1
[mysqldump]
quick
quote-names
max_allowed_packet = 16M


修改 /usr/lib/systemd/system/mariadb.service
解决 number of open files 问题

[Service]
Type=notify
User=mysql
Group=mysql
LimitNOFILE=infinity   <- 增加

额外工作

如果需要创建集群 (双主服务器)
则修改 /etc/my.cnf.d/galera.cnf

[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
skip-name-resolve
wsrep_on=1
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_provider_options="gcache.size=1G"
wsrep_cluster_name="my_yun_cluster"             <-- 集群名称   其他服务器都必须配置相同集群名称
wsrep_cluster_address="gcomm://"                  <-- 第一台启动的服务器这里必须设定为空,
                                               ###  第一台启动成功, 3306 端口启动后,再启动第二台, 第二台写入第一台服务器地址
                                               ### 第二台写法     wsrep_cluster_address="gcomm://10.1.1.1"     <- 第一台 IP 地址就可以
wsrep_slave_threads=1
wsrep_certify_nonPK=1
wsrep_max_ws_rows=131072
wsrep_max_ws_size=1073741824
wsrep_debug=0
wsrep_convert_LOCK_to_trx=0
wsrep_retry_autocommit=1
wsrep_auto_increment_control=1
wsrep_drupal_282555_workaround=0
wsrep_causal_reads=0
wsrep_notify_cmd=
wsrep_sst_method=rsync
wsrep_sst_auth=vip_user:vip_password_salt          <- 用户名/密码 (集群认证用)
验证文件是否存在

不存在则安装软件 galera-25.3.16-3.el7.x86_64

# ls -lh /usr/lib64/galera/libgalera_smm.so
-rwxr-xr-x 1 root root 2.4M Jul 11  2017 /usr/lib64/galera/libgalera_smm.so

启动

  systemctl  daemon-reload
  systemctl restart maraidb   (el7)

验证

mysql 命令能够直接登入 mysql>  终端则可

验证集群

第一台成功后,会看到启动的服务器地址
MariaDB [(none)]> show status like 'wsrep_incoming_addresses';
+--------------------------+-------------------+
| Variable_name            | Value             |
+--------------------------+-------------------+
| wsrep_incoming_addresses | 10.189.20.37:3306 |
+--------------------------+-------------------+

集群同步成功后,会看到集群中所有服务器地址

MariaDB [(none)]> show status like 'wsrep_incoming_addresses';
+--------------------------+-------------------------------------+
| Variable_name            | Value                               |
+--------------------------+-------------------------------------+
| wsrep_incoming_addresses | 10.189.20.37:3306,10.189.20.38:3306 |
+--------------------------+-------------------------------------+

salve 服务器详细启动日志,用于参考
2025-02-07  9:56:10 139979487631552 [Note] WSREP: CRC-32C: using hardware acceleration.
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Passing config to GCS: base_dir = /var/lib/mysql/; base_host = 10.189.20.38; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 2; evs.view_forget_timeout = PT24H; gcache.dir = /var/lib/mysql/; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /var/lib/mysql//galera.cache; gcache.page_size = 128M; gcache.size = 1G; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; p
2025-02-07  9:56:10 139979308107520 [Note] WSREP: Service thread queue flushed.
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Assign initial position for certification: -1, protocol version: -1
2025-02-07  9:56:10 139979487631552 [Note] WSREP: wsrep_sst_grab()
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Start replication
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Setting initial position to 00000000-0000-0000-0000-000000000000:-1
2025-02-07  9:56:10 139979487631552 [Note] WSREP: protonet asio version 0
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Using CRC-32C for message checksums.
2025-02-07  9:56:10 139979487631552 [Note] WSREP: backend: asio
2025-02-07  9:56:10 139979487631552 [Note] WSREP: gcomm thread scheduling priority set to other:0
2025-02-07  9:56:10 139979487631552 [Warning] WSREP: access file(/var/lib/mysql//gvwstate.dat) failed(No such file or directory)
2025-02-07  9:56:10 139979487631552 [Note] WSREP: restore pc from disk failed
2025-02-07  9:56:10 139979487631552 [Note] WSREP: GMCast version 0
2025-02-07  9:56:10 139979487631552 [Note] WSREP: (b3e64f42, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
2025-02-07  9:56:10 139979487631552 [Note] WSREP: (b3e64f42, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
2025-02-07  9:56:10 139979487631552 [Note] WSREP: EVS version 0
2025-02-07  9:56:10 139979487631552 [Note] WSREP: gcomm: connecting to group 'my_yun_cluster', peer '10.189.20.37:'
2025-02-07  9:56:10 139979487631552 [Note] WSREP: (b3e64f42, 'tcp://0.0.0.0:4567') turning message relay requesting on, nonlive peers:
2025-02-07  9:56:10 139979487631552 [Note] WSREP: declaring b096007b at tcp://10.189.20.37:4567 stable
2025-02-07  9:56:10 139979487631552 [Note] WSREP: Node b096007b state prim
2025-02-07  9:56:10 139979487631552 [Note] WSREP: view(view_id(PRIM,b096007b,2) memb {
        b096007b,0
        b3e64f42,0
} joined {
} left {
} partitioned {
})
2025-02-07  9:56:10 139979487631552 [Note] WSREP: save pc into disk
2025-02-07  9:56:11 139979487631552 [Note] WSREP: gcomm: connected
2025-02-07  9:56:11 139979487631552 [Note] WSREP: Changing maximum packet size to 64500, resulting msg size: 32636
2025-02-07  9:56:11 139979487631552 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
2025-02-07  9:56:11 139979487631552 [Note] WSREP: Opened channel 'my_yun_cluster'
2025-02-07  9:56:11 139978117981952 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 1, memb_num = 2
2025-02-07  9:56:11 139978117981952 [Note] WSREP: STATE EXCHANGE: Waiting for state UUID.
2025-02-07  9:56:11 139979487631552 [Note] WSREP: Waiting for SST to complete.
2025-02-07  9:56:11 139978117981952 [Note] WSREP: STATE EXCHANGE: sent state msg: b4332291-e4f6-11ef-9878-b7c47a7119e6
2025-02-07  9:56:11 139978117981952 [Note] WSREP: STATE EXCHANGE: got state msg: b4332291-e4f6-11ef-9878-b7c47a7119e6 from 0 (ns-yun-020037.vclound.com)
2025-02-07  9:56:11 139978117981952 [Note] WSREP: STATE EXCHANGE: got state msg: b4332291-e4f6-11ef-9878-b7c47a7119e6 from 1 (ns-yun-020038.vclound.com)
2025-02-07  9:56:11 139978117981952 [Note] WSREP: Quorum results:
        version    = 4,
        component  = PRIMARY,
        conf_id    = 1,
        members    = 1/2 (joined/total),
        act_id     = 0,
        last_appl. = -1,
        protocols  = 0/7/3 (gcs/repl/appl),
        group UUID = b0964307-e4f5-11ef-9530-d3857360fc8b
2025-02-07  9:56:11 139978117981952 [Note] WSREP: Flow-control interval: [23, 23]
2025-02-07  9:56:11 139978117981952 [Note] WSREP: Shifting OPEN -> PRIMARY (TO: 0)
2025-02-07  9:56:11 139979299714816 [Note] WSREP: State transfer required:
        Group state: b0964307-e4f5-11ef-9530-d3857360fc8b:0
        Local state: 00000000-0000-0000-0000-000000000000:-1
2025-02-07  9:56:11 139979299714816 [Note] WSREP: New cluster view: global state: b0964307-e4f5-11ef-9530-d3857360fc8b:0, view# 2: Primary, number of nodes: 2, my index: 1, protocol version 3
2025-02-07  9:56:11 139979299714816 [Warning] WSREP: Gap in state sequence. Need state transfer.
2025-02-07  9:56:11 139978109589248 [Note] WSREP: Running: 'wsrep_sst_rsync --role 'joiner' --address '10.189.20.38' --datadir '/var/lib/mysql/'   --parent '24359'  '' '
2025-02-07  9:56:11 139979299714816 [Note] WSREP: Prepared SST request: rsync|10.189.20.38:4444/rsync_sst
2025-02-07  9:56:11 139979299714816 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2025-02-07  9:56:11 139979299714816 [Note] WSREP: REPL Protocols: 7 (3, 2)
2025-02-07  9:56:11 139979308107520 [Note] WSREP: Service thread queue flushed.
2025-02-07  9:56:11 139979299714816 [Note] WSREP: Assign initial position for certification: 0, protocol version: 3
2025-02-07  9:56:11 139979308107520 [Note] WSREP: Service thread queue flushed.
2025-02-07  9:56:11 139979299714816 [Warning] WSREP: Failed to prepare for incremental state transfer: Local state UUID (00000000-0000-0000-0000-000000000000) does not match group state UUID (b0964307-e4f5-11ef-9530-d3857360fc8b): 1 (Operation not permitted)
         at galera/src/replicator_str.cpp:prepare_for_IST():482. IST will be unavailable.
2025-02-07  9:56:11 139978117981952 [Note] WSREP: Member 1.0 (ns-yun-020038.vclound.com) requested state transfer from '*any*'. Selected 0.0 (ns-yun-020037.vclound.com)(SYNCED) as donor.
2025-02-07  9:56:11 139978117981952 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 0)
2025-02-07  9:56:11 139979299714816 [Note] WSREP: Requesting state transfer: success, donor: 0
2025-02-07  9:56:13 139978126374656 [Note] WSREP: (b3e64f42, 'tcp://0.0.0.0:4567') turning message relay requesting off
2025-02-07  9:56:49 139978117981952 [Note] WSREP: 0.0 (ns-yun-020037.vclound.com): State transfer to 1.0 (ns-yun-020038.vclound.com) complete.
2025-02-07  9:56:49 139978117981952 [Note] WSREP: Member 0.0 (ns-yun-020037.vclound.com) synced with group.
WSREP_SST: [INFO] Joiner cleanup. rsync PID: 24428 (20250207 09:56:49.691)
WSREP_SST: [INFO] Joiner cleanup done. (20250207 09:56:50.196)
2025-02-07  9:56:50 139979487631552 [Note] WSREP: SST complete, seqno: 0
2025-02-07  9:56:50 139979487631552 [Note] CONNECT: Version 1.04.0008 August 10, 2016
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: The InnoDB memory heap is disabled
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Compressed tables use zlib 1.2.7
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Using Linux native AIO
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Using SSE crc32 instructions
2025-02-07  9:56:50 139979487631552 [Note] InnoDB: Initializing buffer pool, size = 32.0G
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Completed initialization of buffer pool
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Highest supported file format is Barracuda.
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: The log sequence numbers 1622838 and 1622838 in ibdata files do not match the log sequence number 1623012 in the ib_logfiles!
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Database was not shutdown normally!
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Starting crash recovery.
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Reading tablespace information from the .ibd files...
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: Restoring possible half-written data pages
2025-02-07  9:56:51 139979487631552 [Note] InnoDB: from the doublewrite buffer...
2025-02-07  9:56:52 139979487631552 [Note] InnoDB: 128 rollback segment(s) are active.
2025-02-07  9:56:52 139979487631552 [Note] InnoDB: Waiting for purge to start
2025-02-07  9:56:52 139979487631552 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.34-79.1 started; log sequence number 1623012
2025-02-07  9:56:52 139939881146112 [Note] InnoDB: Dumping buffer pool(s) not yet started
2025-02-07  9:56:52 139979487631552 [Note] Plugin 'FEEDBACK' is disabled.
2025-02-07  9:56:52 139979487631552 [Note] Server socket created on IP: '0.0.0.0'.
2025-02-07  9:56:52 139979487631552 [Warning] 'user' entry 'root@ns-yun-020037.vclound.com' ignored in --skip-name-resolve mode.
2025-02-07  9:56:52 139979487631552 [Warning] 'user' entry '@ns-yun-020037.vclound.com' ignored in --skip-name-resolve mode.
2025-02-07  9:56:52 139979487631552 [Warning] 'proxies_priv' entry '@% root@ns-yun-020037.vclound.com' ignored in --skip-name-resolve mode.
2025-02-07  9:56:52 139979487631552 [Note] WSREP: Signalling provider to continue.
2025-02-07  9:56:52 139979487631552 [Note] WSREP: SST received: b0964307-e4f5-11ef-9530-d3857360fc8b:0
2025-02-07  9:56:52 139978117981952 [Note] WSREP: 1.0 (ns-yun-020038.vclound.com): State transfer from 0.0 (ns-yun-020037.vclound.com) complete.
2025-02-07  9:56:52 139978117981952 [Note] WSREP: Shifting JOINER -> JOINED (TO: 0)
2025-02-07  9:56:52 139978117981952 [Note] WSREP: Member 1.0 (ns-yun-020038.vclound.com) synced with group.
2025-02-07  9:56:52 139978117981952 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 0)
2025-02-07  9:56:52 139979299714816 [Note] WSREP: Synchronized with group, ready for connections
2025-02-07  9:56:52 139979299714816 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2025-02-07  9:56:52 139979487631552 [Note] /usr/libexec/mysqld: ready for connections.
Version: '10.1.20-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server

创建用户

创建 keystone 用户

create database keystone character set utf8;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' identified by 'test123';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' identified by 'test123';
flush privileges;

创建 glance 用户

create database glance character set utf8;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' identified by 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' identified by 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'127.0.0.1' identified by 'glance';
flush privileges;

创建 cinder 用户

grant all on cinder.* to 'cinder'@'localhost' identified by 'cinder';
grant all on cinder.* to 'cinder'@'240.10.130.25' identified by 'cinder';
flush privileges;
create databae cinder character set utf8;

创建 neutron 用户

create database neutron_ml2 character set utf8;
GRANT ALL PRIVILEGES ON neutron_ml2.* TO 'neutron'@'%' identified by 'openstack';
GRANT ALL PRIVILEGES ON neutron_ml2.* TO 'neutron'@'localhost' identified by 'openstack';
GRANT ALL PRIVILEGES ON neutron_ml2.* TO 'neutron'@'127.0.0.1' identified by 'openstack';
flush privileges;

创建 nova 用户

CREATE DATABASE nova character set utf8;
GRANT ALL ON nova.* TO 'nova'@'%' IDENTIFIED BY 'openstack';
GRANT ALL ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'openstack';
FLUSH PRIVILEGES;
### 如何在麒麟操作系统上安装和部署OpenStack #### 环境准备 为了成功地在麒麟操作系统V10 SP2版本上安装并部署OpenStack,需先确保硬件环境满足需求。目标服务器应为中科曙光国产芯片服务器X745-H30,配备有Hygon C86 7285 32-core处理器以及四块Hygon DCU Z100 GPU设备[^1]。 #### 基础设置调整 针对不同架构下的默认UEFI加载器路径进行了适配处理,默认情况下对于`aarch64`架构(即ARM),应当指向位于`/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw`的文件作为启动所需的固件镜像[^2]。 #### 主机配置优化 - **主机命名与网络接口设定**:依据实际应用场景合理分配各节点名称及其对应的IP地址。 - **编辑hosts映射表**:向/etc/hosts追加所有参与集群构建机器的信息条目。 - **安全策略放宽**:临时禁用SELinux机制,并停止firewalld服务来减少不必要的干扰因素;同时允许root账户通过SSH无密码登录其他成员之间相互访问。 - **预装必要的工具集**:利用yum源批量获取后续操作可能涉及的基础库函数和支持组件。 - **定时任务安排**:借助cron表达式实现自动化的时间校准流程,保持整个分布式系统的时钟一致性。 #### 数据库搭建 选用MariaDB数据库管理系统承担起存储各类元数据的任务,在此之前要完成如下几步: - 执行官方文档指导下的YUM仓库注册过程; - 启动守护进程并将其加入到开机自启列表里; - 创建专用的服务账号用于身份验证连接请求; - 构建初始模式结构体以便于容纳即将产生的记录项。 #### 消息队列组建 引入RabbitMQ中间件负责消息传递工作流的设计思路如下所示: - 安置Erlang运行时环境以支撑AMQP协议栈正常运转; - 解压tarball压缩包形式发布的二进制可执行程序至指定位置; - 修改配置参数适应多租户场景下并发量增大的情况; - 开放对外监听端口使得远程客户端能够顺利接入通信链路。 #### 缓存加速层集成 最后一步则是增设Memcached实例充当读取热点对象缓存的角色,具体措施包括但不限于: - 下载rpm格式安装包并通过命令行快速部署完毕; - 调整最大内存占用限额防止资源过度消耗引发性能瓶颈; - 设置合理的过期淘汰算法提高命中率从而降低延迟开销。 ```bash # 更新系统软件包索引 sudo yum update -y # 添加MariaDB Yum Repository cat <<EOF | sudo tee /etc/yum.repos.d/MariaDB.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.5/centos7-amd64 gpgkey=https://downloads.mariadb.com/MariaDB/MariaDB-Server-GPG-KEY gpgcheck=1 EOF # 安装MariaDB Server Package sudo yum install mariadb-server -y # 初始化数据库并启用自动启动功能 sudo systemctl start mariadb.service && sudo systemctl enable mariadb.service # RabbitMQ Installation Script wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.9.7/rabbitmq-server-generic-unix-3.9.7.tar.xz tar xf rabbitmq-server-generic-unix-3.9.7.tar.xz -C /opt/ ln -sf /opt/rabbitmq_server-3.9.7/sbin/* /usr/local/bin/ # Memcached Setup Commands sudo yum install memcached libmemcached -y echo 'MAXCONN 2048' | sudo tee -a /etc/sysconfig/memcached echo '-m 64' | sudo tee -a /etc/sysconfig/memcached ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值