这篇文章给大家分享的是有关RHEL 7.2如何安装二进制MySQL 5.7.18的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
环境:
Red Hat Enterprise Linux Server release 7.2 (Maipo)
mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
安装需求:
libaio
MySQL 5.7.19 and later 需要安装libnuma,由于本次测试为5.7.18,不需要安装libnuma.
如之前安装过MySQL,清除一下目录和文件
/etc/my.cnf or the /etc/mysql
rhel7以后需要取消RemoveIPC限制
[root@rhelb mysql]# vi /etc/systemd/logind.conf
#RemoveIPC=yes -> RemoveIPC=no
检查软件包是否安装
[root@rhelb mysql]# rpm -qa | grep libaio
关闭防火墙
[root@rhelb yum.repos.d]# vi /etc/sysconfig/selinux
SELINUX=enforcing-> SELINUX=disabled
关闭系统THP,rhel7以后和之前关闭THP文件有变化,rhel7及以后关闭方式如下:
[root@rhelb yum.repos.d]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
在quiet后添加 transparent_hugepage=never
[root@rhelb yum.repos.d]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
添加后重启主机
[root@rhelb yum.repos.d]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
配置yum源,rhel7以后,新建一个新的yum资料库
[root@rhelb mysql]# mount /dev/sr0 /mnt
[root@rhelb yum.repos.d]# ls -lrt
total 8
-rw-r--r--. 1 root root 91 Aug 16 23:11 rhel.repo
-rw-r--r--. 1 root root 358 Aug 16 23:12 redhat.repo
[root@rhelb yum.repos.d]# more /etc/yum.repos.d/rhel.repo
[rhel7_server]
name=added from: file:///rhel7/dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0
安装软件包:
[root@rhelb mysql]# yum -y install libaio.x86_64
......
Installed:
libaio.x86_64 0:0.3.109-13.el7
Complete!
MySQL二进制目录说明:
Directory Contents of Directory
bin mysqld server, client and utility programs
docs MySQL manual in Info format
man Unix manual pages
include Include (header) files
lib Libraries
share Error messages, dictionary, and SQL for database installation
support-files Miscellaneous support files
解压软件:
[root@rhelb soft]# tar -xzvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
[root@rhelb soft]# mv mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
创建相关用户:
[root@rhelb mysql]# groupadd mysql
[root@rhelb mysql]# useradd -r -g mysql -s /bin/false mysql
[root@rhelb mysql]# cd /usr/local
[root@rhelb local]# mkdir /data
[root@rhelb local]# chown -R mysql:mysql /usr/local/mysql/
[root@rhelb local]# chown -R mysql:mysql /data/
[root@rhelb local]# chmod 750 /data/
初始化数据库:
查看mysqld参数:
root@rhelb mysql]# bin/mysqld --verbose --help |more
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2 - No such file or directory)
bin/mysqld Ver 5.7.18 for linux-glibc2.5 on x86_64 (MySQL Community Server (GPL))
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Starts the MySQL database server.
Usage: bin/mysqld [OPTIONS]
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
The following groups are read: mysqld server mysqld-5.7
The following options may be given as the first argument:
root初始化密码kdivr2ax2P,K
[root@rhelb mysql]# ls -lrt /data/
total 110628
-rw-r----- 1 mysql mysql 50331648 Aug 21 05:11 ib_logfile1
-rw-r----- 1 mysql mysql 56 Aug 21 05:11 auto.cnf
drwxr-x--- 2 mysql mysql 8192 Aug 21 05:11 performance_schema
drwxr-x--- 2 mysql mysql 4096 Aug 21 05:11 mysql
drwxr-x--- 2 mysql mysql 8192 Aug 21 05:11 sys
-rw-r----- 1 mysql mysql 419 Aug 21 05:11 ib_buffer_pool
-rw-r----- 1 mysql mysql 50331648 Aug 21 05:11 ib_logfile0
-rw-r----- 1 mysql mysql 12582912 Aug 21 05:11 ibdata1
配置ssl,会话安全方面考虑,如不需要可以不配置
[root@rhelb mysql]# bin/mysql_ssl_rsa_setup
Generating a 2048 bit RSA private key
.................................+++
...+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
..........................................................................+++
.+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
..............................+++
..................................................................+++
writing new private key to 'client-key.pem'
配置参数文件,如果不配置[client]客户端连接时提示/tmp/socket.sock
[root@rhelb etc]# vi /etc/my.cnf
[mysqld]
port = 3306
pid-file = /data/mysql3306.pid
datadir = /data/
socket = /data/mysql3306.sock
slow_query_log_file = /data/slow.log
log-error = /data/error.log
[client]
socket = /data/mysql3306.sock
MySQL取消安全隐患:
a)为root用户设置密码
b)删除匿名账号
c)取消root用户远程登录
d)删除test库和对test库的访问权限
e)刷新授权表使修改生效
root@rhelb mysql]# bin/mysql_secure_installation
Securing the MySQL server deployment.
mysql Ver 14.14 Distrib 5.7.18, for linux-glibc2.5 (x86_64) using EditLine wrapper
Connection id: 4
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.18 MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /data/mysql3306.sock
Uptime: 12 sec
Threads: 1 Questions: 6 Slow queries: 0 Opens: 105 Flush tables: 1 Open tables: 98 Queries per second avg: 0.500
感谢各位的阅读!关于“RHEL 7.2如何安装二进制MySQL 5.7.18”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
大型站长资讯类网站! https://www.nzzz.com.cn