OS: CentOS release 6.9 (Final)
MySQL: mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz
说明:类似的操作系统也可以的。为了方便起见,涉及到的操作,均可以直接粘贴复制,比较直观快捷的实施,我没有将带有命令行的截图或者文字粘贴出来。
可能会与路径有关,本文档是基于实践而记录下的,可能与你的环境有所不同,请遇到问题,具体分析查找资料。
二、准备工作 2.1、修改主机名称hostname myserver sed -i 's/shell/myserver/' /etc/sysconfig/network
2.2、关闭selinuxsed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce 0
2.3、修改系统内核参数cat >> /etc/sysctl.conf <<EOF fs.file-max=655360 fs.aio-max-nr = 1048576 kernel.sem = 5050 646400 5050 128 kernel.shmmax = 137438953472 kernel.shmall = 4294967296 kernel.shmmni = 4096 net.ipv4.ip_local_port_range = 9000 65500 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_rmem = 4096 87380 16777216 net.ipv4.tcp_wmem = 4096 65536 16777216 net.core.netdev_max_backlog = 32768 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_fin_timeout = 10 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_max_syn_backlog = 32768 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.conf.default.accept_source_route = 0 vm.swappiness=1 EOF # 使其生效 sysctl -p
2.4、安装依赖包# 需要配置yum yum clean all yum -y update yum -y install gd libxml2-devel libjpeg-devel libpng-devel net-snmp-devel wget telnet vim zip unzip yum -y install curl-devel libxslt-devel pcre-devel libjpeg libpng libcurl4-openssl-dev yum -y install libcurl-devel libcurl freetype-config freetype freetype-devel unixODBC libxslt yum -y install libtool openssl-devel yum -y install perl-devel perl-ExtUtils-Embed yum -y install ncurses-devel.x86_64 openldap-devel.x86_64 lrzsz openssh-clients gcc-g77 bison yum -y install libmcrypt libmcrypt-devel mhash mhash-devel bzip2 bzip2-devel yum -y install ntpdate rsync svn patch iptables iptables-services yum -y install libevent libevent-devel cyrus-sasl cyrus-sasl-devel yum -y install gd-devel libmemcached-devel memcached git libssl-devel libyaml-devel auto yum -y install gcc gcc-c++ make autoconf automake ncurses-devel ncurses cmake libaio libaio-devel boost yum -y install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL perl perl-devel yum -y groupinstall "Server Platform Development" "Development tools" yum -y groupinstall "Development tools"
2.5、基本初始化mkdir -p /opt/mysql cd /opt/mysql/ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz tar -zxf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz cd /usr/local/ ln -s /opt/mysql/mysql-5.7.20-linux-glibc2.12-x86_64 mysql
2.6、创建所需要的目录
mkdir -p /gomeo2o/data/mysql/mysql_3306/{data,logs,tmp}
mkdir -p /data/backup/
# 更改权限
groupadd mysql
useradd -g mysql mysql -d /home/mysql -s /sbin/nologin