十三周

一身转战三千里,一剑曾当百万师。这篇文章主要讲述十三周相关的知识,希望能为你提供帮助。
1、ansible-playbook实现mysql的二进制部署

安装ansible wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo yum install -y epel-release yum -y install ansible 安装mysql 下载软件包 https://downloads.mysql.com/archives/community/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz 修改 hostnamectl set-hostname dbsrvsmkdir -p mysql_install/{files,handlers,meta,tasks,templates,vars} mv /mnt/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz /etc/ansible/roles/mysql_install/files/cd/etc/ansible/roles/mysql_install/files [root@dbsrvs files]# cat secure_mysql.sh #!/bin/bash /usr/local/mysql/bin/mysql_secure_installation < < EOF y fyq939 fyq939 y y y y EOF [root@dbsrvs files]# tree/etc/ansible/roles/mysql_install/files/ /etc/ansible/roles/mysql_install/files/ ├── install_mysql.yml ├── my.cnf ├── mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz └── secure_mysql.sh[root@dbsrvs files]# cat install_mysql.yml ---- hosts: dbsrvs remote_user: root gather_facts: notasks: - name: install packages yum: name=libaio, perl-Data-Dumper, perl-Getopt-Long - name: create mysql group group: name=mysql gid 333 - name: create mysql user user: name=mysql uid 333 group=mysql shell=/sbin/nologin system=yes create_home=no home=/data/mysql - name: copy tar to remote host and file mode unarchive: src=https://www.songbingjia.com/etc/ansible/roles/mysql_install/files/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz dest=/usr/local/ owner=root group=root - name: create linkfile /usr/local/mysql file: src=/usr/local/mysql-5.6.46-linux-glibc2.12-x86_64 dest=/usr/local/mysql state=link - name: data dir shell: chdir=/usr/local/mysql/ ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql tags: data - name: config my.cnf copy: src=/etc/ansible/roles/mysql_install/files/my.cnf dest=/etc/my.cnf - name: service script shell: /bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld - name: enable service shell: /etc/init.d/mysqld start; chkconfig --add mysqld; chkconfig mysqld on tags: service - name: PATH variable copy: content=PATH=/usr/local/mysql/bin:$PATH dest=/etc/profile.d/mysql.sh - name: secure script script: /etc/ansible/roles/mysql_install/files/secure_mysql.sh tags: script#### 2、Ansible playbook实现apache批量部署,并对不同主机提供以各自IP地址为内容的index.html

vim install-httpd.yml
  • hosts: websrvs
    remote_user:root
    gather_facts: no
    【十三周】tasks:
    • name: Install httpd
      yum: name=httpd state=present
    • name: Install configure file
      copy: src=https://www.songbingjia.com/android/files/httpd.conf dest=/etc/httpd/conf/
    • name: modify config
      lineinfile: path=/etc/httpd/conf/httpd.conf regexp=^Listen line=Listen 8080
    • name: mkdir website dir
      file: path=/data/html state=directory
    • name: web html
      copy: src=https://www.songbingjia.com/android/files/index.html dest=/data/html/
    • name: start service
#### 3、http的报文结构和状态码总结请求报文格式:< method> < request-URL> < version> < headers> < entity-body> 响应报文的格式:< version> < status> < reason-phrase> < headers> < entiy-body> 首部(headers): 可以有零个或者多个首部,每个首部都包含一个名字,后面跟着一个冒号(:),然后是一个可选的空格,接着是一个值,最后是一个回车换行。首部是由一个回车换行结束的,表示了首部列表的结束和实体主体不部分的开始。有些HTTP版本中,比如 HTTP/1.1,要求有效的请求和响应报文中必须包含特定的首部。实体的主体部分(entity-body): 实体的主体部分包含一个由任意数据组成的数据块,并不是所有的报文都包含实体的主体部分。![image.png](https://s2.51cto.com/images/20211205/1638677897499984.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)


    推荐阅读