|
|
安装环境 centos x86_64
最小化安装
安装 “development tools" "server platform development"
"desktop platform development" 组件
二进制包安装
一 准备数据存放的文件系统
新建逻辑卷 挂载到 /mydata ,然后新建目录 /my
data/data作为数据库存放目录
1 安装LVM
1
2
| [iyunv@www ~]# rpm -ql lvm
[iyunv@www ~]# yum install lvm2
|
2 新增一块硬盘,划分分区,查看磁盘分区
1
2
3
4
5
6
7
8
9
10
11
| [iyunv@www ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x47e9e58b
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 2610 10474348+ 83 Linux
|
3 创建逻辑分区
修改分区ID 号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| fdisk /dev/sdb
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x47e9e58b
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 8e Linux LVM
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 2610 10474348+ 8e Linux LVM
|
1
2
3
4
5
6
7
| [iyunv@www ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[iyunv@www ~]# pvcreate /dev/sdb5
Physical volume "/dev/sdb5" successfully created
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| [iyunv@www ~]# vgcreate myvg /dev/sdb1 /dev/sdb5
Volume group "myvg" successfully created
[iyunv@www ~]# lvcreate -n mydata -L 10G myvg
Logical volume "mydata" created
[iyunv@www ~]# mke2fs -t ext4 /dev/myvg/mydata
[iyunv@www ~# mkdir mydata
[iyunv@www ~]# mount /dev/myvg/mydata /mydata/
[iyunv@www ~]# vim /etc/fstab
/dev/myvg/mydata/mydata ext4 defaults 0 0
[iyunv@www ~]# mount -a
[iyunv@www ~]# mount
|
4 在/mydata下创建子目录,作为mysql数据库目录
1
| [iyunv@www ~]# mkdir /mydata/data/
|
二 创建mysql 用户 修改权限
1
| [iyunv@www ~]# useradd mysql
|
1
| [iyunv@www ~]# chown -R mysql:mysql /mydata/data/
|
三 安装mysql
1 解压缩到/usr/local/ 更改权限
1
2
| [iyunv@www ~]# tar xf mysql-5.5.37-linux2.6-x86_64.tar.gz -C /usr/local/ [iyunv@www local]# ln -sv mysql-5.5.37-linux2.6-x86_64 mysql
[iyunv@www local]# chown -R mysql:mysql mysql
|
2 配置my.cnf
1
2
3
4
| [iyunv@www mysql]# cd support-files/
[iyunv@www support-files]# cp my-large.cnf /etc/my.cnf
[iyunv@www mysql]# vim /etc/my.cnf
添加datadir=/mydata/data thread_cache_size=4 (物理核心的一到二倍)
|
3 服务脚本
1
2
| [iyunv@www support-files]# cp mysql.server /etc/rc.d/init.d/mysqld
[iyunv@www mysql]# chkconfig mysqld on
|
4 初始化脚本
1
2
3
4
5
| [iyunv@www mysql]#scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
Installing MySQL system tables....
/bin/mysqld
: error whileloading shared libraries
[iyunv@www mysql]# yum install libaio
|
1
| [iyunv@www mysql]# ls /mydata/data/
|
5 修改PATH变量
1
2
3
| [iyunv@www mysql]# vim /etc/profile.d/mysql.sh
添加exportPATH=/usr/local/mysql/bin:$PATH
[iyunv@www mysql]# source /etc/profile.d/mysql.sh
|
6 输出mysql头文件至系统头文件路径
1
| [iyunv@www mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
|
7 输出mysql库文件至系统库文件查找路径
1
2
3
| [iyunv@www mysql]# vim /etc/ld.so.conf.d/mysql.conf
添加/usr/local/mysql/lib
[iyunv@www mysql]# ldconfig -v
|
8 输出mysql man 手册至man命令查找路径
1
2
| [iyunv@www mysql# vim /etc/man.config
添加MANPATH/usr/local/mysql/man
|
9测试连接
1
2
3
4
5
6
7
8
9
10
| [iyunv@www ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.37-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
|
|
|