mysql 5.6单机单实例源码编译安装配置

--linux 基础配置  指定机器名为sql1

--查看centos内核
uname -a
cat /etc/issue

--修改机器名

1、 echo "192.168.33.190 sql1 localhost.localdomain localhost4 localhost4.localdomain4" >> /etc/hosts

2、 vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=sql1

--修改ip
vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:0C:29:39:E0:20"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="78bfd5ef-0ba2-4fff-aba3-bf8d7839fcb9"
IPADDR="192.168.33.190"
GATEWAY="192.168.33.1"
DNS1=180.76.76.76

--关闭selinux
vi /etc/sysconfig/selinux
SELINUX=disabled

--关闭防火墙
service iptables stop
chkconfig iptables off

--配置本地yum源 卸载 umount /mnt/cdrom
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

cd /etc/yum.repos.d
其下所有文件,进行重命名;新建CentOS-Media.repo

vi CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

yum clean all --清理yum缓存

yum install php --安装php测试

如需要将yum源改为网络,还原/etc/yum.repos.d目录下的四个文件即可

--查看是否已安装
rpm -qa | grep mysql
mysql-libs-5.1.61-4.el6.x86_64

--卸载mysql
rpm -e mysql-libs --直接删除会失败
rpm --nodeps -e mysql-libs

--编译安装需要的包
yum -y install make
yum -y install gcc-c++
yum -y install cmake
yum -y install bison-devel
yum -y install ncurses-devel

--创建mysql用户和组
groupadd mysql
useradd -g mysql mysql

--设置用户的操作系统资源限制
vi /etc/security/limits.conf
mysql soft nproc 2047
mysql hard nproc 16384
mysql soft nofile 1024
mysql hard nofile 65536

--安装mysql  前期规划规划

mysql软件安装路径 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

数据文件 -DMYSQL_DATADIR=/data/sql1

my.cnf配置文件 -DSYSCONFDIR=/etc/mysql

字符集 -DDEFAULT_CHARSET=utf8mb4

排序规则 -DDEFAULT_COLLATION=utf8mb4_general_ci

开启load -DENABLED_LOCAL_INFILE=1

开启分区 -DWITH_PARTITION_STORAGE_ENGINE=1

开启Performance_Schema库 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1

mysql端口 -DMYSQL_TCP_PORT=3306

--源码解压
tar -xvf mysql-5.6.21.tar.gz

cd mysql-5.6.21

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/sql1/data \
-DSYSCONFDIR=/etc/mysql \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci

make && make install --约10分钟左右

--设置环境变量 mysql命令目录 -DCMAKE_INSTALL_PREFIX/bin
su - mysql
vi /home/mysql/.bash_profile
export PATH=/usr/local/mysql/bin:$PATH

source ~/.bash_profile

--binlog路径/backup路径/临时文件路径 InnoDB不会创建目录,启动服务器之前事先创建
mkdir /etc/mysql
mkdir -p /data/sql1/data
mkdir /data/sql1/backup
mkdir /data/sql1/tmp
mkdir /data/sql1/binlog
mkdir /data/sql1/log

chown -R mysql:mysql /data
chown -R mysql:mysql /usr/local/mysql

chown -R mysql:mysql /etc/mysql

--配置启动参数
su - mysql
vi /etc/mysql/my.cnf
[client]
port = 3306
socket = /data/sql1/data/mysql.sock

[mysqld]
port = 3306
user = mysql
socket = /data/sql1/data/mysql.sock #client and server in same machine ,use localhost connect to server
pid-file = /data/sql1/data/mysql.pid #In multi-instance keep each instance do not startup twice.

basedir = /usr/local/mysql
datadir = /data/sql1/data
tmpdir = /data/sql1/tmp

open_files_limit = 10240

#buffer
max_heap_table_size = 256M
innodb_buffer_pool_size = 128M
sort_buffer_size = 2M
join_buffer_size = 4M
read_buffer_size =2M
read_rnd_buffer_size =2M
max_connections = 5000

#log
log-bin = /data/sql1/binlog/mysql-bin
max_binlog_cache_size = 512M
max_binlog_size = 512M
binlog_format = mixed
log_output = FILE
log-error = /data/sql1/log/mysql-error.log

slow_query_log = 1
slow_query_log_file = /data/sql1/log/slow_query.log
general_log = 0
general_log_file = /data/sql1/log/general_query.log
expire-logs-days = 14

#Innodb
innodb_data_file_path = ibdata1:128M:autoextend
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_log_group_home_dir = /data/sql1/log
innodb_buffer_pool_size = 512M
innodb_file_per_table = 1

