用ansible 安装二进制mysql5.6
安全加固那一步老是没过,报的错:
fatal: [10.0.0.18]: FAILED! => {"changed": true, "msg": "non-zero return code", "rc": 29, "stderr":
"Shared connection to 10.0.0.18 closed.\r\n", "stderr_lines": ["Shared connection to 10.0.0.18
closed."], "stdout": "Can't find a 'mysql' client in PATH or ./bin\r\nCleaning up...\r\nWarning: Could
not unlink .my.cnf.15495: No such file or directory\r\nWarning: Could not unlink .mysql.15495: No such
file or directory\r\n", "stdout_lines": ["Can't find a 'mysql' client in PATH or ./bin", "Cleaning
up...", "Warning: Could not unlink .my.cnf.15495: No such file or directory", "Warning: Could not
unlink .mysql.15495: No such file or directory"]}
然后就去18 上查了一下:
1.端口和PATH变量都有了(PATH 要exit 一下 再 进去就好了)
2.但是安全加固脚本单独执行也报错
3.在18上执行mysql 命令的时候报错是这个
[root@centos8 ~]# mysql
mysql: error while loading shared libraries: libncurses.so.5:
cannot open shared object file: No such file or directory
百度了一下:按照百度的方法都不成功,应该和系统版本有关
后来想到一个方法:yum install libncurses*,完美解决问题。
然后在 自动化安装脚本yum模块上加上
- name: install package
yum: name=libaio,perl,autoconf,ncurses,libncurses*
再次执行自动化安装脚本就成功实现在centos7 和centos8上安装 二进制 mysql5.6 了
- hosts: websrvs
remote_user: root
gather_facts: no
tasks:
- name: install package
yum: name=libaio,perl,autoconf,ncurses,libncurses*
- name: create mysql group
group: name=mysql gid=306
- name: create mysql user
user: name=mysql uid=306 group=mysql shell=/sbin/nologin system=yes create_home=no home=/data/mysql
- name: copy tar to remote host and file mode
unarchive: src=/data/ansible/files/mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz dest=/usr/local/ owner=root group=root
tags: tar1
- name: create linkfile /usr/local/mysql
file: src=/usr/local/mysql-5.6.51-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=/data/ansible/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: /data/ansible/files/secure_mysql.sh
tags: script