CentOS6.5下安装mysql

1.安装介质

Mysql    http://dev.mysql.com/downloads/mysql/     本次使用mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

2.安装过程

2.1主机配置

a)关闭防火墙

service iptables stop

 chkconfig iptables off

 chkconfig --list iptables

iptables            0:off       1:off       2:off       3:off       4:off       5:off       6:off

b)禁掉Selinux

vim /etc/selinux/config

#SELINUX=enforcing

#SELINUXTYPE=targeted

SELINUX=disabled

setenforce 0

2.2修改limits.conf

vi /etc/security/limits.conf

mysql soft nproc 16384

mysql hard nproc 16384

mysql soft nofile 65536

mysql hard nofile 65536

mysql soft stack 10240

2.3添加pam_limits.so模块

在文件最下面加入以下内容:

vi /etc/pam.d/login

session required pam_limits.so

2.4配置内核参数

vi /etc/sysctl.conf

 

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 16777216

kernel.shmmax = 68719476736

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.ip_local_port_range = 9000 65500

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_syncookies=1

net.ipv4.tcp_fin_timeout = 30

使修改的内核参数生效

sysctl -p

确保当前系统没有mysql相关的包

rpm -aq|grep -i mysql

rpm -e xxxx  --nodeps

2.5创建安装目录

查看磁盘的挂载情况

df -h   

umount /home

mkdir /u01

vi /etc/fstab

修改:

/dev/mapper/VolGroup-lv_home /u01

mount /dev/mapper/VolGroup-lv_home /u01

mkdir /u01/db

2.6创建mysql用户

useradd -u 601 -d /u01/db/mysql -s /bin/bash mysql

passwd mysql       #设置mysql用户的密码为mysql

 [root@root ~]# id mysql

uid=601(mysql) gid=601(mysql) groups=601(mysql)

2.7解压安装文件

红色字体的命令是在一台机器上安装完之后,在另外一台机器上直接scp过去的

 MySQL-shared-compat-5.6.33-1.linux_glibc2.5.x86_64.rpm root@192.168.1.243:/u01/db/mysql/

scp mysql-5.6.29-linux-glibc2.5-x86_64.tar root@192.168.1.243:/u01/db/mysql/

su – mysql

将mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz和MySQL-shared-compat-5.6.33-1.linux_glibc2.5.x86_64.rpm上传至/u01/db/mysql下并解压

gunzip mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz

tar -xvf mysql-5.6.29-linux-glibc2.5-x86_64.tar

ln -s mysql-5.6.29-linux-glibc2.5-x86_64 mysql

2.8配置mysql的环境变量

vi ~/.bash_profile

增加:

PATH=$HOME/mysql/bin:$HOME/mysql/support-files:$PATH

[mysql@localhost ~]$ source ~/.bash_profile

[mysql@localhost ~]$ which mysql

~/mysql/bin/mysql

2.9修改 mysql.server文件

vi ~/mysql/support-files/mysql.server

修改:

basedir=/u01/db/mysql/mysql

datadir=/u01/db/mysql/mydata

ln -s ~/mysql/support-files/mysql.server ~/mysql/bin

cd ~/mysql

scripts/mysql_install_db --basedir=/u01/db/mysql/mysql --datadir=/u01/db/mysql/mydata

cd /u01/db/mysql/mysql/

support-files/mysql.server start

删除测试数据库(test)和匿名用户

/u01/db/mysql/mysql/bin/mysql_secure_installation

第一个命令按enter,之后密码是123456,之后全是y

mysql.server stop

cd $HOME

mkdir conf log_bin logs log_relay scripts sh

vi conf/my.cnf

修改server_id的值,每台机器要设置为唯一值,将下面这段整段复制过去

[client] 

port = 3306 

socket = /tmp/mysql.sock 

 

[mysqld] 

#GERNERAL

port = 3306

user = mysql

server_id = 4303

socket = /tmp/mysql.sock 

character_set_server = utf8

basedir = /u01/db/mysql/mysql

datadir = /u01/db/mysql/mydata

pid-file = /u01/db/mysql/mydata/mysql.pid

lower_case_table_names = 1

replicate-ignore-db=mysql

max_connections = 3000

max_connect_errors = 6000

wait_timeout=31536000

interactive_timeout=31536000

skip-name-resolve

 

#LOG

log_error = /u01/db/mysql/logs/mysql-error.log

log_bin = /u01/db/mysql/log_bin/mysql-bin 

binlog_format = ROW

expire_logs_days = 10

relay_log = /u01/db/mysql/log_relay/relay-bin

relay_log_recovery = 1

slow_query_log = 1 

long_query_time = 1

slow_query_log_file = /u01/db/mysql/logs/mysql-slow.log

log-slave-updates=true

binlog-ignore-db=mysql

 

#GTID

gtid-mode=on 

enforce-gtid-consistency=true

 

#DOUBLE 1

sync_binlog = 1

innodb_flush_log_at_trx_commit = 1

 

#INNODB

default-storage-engine = InnoDB

innodb_file_per_table = 1  

innodb_open_files = 500 

innodb_buffer_pool_size = 20000M

innodb_log_file_size = 100M

innodb_write_io_threads = 4 

innodb_read_io_threads = 4   

innodb_thread_concurrency = 0  

innodb_purge_threads = 1  

innodb_log_buffer_size = 2M 

innodb_log_files_in_group = 3 

innodb_max_dirty_pages_pct = 90 

innodb_lock_wait_timeout = 120  

 

#rpl_semi_sync_master_enabled=ON

#rpl_semi_sync_slave_enabled=ON

#rpl_semi_sync_master_timeout=milliseconds

#rpl_semi_sync_master_timeout = 1000

#rpl_semi_sync_master_trace_level = 32

 

log_bin_trust_function_creators=1

max_allowed_packet = 36M

group_concat_max_len=102400

tmp_table_size=200M

 

[mysqladmin]

user=root

password=123456

 

ln -s conf/my.cnf .my.cnf

mysql.server start

增加root用户远程连接

mysql>

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

flush privileges;

通过远程连接测试

mysql -uroot -p -h 192.168.1.249

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值