标签:repo mct read 使用 头文件 块大小 warning 文件 ase
准备工作:一、准备数据存放的文件系统
新建一个逻辑卷,并将其挂载至特定目录。此处新建一个5G的逻辑卷挂载至/mydata目录下,而后创建/mydata/data目录为MySQL的数据目录。
[root@localhost ~]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分区号 (3,4,默认 3):3
起始 扇区 (48250880-251658239,默认为 48250880):
将使用默认值 48250880
Last 扇区, +扇区 or +size{K,M,G} (48250880-251658239,默认为 251658239):+5G
分区 3 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
[root@localhost ~]# partx -a /dev/sda
partx: /dev/sda: error adding partitions 1-2
[root@localhost ~]# partx -a /dev/sda
partx: /dev/sda: error adding partitions 1-3
[root@localhost ~]# mkfs -t ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: 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
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkdir /mydata
[root@localhost ~]# mount /dev/sda3 /mydata
[root@localhost ~]# mkdir /mydata/data
二、新建用户以安全的方式运行程序
[root@localhost ~]# groupadd -r mysql
[root@localhost ~]# useradd -r -g mysql -s /sbin/nologin -m -d /mydata/data mysql
useradd:警告:此主目录已经存在。
不从 skel 目录里向其中复制任何文件。
[root@localhost ~]# chown -R mysql:mysql /mydata/data/
三、安装并初始化mariadb-10.2.12
下载mariadb至本地此处使用的是mariadb-10.2.12,由于MySQL解压后默认自己的安装路径为/usr/local路径下所以解压时需要解压至此目录,并且创建名为mysql的链接文件链接至此解压目录。
[root@localhost ~]# cd /tmp
[root@localhost tmp]# tar xf mariadb-10.2.12-linux-x86_64.tar.gz -C /usr/local/
[root@localhost tmp]# cd /usr/local/
[root@localhost local]# ln -sv mariadb-10.2.12-linux-x86_64 mysql
"mysql" -> "mariadb-10.2.12-linux-x86_64"
[root@localhost local]# cd mysql/
[root@localhost mysql]# chown -R mysql:mysql ./*
[root@localhost mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
Installing MariaDB/MySQL system tables in ‘/mydata/data‘ ...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
‘./bin/mysqladmin‘ -u root password ‘new-password‘
‘./bin/mysqladmin‘ -u root -h localhost.localdomain password ‘new-password‘
Alternatively you can run:
‘./bin/mysql_secure_installation‘
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd ‘.‘ ; ./bin/mysqld_safe --datadir=‘/mydata/data‘
You can test the MariaDB daemon with mysql-test-run.pl
cd ‘./mysql-test‘ ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB‘s strong and vibrant community:
https://mariadb.org/get-involved/
[root@localhost mysql]# chown -R root ./*
四、为mariadb提供主配置文件
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# mkdir /etc/mysql
[root@localhost support-files]# cp my-large.cnf /etc/mysql/my.cnf
[root@localhost support-files]# vim /etc/mysql/my.cnf
加入以下3行
datadir = /mydata/data
skip_name_resolve = ON
innodb_file_per_table = ON
五、为mariadb提供sysv服务脚本
将support-files目录下的mysql.server复制到/etc/init.d目录下并改名为mysqld,然后将其添加至服务列表
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost support-files]# chkconfig --add mysqld
至此MySQL已经可以正常启动了
[root@localhost support-files]# service mysqld start
Starting mysqld (via systemctl): [ 确定 ]
为了使MySQL的安装符合系统使用规范,并将其开发组件导出给系统使用,还需要进行以下步骤
六、输出mariadb的man手册至man命令的查找路径
编辑/etc/man_db.config,添加如下行
MANDATORY_MANPATH /usr/local/mysql/man
如果系统为centos6,则编辑/etc/man.config 添加如下行
MANPATH /usr/local/mysql/man
七、输出mariadb的头文件至系统头文件路径/usr/include
[root@localhost ~]# ln -sv /usr/local/mysql/include /usr/include/mysql
"/usr/include/mysql" -> "/usr/local/mysql/include"
八、输出mariadb的库文件给系统库查找路径
[root@localhost ~]# echo /usr/local/mysql/lib > /etc/ld.so.conf.d/mysql.conf
让系统重新载入系统库
[root@localhost ~]# ldconfig
九、修改PATH环境变量
在/etc/profile.d目录下创建脚本文件
[root@localhost ~]# vim /etc/profile.d/mysql.sh
#!/bin/bash
export PATH=/usr/local/mysql/bin:$PATH
标签:repo mct read 使用 头文件 块大小 warning 文件 ase
原文地址:http://blog.51cto.com/11886307/2061716