今天 看一马哥视频 写点东东
mysql 安装配置
通用二进制包 直接解压配置使用 wget https://downloads.mariadb.com/archives/mysql-5.5/mysql-5.5.39-linux2.6-x86_64.tar.gz
#yum install libaio
mysql-5.5.39-linux2.6-x86_64.tar.gz
解压缩 tar -xf mysql-5.5.39-linux2.6-x86_64.tar.gz -C /usr/local
做软连接 ln -sv /usr/local/mysql-5.5.39-linux2.6-x86_64 /usr/local/mysql
创建mysql用户MySQL组 修改权限 准备初始化
[[email protected] mysql]# groupadd -r -g 306 mysql
[[email protected] mysql]# useradd -g 306 -r -u 306 mysql
[[email protected] mysql]# id mysql
uid=306(mysql) gid=306(mysql) 组=306(mysql)
[[email protected] mysql]# cd ..
[[email protected] local]# chown -R mysql.mysql /usr/local/mysql/*
配置逻辑卷的时候 默认是centos6 安装的是LVM2 所以
# yum install lvm2
进行安装后操作管理lvm管理
[[email protected] army]# pvcreate /dev/sdb5
Physical volume "/dev/sdb5" successfully created
[[email protected] army]# vgcreate myvg /dev/sdb5
Volume group "myvg" successfully created
[[email protected] army]# lvcreate -n mydata -L 5G myvg
Logical volume "mydata" created
[[email protected] army]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
mydata myvg -wi-a----- 5.00g
[[email protected] army]# mke2fs -j /dev/myvg/mydata
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] army]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Jun 19 20:11:18 2015
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=dc24aa45-f6b8-4d21-a5ad-fd8358b011e1 / ext4 defaults
1 1
UUID=68e2bcd9-1f79-435c-80c8-a22cddd123a6 /boot ext4 defaults
1 2
UUID=741ee383-fa2a-4027-8923-8f19d0ae5bad /usr/local ext4 defaults
1 2
UUID=8559f55e-fea9-4700-90ca-30b4504f5165 swap swap defaults
0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/myvg/mydata /mydata ext3 defaults 0 0
[[email protected] army]# mkdir /mydata
[[email protected] army]# mount -a
[[email protected] army]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /usr/local type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/myvg-mydata on /mydata type ext3 (rw)
[[email protected] army]# cd /mydata/
[[email protected] mydata]# ls
lost+found
[[email protected] mydata]# mkdir data
[[email protected] mydata]# ll
总用量 20
drwxr-xr-x. 2 root root 4096 6月 24 21:19 data
drwx------. 2 root root 16384 6月 24 21:14 lost+found
[[email protected] mydata]# chown -R mysql.mysql /mydata/data/
[[email protected] mydata]# ls
data lost+found
[[email protected] mydata]# ll
总用量 20
drwxr-xr-x. 2 mysql mysql 4096 6月 24 21:19 data
drwx------. 2 root root 16384 6月 24 21:14 lost+found
[[email protected] mydata]# chmod o-rx data/
[[email protected] mydata]# ll
总用量 20
drwxr-x---. 2 mysql mysql 4096 6月 24 21:19 data
drwx------. 2 root root 16384 6月 24 21:14 lost+found
[[email protected] mydata]# cd /usr/local/mysql
配置环境变量
[[email protected] profile.d]# vim mysql.sh
export PATH=$PATH:/usr/local/mysql/bin
立即生效环境变量
[[email protected] profile.d]# source /etc/profile.d/mysql.sh
[[email protected] profile.d]# echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/apache/bin:/home/army/bin:/usr/local/apache/bin:/usr/local/mysql/bin
提供mysql的启动脚本 和配置文件
[[email protected] mysql]# cd support-files/
[[email protected] support-files]# pwd
/usr/local/mysql/support-files
[[email protected] support-files]# ls
binary-configure magic my-medium.cnf mysql.server
config.huge.ini my-huge.cnf my-small.cnf ndb-config-2-node.ini
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# ll /etc/init.d/mysqld
-rwxr-xr-x. 1 root root 10880 6月 24 22:51 /etc/init.d/mysqld
[[email protected] support-files]# chkconfig --add mysqld
[[email protected] support-files]# chkconfig --list mysqld
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[[email protected] support-files]#
添加配置MySQL的配置文件 mysql的配置文件默认给我们提供的多个的配置文件要根据的我们机器配置来决定
注意 mysql的 5.6 以后 就可以不用负责 mysql的 配置文件 执行初始化 脚本会自己生成my.cnf 文件
注意一定修改 配置文件的的 datadir = /mydata/data/ //添加这一条数据存放的路径 非常重要
这里我的服务器是虚拟机的
1个cup 内存是1G 所有使用的是 my-large.cnf
cp my-large.cnf /etc/my.cnf
#vim /etc/my.cnf
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU‘s*2 for thread_concurrency
thread_concurrency = 4 //这里根据物理CPU 有多少个乘以2
datadir = /mydata/data/ //添加这一条数据存放的路径 非常重要
初始化mysql 注意初始化的时候 路径
[[email protected] mysql]# pwd
/usr/local/mysql
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
Installing MySQL system tables...
./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
这初始化错误的 提示没有找到 libraries: libaio.so.1 所有安装 libaiio
Installation of system tables failed! Examine the logs in
/mydata/data/ for more information.
You can try to start the mysqld daemon with:
shell> ./bin/mysqld --skip-grant &
and use the command line tool ./bin/mysql
to connect to the mysql database and look at the grant tables:
shell> ./bin/mysql -u root mysql
mysql> show tables
Try ‘mysqld --help‘ if you have problems with paths. Using --log
gives you a log in /mydata/data/ that may be helpful.
Please consult the MySQL manual section
‘Problems running mysql_install_db‘, and the manual section that
describes problems on your OS. Another information source are the
MySQL email archives available at http://lists.mysql.com/.
Please check all of the above before submitting a bug report
at http://bugs.mysql.com/
以上是初始化错的的 要重新初始化才行
注意权限mysql安装完成后要把MySQL的所有者权限还给root
[[email protected] mysql]# chown -R root /usr/local/mysql/*
[[email protected] mysql]# ll
总用量 200
drwxr-xr-x. 2 root mysql 4096 6月 20 10:43 bin
-rw-r--r--. 1 root mysql 17987 7月 19 2014 COPYING
drwxr-xr-x. 3 root mysql 4096 6月 20 10:43 data
添加mysql 的man 手册帮助文档
[[email protected] mysql]# vim /etc/man.config
添加这一条
MANPATH /usr/local/mysql/man
输出库文件
MySQL的库文件所在是
[[email protected] lib]# pwd
/usr/local/mysql/lib
[[email protected] ~]# vim /etc/ld.so.conf.d/mysql.conf
添加一条
/usr/local/mysql/lib
执行重新加载 库文件命令
ldconfig -v
输出头文件
[[email protected] ~]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
"/usr/include/mysql" -> "/usr/local/mysql/include/"
[[email protected] ~]#
mysql 安装配置完成!