centos7二进制安装php,centos7安装(二进制包)mysql8

系统优化:关闭selinuxsetenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config关闭防火墙systemctl stop firewalld

systemctl disable firewalld安装依赖包yum -y install libeventsysctl.conf 优化:cat >> /etc/sysctl.conf << EOF

fs.aio-max-nr = 1048576

fs.file-max = 681574400

kernel.shmmax = 137438953472

kernel.shmmni = 4096

kernel.sem = 250 32000 100 200

net.ipv4.ip_local_port_range = 9000 65000

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048586

EOF

sysctl -plimit 优化:cat >> /etc/security/limits.conf << EOF

* soft nproc 65536

* hard nproc 65536

* soft nofile 65536

* hard nofile 65536

EOF

cat >> /etc/security/limits.d/20-nproc.conf << EOF

* soft nproc unlimited

* hard nproc unlimited

EOF

cat >> /etc/pam.d/login << EOF

session required /lib/security/pam_limits.so

session required pam_limits.so

EOF

cat >> /etc/profile << EOF

ulimit -HSn 65535

EOF

source /etc/profile

安装mysql8新建系统用户及创建所需文件夹useradd -M mysql -s /sbin/nologin

mkdir -p /data/mysql/{data,log} /usr/local/mysql/etc

chown -R mysql:mysql /data/mysql下载mysql8安装包wget https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-8.0.15-5/binary/tarball/Percona-Server-8.0.15-5-Linux.x86_64.ssl101.tar.gz安装tar zxvf Percona-Server-8.0.15-5-Linux.x86_64.ssl101.tar.gz

mv Percona-Server-8.0.15-5-Linux.x86_64.ssl101/* /usr/local/mysql/

ln -s /usr/local/mysql /usr/local/Percona-Server-8.0.15-5-Linux.x86_64.ssl101

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

sed -i 's|conf\=/etc/my.cnf|conf\=/usr/local/mysql/etc/my.cnf|g' /etc/init.d/mysqld

sed -i "s|^mysqld_pid_file_path=.*$|mysqld_pid_file_path='/data/mysql/mysql.pid'|g" /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

ln -s /usr/local/mysql/bin/mysql /usr/sbin/修改配置cat > /etc/my.cnf << EOF

[client]

port = 3306

socket = /tmp/mysql.sock

[mysql]

prompt=\\u@\\d \\R:\\m>

auto_rehash

[mysqldump]

quick

max_allowed_packet = 16M

[mysqld]

user = mysql

port = 3306

wait_timeout = 31536000

interactive_timeout = 31536000

basedir = /usr/local/mysql

socket = /tmp/mysql.sock

pid_file = /data/mysql/mysql.pid

datadir = /data/mysql/data

log_bin = /data/mysql/data/bin

skip_name_resolve

skip_external_locking

default_storage_engine = InnoDB

slow_query_log = 1

long_query_time = 3

slow_query_log_file = /data/mysql/log/slow.log

log_error = /data/mysql/log/mysql_error.log

relay_log = /data/mysql/log/slave-relay.log

server_id = 8

gtid_mode = on

enforce_gtid_consistency = 1

EOFcat > /usr/local/mysql/etc/my.cnf << EOF

[client]

port = 3306

socket = /tmp/mysql.sock

[mysql]

prompt=\\u@\\d \\R:\\m>

auto_rehash

[mysqldump]

quick

max_allowed_packet = 64M

[mysqld]

user = mysql

server_id = 8

port = 3306

wait_timeout = 31536000

interactive_timeout = 31536000

socket = /tmp/mysql.sock

explicit_defaults_for_timestamp = 1

basedir = /usr/local/mysql

datadir = /data/mysql/data

pid_file = /data/mysql/mysql.pid

performance_schema = 0

log_bin_trust_function_creators = 1

lower_case_table_names = 1

init_connect = 'SET NAMES utf8mb4'

#character_set_server = utf8mb4

skip_name_resolve

skip_external_locking

max_connections = 4000

max_connect_errors = 10000

open_files_limit = 65535

max_allowed_packet = 64M

binlog_cache_size = 64K

max_heap_table_size = 16M

tmp_table_size = 16M

read_buffer_size = 128K

read_rnd_buffer_size = 256K

sort_buffer_size = 256K

join_buffer_size = 256K

key_buffer_size = 8M

thread_cache_size = 9

####binlog

log_bin = /data/mysql/data/bin

binlog_format = row

log_slave_updates = 1

sync_binlog = 1

expire_logs_days = 5

binlog_checksum = CRC32

slave_allow_batching = 1

master_verify_checksum = 1

slave_sql_verify_checksum = 1

master_info_repository = table

relay_log_info_repository = table

relay_log_purge = 1

relay_log_recovery = 1

relay_log = /data/mysql/log/slave-relay.log

binlog_row_image = minimal

binlog_rows_query_log_events = 1

####other logs

long_query_time = 3

slow_query_log = 1

slow_query_log_file = /data/mysql/log/slow.log

log_error = /data/mysql/log/mysql_error.log

####master&slave

gtid_mode = on

enforce_gtid_consistency = 1

####innodb

default_storage_engine = InnoDB

innodb_open_files = 4000

innodb_buffer_pool_size = 128m

innodb_purge_threads = 4

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 16M

innodb_log_files_in_group = 3

innodb_log_file_size = 48M

innodb_flush_method = O_DIRECT

innodb_data_file_path = ibdata1:12M:autoextend

innodb_file_per_table = 1

EOF初始化/usr/local/mysql/bin/mysqld --initialize-insecure启动、关闭mysql/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &

service mysqld stop登录服务器并增加用户/usr/local/mysql/bin/mysql -S /tmp/mysql.sock

> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

> CREATE USER 'root'@'%' IDENTIFIED BY '123456';

> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

> FLUSH PRIVILEGES;修改mysql启动文件并设置开机启动echo '/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &' >> /etc/rc.d/rc.local

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值