[root@node01 ~]# cat >> /etc/hosts <<EOF
192.168.1.101  node01
EOF
创建mysql用户
[root@node01 ~]# useradd mysql
[root@node01~]# echo mysql | passwd --stdin mysql
Changing password for user mysql.
passwd: all authentication tokens updated successfully
[root@node01 ~]# id mysql
uid=1001(mysql) gid=1002(mysql) groups=1002(mysql)
修改/etc/f文件,配置用户对系统资源的使用限制
[root@node01 ~]# cat >> /etc/f <<EOF
mysql            soft    nproc          4096
mysql            hard    nproc          65535
mysql            soft    nofile        4096
mysql            hard    nofile        65535
EOF
调整系统内核参数
[root@node01 ~]# cat /sys/block/sda/queue/scheduler
noop [deadline] cfq
[root@node01 ~]# echo "vm.swappiness = 10" >>/f
[root@node01 ~]# echo 'vm.dirty_background_ratio = 5' >>/f
[root@node01 ~]# echo 'vm.dirty_ratio = 10' >>/f
[root@node01 ~]# sysctl -p
安装相关依赖包
[root@node01 ~]# yum install -y libaio
下载mysql5.7二进制包,通过xftp上传到node01,解压到当前目录下
[root@node01 ~]$ tar zxvf mysql-5.7.41-linux-glibc2.12-x86_
将解压过的mysql5.7包重命名为mysql,移动到/usr/local/目录下
[root@node01 ~]$ mv mysql-5.7.41-linux-glibc2.12-x86_64 mysql
[root@node01 ~]# mv mysql /usr/local/
创建数据库相关目录,修改相关目录权限
[root@node01 ~]# mkdir /usr/local/mysql/data
[root@node01 ~]# chown -R mysql:mysql /usr/local/mysql
[root@node01 ~]# mkdir /var/lib/mysql
[root@node01 ~]# chown -R mysql:mysql /var/lib/mysql
[root@node01 ~]# mkdir /var/lib/mysql-files
[root@node01 ~]# chown mysql:mysql /var/lib/mysql-files
修改系统环境变量:PATH
[root@node01 ~]# echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile
[root@node01 ~]# source /etc/profile
[root@node01 ~]# env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
创建配置文件:/etc/myf
[root@node01 ~]# vim /etc/myf
[mysqld]
user = mysql
port = 3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
secure_file_priv = /var/lib/mysql-files
log-error = mysqld_error.log
pid-file=mysqld.pid
log_timestamps = SYSTEM
character-set-server = utf8mb4
open-files-limit = 65535
max_connections = 500
max_connect_errors = 10000
max_allowed_packet = 32M
tmp_table_size = 512M
mysql下载starting the servermax_heap_table_size = 512M
slow_query_log = 1
long_query_time = 2
slow_query_log_file = mysqld_slow.log
server_id = 201
log_bin = mysql-bin
binlog_cache_size = 16M
max_binlog_cache_size = 4G
max_binlog_size = 128M
expire_logs_days = 7
binlog_rows_query_log_events = on
transaction-isolation = READ-COMMITTED
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_log_file_size = 256M
innodb_log_files_in_group = 4
innodb_log_buffer_size = 16M
innodb_undo_logs = 128
innodb_undo_tablespaces = 3
innodb_undo_log_truncate = 1
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_temp_data_file_path = ibtmp1:128M:autoextend
innodb_print_all_deadlocks = 1
[mysql]
socket=/var/lib/mysql/mysql.sock
prompt=(\\u@\\h) >\\_
初始化数据库
[root@node01 ~]# mysqld --initialize-insecure
复制启动脚本到/etc/init.d目录下
[root@node01 ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
启动mysql服务,并查看服务启动状态
[root@node01 ~]# /etc/init.d/mysql.server start
SUCCESS!
[root@node01 ~]# /etc/init.d/mysql.server status
SUCCESS! MySQL running (14499)
[root@node01 ~]# echo "/usr/local/mysql/lib" > /etc/f.f
[root@node01 ~]# ldconfig
[root@node01 ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql
[root@node01 ~]# mysql_secure_installation
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: n
Please set the password for root here.#为root用户设置密码
New password:
Re-enter new password:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y #删除匿名用户
Success.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y #禁止root远程登录
Success.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y #删除test数据库
-
Dropping
Success.

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。