1、准备机器
worker-smarthome 主 172.31.76.147
worker-oss 从 172.31.80.14
2、rpm安装msql yum源
这里安装MySQL5.7版本,MySQL5.7版本
$ wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
$ sudo rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
$ yum repolist all | grep mysql
3、安装数据库
$ yum install -y mysql-community-server
4、启动mysql,并查看mysql状态
$ systemctl enable mysqld
$ systemctl start mysqld
$ systemctl status mysqld
5、查看mysql临时密码
$ grep "password" /var/log/mysqld.log
2018-07-19T09:26:49.073788Z 1 [Note] A temporary password is generated for root@localhost: &&s%n)XXXX
6、修改密码并允许远程登录
$ mysql -uroot -p
输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库:
mysql> set global validate_password_policy=0;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
允许远程连接:
mysql> CREATE USER 'slave'@'localhost' IDENTIFIED BY '123456';
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new password' WITH GRANT OPTION;
mysql>flush privileges;
6、永久关闭selinux
$ vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled,保存后退出
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
7、重启
此时获取当前selinux防火墙的安全策略仍为Enforcing,配置文件并未生效。
$ getenforce
Enforcing
重启机器
$ reboot
验证
$ /usr/sbin/sestatus
SELinux status: disabled
$ getenforce
Disabled
8、创建软链接:
$ mv /var/lib/