共計 6254 個字符,預(yù)計需要花費(fèi) 16 分鐘才能閱讀完成。
這篇文章主要介紹“centos7 二進(jìn)制安裝 mysql5.7.25 的過程”,在日常操作中,相信很多人在 centos7 二進(jìn)制安裝 mysql5.7.25 的過程問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”centos7 二進(jìn)制安裝 mysql5.7.25 的過程”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學(xué)習(xí)吧!
一. 安裝前系統(tǒng)環(huán)境檢查
1. 關(guān)閉 selinux
[root@mgr1 ~]# cat /etc/sysconfig/selinux
# 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=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
2. 關(guān)閉防火墻
[root@mgr1 ~]# systemctl stop firewalld
[root@mgr1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2019-02-16 19:12:54 EST; 8s ago
Docs: man:firewalld(1)
Process: 7054 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 7054 (code=exited, status=0/SUCCESS)
Feb 16 08:46:31 mgr1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Feb 16 08:46:33 mgr1 systemd[1]: Started firewalld - dynamic firewall daemon.
Feb 16 19:12:52 mgr1 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Feb 16 19:12:54 mgr1 systemd[1]: Stopped firewalld - dynamic firewall daemon.
3.centos 7 io 調(diào)度系統(tǒng)是 deadline 模式,ssd 硬盤需要改為 noop 模式
[root@mgr1 ~]# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
4. 操作系統(tǒng)的限制
[root@mgr1 default]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 3795
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 3795
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
這里面最重要的兩個參數(shù)是 open files 和 max user processes
編輯 /etc/security/limits.conf,加入下面的內(nèi)容
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
5.numa
6. 創(chuàng)建用戶組和用戶
[root@mgr1 default]# groupadd mysql
[root@mgr1 default]#
[root@mgr1 default]# useradd -g mysql mysql -s /sbin/nologin
[root@mgr1 default]#
7. 做個軟連接
[root@mgr1 default]# cd /usr/local
[root@mgr1 local]# ls -ltr
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 5 root root 49 Feb 16 08:30 share
drwxr-xr-x. 9 root root 129 Feb 16 18:58 mysql-5.7.25-linux-glibc2.12-i686
[root@mgr1 local]# ln -s mysql-5.7.25-linux-glibc2.12-i686 mysql
8. 授權(quán)
[root@mgr1 local]# chown mysql:mysql -R mysql
9. 創(chuàng)建 mysql 數(shù)據(jù)庫的數(shù)據(jù)目錄(datadir)
[root@mgr1 /]# mkdir -p /data/mysql
10. 給數(shù)據(jù)目錄授權(quán)
[root@mgr1 /]# chown -R mysql:mysql /data/mysql
11. 配置 /etc/my.cnf 文件
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
[mysql]
prompt= \u@db \R:\m:\s [\d]
no-auto-rehash
[mysqld]
user=mysql
port=3306
socket=/usr/local/mysql/mysql.sock
server_id=20
gtid_mode=on
enforce_gtid_consistency=on
master_info_repository=table
relay_log_info_repository=table
binlog_checksum=none
log_slave_updates=on
log-bin=/usr/local/mysql/log/mysql-bin
binlog_format=row
basedir=/usr/local/mysql
datadir=/data/mysql
performance_schema=1
character-set-server=utf8
collation-server=utf8_bin
log_timestamps=system
explicit_defaults_for_timestamp=true
####group replication
transaction_write_set_extraction =XXHASH64
loose-group_replication_group_name = bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
loose-group_replication_start_on_boot =off
loose-group_replication_local_address = 192.168.44.132:33061
loose-group_replication_group_seeds = 192.168.44.132:33061,192.168.44.133:33061,192.168.44.134:33061
loose-group_replication_bootstrap_group =off
12. 初始化
[root@mgr1 bin]# ./mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql –initialize
-bash: ./mysqld: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
解決辦法:
[root@mgr1 bin]# yum install glibc.i686
[root@mgr1 bin]# ./mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql –initialize
./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解決辦法:
yum -y install libaio.so.1
[root@mgr1 bin]# ./mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql –initialize
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
yum install -y libnuma.so.1
[root@mgr1 bin]# ./mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql –initialize
./mysqld: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
yum install -y
libstdc++.so.6
[root@mgr1 bin]# ./mysqld –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql –datadir=/data/mysql/ –user=mysql –initialize
啟動:
[root@mgr1 bin]# ./mysqld_safe –defaults-file=/etc/my.cnf
[1] 7910
[root@mgr1 bin]# 2019-02-17T07:47:24.044846Z mysqld_safe Logging to /data/mysql/error.log .
2019-02-17T07:47:24.109848Z mysqld_safe Starting mysqld daemon with databases from /data/mysql
2019-02-17T07:47:26.264358Z mysqld_safe mysqld from pid file /data/mysql/mgr1.pid ended
查看初始化密碼:
[root@mgr1 bin]# cat /data/mysql/error.log |grep password
2019-02-17T03:06:47.347886-05:00 1 [Note] A temporary password is generated for root@localhost: vjxL1c_F3*fd
登錄:
[root@mgr1 bin]# ./mysql -uroot -p
修改密碼:
root@db 03:10: [(none)] set password= root123
Query OK, 0 rows affected (0.00 sec)
root@db 03:12: [(none)] alter user root @ localhost password expire never;
Query OK, 0 rows affected (0.00 sec)
root@db 03:13: [(none)] flush privileges;
Query OK, 0 rows affected (0.00 sec)
設(shè)置環(huán)境變量
export PATH=$PATH:/usr/local/mysql/bin
讓它生效
source /etc/profile
到此,關(guān)于“centos7 二進(jìn)制安裝 mysql5.7.25 的過程”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注丸趣 TV 網(wǎng)站,丸趣 TV 小編會繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!