【题目 1】Ansible服务部署:部署 MariaDB 集群
使用OpenStack私有云平台,创建 4台系统为centos7.9的云主机,其中一台作为 Ansible的母机并命名为 ansible,另外三台云主机命名为 node1、node2、node3;使用这一台母机,编写 Ansible脚本(在/root目录下创建 example目录作为 Ansible工作目录,部署的入口文件命名为 cscc_install.yaml ) , 对其他三台云主机进行安装高可用数据库集群(MariaDB_Galera_cluster,数据库密码设置为 123456)的操作。文章来源:https://www.toymoban.com/news/detail-555775.html
关闭4台主机防火墙和安全子系统
[root@ansible ~]# systemctl stop firewalld
[root@ansible ~]# setenforce 0
配置主机映射
[root@ansible ~]# echo 192.168.100.10 ansible >> /etc/hosts
[root@ansible ~]# echo 192.168.100.20 node-1 >> /etc/hosts
[root@ansible ~]# echo 192.168.100.30 node-3 >> /etc/hosts
[root@ansible ~]# echo 192.168.100.40 node-3 >> /etc/hosts
配置免密钥
[root@ansible ~]# ssh-copy-id node-1
[root@ansible ~]# ssh-copy-id node-2
[root@ansible ~]# ssh-copy-id node-3
配置yum源
[root@ansible ~]# tar -zxf mariadb-repo.tar.gz -C /opt/
[root@ansible ~]# tar -zxf ansible.tar.gz -C /opt/
[root@ansible ~]# mount /dev/cdrom /mnt/
[root@ansible ~]# cp -rfv /mnt/* /opt/
[root@ansible ~]# cat >> /etc/yum.repos.d/local.repo << EOF
> [centos]
> name=centos
> baseurl=file:///opt/
> gpgcheck=0
> enabled=1
> [ansible]
> name=ansible
> baseurl=file:///opt/ansible/
> gpgcheck=0
> enabled=1
> [mariadb]
> name=mariadb
> baseurl=file:///opt/mariadb-repo
> gpgcheck=0
> enabled=1
> EOF
[root@ansible ~]# yum -y install mariadb mariadb-server mariadb-common vsftpd ansible
[root@ansible example]# cat >> /etc/ansible/hosts << EOF
> [node]
> node-1
> node-2
> node-3
> EOF
[root@ansible ~]# echo anon_root=/opt/ >> /etc/vsftpd/vsftpd.conf
[root@ansible ~]# systemctl restart vsftpd
[root@ansible ~]# mkdir example
[root@ansible ~]# cd example/
[root@ansible example]# cp -rf /etc/yum.repos.d/local.repo .
[root@ansible example]# cat local.repo
[centos]
name=centos
baseurl=ftp://192.168.100.10/
gpgcheck=0
enabled=1
[ansible]
name=ansible
baseurl=ftp://192.168.100.10/ansible/
gpgcheck=0
enabled=1
[mariadb]
name=mariadb
baseurl=ftp://192.168.100.10/mariadb-repo
gpgcheck=0
enabled=1
[root@ansible example]# vim cscc_install.yaml
[root@ansible example]# ansible-playbook -C cscc_install.yaml
[root@ansible example]# ansible-playbook cscc_install.yaml
PLAY RECAP ************************************************************************************************************************************************************************
node-1 : ok=10 changed=7 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node-2 : ok=8 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node-3 : ok=8 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[root@localhost ~]# netstat -ntlp | grep 4567
tcp 0 0 0.0.0.0:4567 0.0.0.0:* LISTEN 8750/mysqld
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.3.23-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show status like 'wsrep_ready';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wsrep_ready | ON |
+---------------+-------+
1 row in set (0.001 sec)
MariaDB [(none)]> show status like 'wsrep_cluster_size';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in set (0.001 sec)
MariaDB [(none)]> exit
[root@localhost ~]#
【题目 2】Ansible服务部署:部署ELK集群服务
使用赛项提供的OpenStack 私有云平台,创建三台 CentOS7.9 系统的云主机分别命名为elk-1、elk-2和elk-3,Ansible主机可以使用上一题的环境。要求Ansible节点编写剧本,执行 Ansible剧本可以在这三个节点部署 ELK集群服务(在/root目录下创建 install_elk 目录作为 ansible工作目录,部署的入口文件命名为 install_elk.yaml)。具体要求为三个节点均安装Elasticserach服务并配置为 Elasticserach集群;kibana安装在第一个节点;Logstash安装在第二个节点。文章来源地址https://www.toymoban.com/news/detail-555775.html
关闭4台主机防火墙和安全子系统
[root@ansible ~]# systemctl stop firewalld
[root@ansible ~]# setenforce 0
配置主机映射
[root@ansible ~]# echo 192.168.100.10 ansible >> /etc/hosts
[root@ansible ~]# echo 192.168.100.20 elk-1 >> /etc/hosts
[root@ansible ~]# echo 192.168.100.30 elk-3 >> /etc/hosts
[root@ansible ~]# echo 192.168.100.40 elk-3 >> /etc/hosts
[root@ansible example]# cat >> /etc/ansible/hosts << EOF
> [elk]
> elk-1
> elk-2
> elk-3
> EOF
配置免密钥
[root@ansible ~]# ssh-copy-id elk-1
[root@ansible ~]# ssh-copy-id elk-2
[root@ansible ~]# ssh-copy-id elk-3
[root@ansible ~]# tar -zxf Ansible.tar.gz
[root@ansible ~]# ls
ansible.tar.gz Ansible.tar.gz elasticsearch-6.0.0.rpm kibana-6.0.0-x86_64.rpm logstash-6.0.0.rpm
[root@ansible ~]# yum -y install /root/*
[root@ansible ~]# mkdir install_elk
[root@ansible ~]# cd install_elk/
[root@ansible install_elk]# vim /etc/elasticsearch/elasticsearch.yml
[root@ansible install_elk]# cp -rfv /etc/elasticsearch/elasticsearch.yml .
[root@ansible install_elk]# vim /etc/kibana/kibana.yml
[root@ansible install_elk]# cp -rfv /etc/kibana/kibana.yml .
[root@ansible install_elk]# cp -rfv /etc/hosts .
[root@ansible ~]# cp -rfv *.rpm /opt/ansible/packages/
[root@ansible install_elk]# vim local.repo
[centos]
name=centos
baseurl=ftp://192.168.100.10/ansible/
gpgcheck=0
enabled=1
[centos]
name=centos
baseurl=ftp://192.168.100.10/
gpgcheck=0
enabled=1
[root@ansible install_elk]# systemctl restart vsftpd
[root@ansible install_elk]# vim install_elk.yaml
[root@ansible install_elk]# ansible-playbook install_elk.yaml
PLAY RECAP ************************************************************************************************************************************************************************
node-1 : ok=11 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node-2 : ok=11 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node-3 : ok=11 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[root@localhost yum.repos.d]# netstat -ntlp
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:5601 0.0.0.0:* LISTEN 108212/node
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1077/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1311/master
tcp6 0 0 127.0.0.1:9200 :::* LISTEN 84384/java
tcp6 0 0 ::1:9200 :::* LISTEN 84384/java
tcp6 0 0 127.0.0.1:9300 :::* LISTEN 84384/java
tcp6 0 0 ::1:9300 :::* LISTEN 84384/java
tcp6 0 0 :::22 :::* LISTEN 1077/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1311/master
到了这里,关于云计算赛项-私有云Ansible服务部署的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!