explicit_defaults_for_timestamp=true

--创建数据库 -DCMAKE_INSTALL_PREFIX 安装报错查看日志 mysql-error.log
su - mysql
/usr/local/mysql/scripts/mysql_install_db --datadir=/data/sql1/data --basedir=/usr/local/mysql

--手工启动mysql
su - mysql
mkdir scripts

vi /home/mysql/scripts/mysql_startup.sh
#! /bin/bash
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/mysql/my.cnf &

--关闭mysql
mysqladmin -u root -p shutdown

--sudo 添加执行权限 关闭requiretty
chmod 740 /etc/sudoers

vi /etc/sudoers
#Defaults requiretty

chmod 440 /etc/sudoers

--重启自动启动
vi /etc/rc.local

sudo -i -u mysql /home/mysql/scripts/mysql_startup.sh > /tmp/mysql_db_startup.log 2>&1

时间: 2024-10-10 12:41:28

mysql 5.6单机单实例源码编译安装配置的相关文章

Linux中MySQLl单实例源码编译安装

MySQL5.5以后源码安装要用cmake 1.3 安装相关包(cmake) 1.3.1 cmake软件 cd /home/Public/tools/ tar xf cmake-2.8.8.tar.gz cd cmake-2.8.8 ./configure #CMake has bootstrapped. Now run gmake. gmake gmake install cd ../ 1.3.2 依赖包 yum install ncurses-devel -y 1.4 开始安装mysql 1

yum/源码编译安装配置apache+svn

本次整理的比较急.源码编译和命令解释后续加上.不多说开始吧 系统环境:CentOS6.5_x86_64 minimal YUM版 1.检查是否安装了httpd.mod_dav_svn(实现apache+svn的一个模块).subversion(默认是安装的.需要yum remove subversion卸载掉) [[email protected] ~]# rpm -ql httpd package httpd is not installed [[email protected] ~]# rp

LAMP源码编译安装配置

系统环境CentOS6.5 一.编译安装Apache 关闭selinux和防火墙 1.解决依赖关系 [[email protected] ~]# yum install gcc gcc-c++ openssl openssl-devel 编译安装apr(The mission of the Apache Portable Runtime (APR) project is to create and maintain software libraries that provide a predic

rsync 3.1.1源码编译安装配置

http://rsync.samba.org/ rsync-3.1.1.tar.gz ---0.卸载rpm # yum remove rsync -----1.安装: tar -zxvf rsync-3.1.1.tar.gz cd rsync-3.1.1 ./configure --prefix=/usr/local/rsync --disable-ipv6 make make install ln -s /usr/local/rsync/bin/rsync /usr/local/bin/rsy

PHP源码编译安装的简单整理

PHP源码编译安装配置   下载地址http://php.net/downloads.php CentOS下预装依赖,具体自己对应添加 一般情况下面足够yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y PHP常用配置添加 ./configure  --prefix=/usr/local/php \--with-config-file-path=/u

多实例Mysql5.5.x源码编译安装

多实例Mysql5.5.x源码编译安装 1.  建立Mysql账号 [[email protected] ~]# groupadd mysql [[email protected] ~]# useradd -s /sbin/nologin -g mysql -M mysql useradd参数说明: -s/sbin/nologin 表示禁止该用户登录 -gmysql 指定属于mysql组 -M表示不创建用户家目录 检查创建的用户: [[email protected] ~]# tail -1 /

linux学习笔记——源码编译安装Mysql

#######Redhat6.5源码编译安装Mysql########实验环境:1.IP:172.25.8.32.磁盘要大于20G先添加一块大于20G的磁盘fdisk /dev/vdb        ##得到/dev/vdb1 8e linuxpvcreate /dev/vdb1    ##把物理分区做成物理卷vgextend vg_server1 /dev/vdb1    ##把新建立的/dev/vdb1添加到vg_server1中lvextend -L 20G /dev/vg_server1

CentOS源码编译安装MySQL 5.5.15

CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install gcc gcc-c++ yum install ncurses-devel 下载源码 mkdir -p /tmp cd /tmp wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.

MySQL源码编译安装(CentOS-6.6+MySQL-5.6)

MySQL源码编译安装(CentOS-6.6+MySQL-5.6) 部署环境 操作系统:CentOS-6.6-x86_64-bin-DVD1.iso MySQL版本:mysql-5.6.26.tar.gz 操作用户:root 系统IP:192.168.1.205 主机名:edu-mysql-01 配置:4核.4G内存 一.服务器配置: 1.配置网络 # vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=stati