Linux下Mysql5.6 二进制安装过程
程序员文章站
2023-10-23 08:27:36
1.1下载二进制安装包
wget https://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.40-linux-gli...
1.1下载二进制安装包
wget https://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz
1.2创建 mysql用户与组
groupadd -r -g 306 mysql useradd -r -g 306 -u 306 -m -s /sbin/nologin mysql
1.3解压
tar xf mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -c /usr/local
1.4创建mysql软连接
cd /usr/local ln -s mysql-5.6.40-linux-glibc2.12-x86_64 mysql
1.5修改所属主,所属组权限
chown -r mysql.mysql /usr/local/mysql-5.6.40-linux-glibc2.12-x86_64 chown mysql.mysql /usr/local/mysql
1.6创建目录,修改mysql目录的所属主
mkdir -p /data/mysql{,_binlog} chown -r mysql.mysql /data/mysql chown -r mysql.mysql /data/mysql_binlog
1.7创建配置文件目录
mkdir /etc/mysql/ cp /usr/local/mysql/support-files/my-default.cnf /etc/mysql/my.cnf
1.8配置文件 vim /etc/mysql/my.cnf
[client] port = 3306 socket = /data/mysql/mysql.sock [mysqld] port = 3306 user = mysql basedir = /usr/local/mysql datadir = /data/mysql socket = /data/mysql/mysql.sock pid-file = /data/mysql/mysql.pid log-error = /data/mysql/mysql_error.log character-set-server = utf8 init_connect='set names utf8' innodb_log_file_size = 256m innodb_file_format = barracuda innodb_strict_mode = 0 innodb_file_per_table = on #跳过主机名解析 skip-name-resolve #服务器id,集群必填配置,区分机器编号,每台机器不同 server_id = 1 #开启二进制日志,行级记录,同步写入磁盘 log_bin = /data/mysql_binlog/mysql-bin binlog_format = row sync_binlog = 1 sql_mode='strict_trans_tables,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution' symbolic-links=0
1.9修改path环境变量
]# vim /etc/profile.d/mysql.sh path=/usr/local/mysql/bin:$path ]# source /etc/profile.d/mysql.sh
2.0创建数据库文件
cd /usr/local/mysql/ ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
2.1准备启动脚本
cd /usr/local/mysql/ ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
2.2安全初始化
ln -s /data/mysql/mysql.sock /tmp/mysql.sock mysql_secure_installation root没有密码 --> 直接回车 --> 是否设置密码 y 输入密码 --> 是否删除匿名用户 y --> 是否禁止root远程连接 n --> 是否删除test测试数据库 y --> 是否重新载入数据库 y ---> ok
2.3主从复制架构
2.3.1配置文件
master 主数据库
log_bin=/bin_log_path/mysql-bin 开启二进制日志 binlog_format = row 二进制日志记录方式,行级记录 server_id = 1
2.3.2创建主从复制专用权限用户
mysql> grant replication salve on *.* to 'repluer'@'172.16.1.%' identified by '123456'
2.3.3刷新二进制日志
mysql> reset master; mysql> show master status;
2.3.3 slave 从数据库配置文件
server_id=2
2.4建立主从关联
mysql> change master to master_host='172.16.1.211', master_user='repluser',master_password='123456', master_log_file='mysql-bin.000001',master_log_pos=120;
2.4.1查看与启用从节点
mysql> start slave; mysql> show slave status\g
说明:主从复制架构,是多从同步一台主的数据,可能造成主节点压力大,可以使用主从级联复制,主节点负责一台从节点,从节点再负责下一台从节点
主要用到配置
从节点 配置 log_bin 二进制日志记录配置
log_slave_updates 将同步过来的数据,写入二进制日志,方便下一台从节点同步
总结
以上所述是小编给大家介绍的linux下mysql5.6 二进制安装过程,希望对大家有所帮助