当前位置: 代码迷 >> MySQL >> MYSQL 二进制装配+XFS
  详细解决方案

MYSQL 二进制装配+XFS

热度:208   发布时间:2016-05-05 17:13:11.0
MYSQL 二进制安装+XFS
1. 准备分区
yum install  xfsprogs
[[email protected] yum.repos.d]# mkfs.xfs -f -i attr=2 -l lazy-count=1,sectsize=4096 -b size=4096 -d sectsize=4096 -L data /dev/sdb
meta-data=/dev/sdb               isize=256    agcount=4, agsize=1966080 blks
         =                       sectsz=4096  attr=2
data     =                       bsize=4096   blocks=7864320, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=3840, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[[email protected] yum.repos.d]# mkdir /data
[[email protected] yum.repos.d]# mount -o rw,noatime,nodiratime,noikeep,nobarrier,allocsize=100M,attr2,largeio,inode64,swalloc /dev/sdb /data
[[email protected] yum.repos.d]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       36G  4.0G   30G  12% /
tmpfs                 2.0G  264K  2.0G   1% /dev/shm
/dev/sda1             485M   59M  401M  13% /boot
/dev/sr0              3.5G  3.5G     0 100% /media/OL6.3 x86_64 Disc 1 20120626
/dev/sr0              3.5G  3.5G     0 100% /mnt
/dev/sdb               30G   33M   30G   1% /data
[[email protected] yum.repos.d]# vi /etc/fstab 




#
# /etc/fstab
# Created by anaconda on Fri May 23 22:30:35 2014
#
# 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
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=181e768c-89a3-4e65-b576-4f9ae746f642 /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap 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/sdb               /data                   xfs     rw,noatime,nodiratime,noikeep,nobarrier,allocsize=100M,attr2,largeio,inode64,swalloc    0 0


2. 准备目录:
[[email protected] yum.repos.d]# mkdir -p /data/mysql/mysql_3306/data
[[email protected] yum.repos.d]# mkdir -p /data/mysql/mysql_3306/tmp
[[email protected] yum.repos.d]# mkdir -p /data/mysql/mysql_3306/logs
[[email protected] yum.repos.d]# chown -R root:mysql /data
[[email protected] yum.repos.d]# chown -R mysql:mysql /data
[[email protected] yum.repos.d]# chmod -R 775 /data


3. 解压MYSQL软件
tar -xzvf mysql-5.5.37-linux2.6-x86_64.tar.gz 


4. 做好软链接
[[email protected] opt]# ln -s /opt/mysql-5.5.37-linux2.6-x86_64 /usr/local/mysql


5. 准备初始化文件:
vi /etc/my.cnf


6. 初始化DB
[[email protected] mysql5]# scripts/mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
Installing MySQL system tables...
140612 13:51:56 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set
OK
Filling help tables...
140612 13:51:56 [Warning] options --log-slow-admin-statements, --log-queries-not-using-indexes and --log-slow-slave-statements have no effect if --log_slow_queries is not set
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 MySQL root USER !
To do so, start the server, then issue the following commands:


/usr/local/mysql5//bin/mysqladmin -u root password 'new-password'
/usr/local/mysql5//bin/mysqladmin -u root -h ycdatadbsupport.localdomain password 'new-password'


Alternatively you can run:
/usr/local/mysql5//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 manual for more instructions.


You can start the MySQL daemon with:
cd /usr/local/mysql5/ ; /usr/local/mysql5//bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql5//mysql-test ; perl mysql-test-run.pl


Please report any problems at http://bugs.mysql.com/


7. 启动数据库
[[email protected] local]# mysqld_safe --defaults-file=/etc/my.cnf &
[1] 7666
[[email protected] local]# 140612 14:46:33 mysqld_safe Logging to '/data/mysql/mysql_3306/data/error.log'.
140612 14:46:33 mysqld_safe Starting mysqld daemon with databases from /data/mysql/mysql_3306/data




8. 连接MSYQL, 修改ROOT密码。第一次登录是不需要密码的。 这样MYSQL就安装成功了。 
[[email protected] local]# mysql -uroot -p -S /tmp/mysql.sock 
Enter password: 
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.


(testing)[email protected] [(none)]> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "vipshop";
Query OK, 0 rows affected (0.00 sec)




(testing)[email protected] [(none)]> use mysql;
Database changed
(testing)[email protected] [mysql]> update user set password = password('vipshop') where user='root';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 5  Changed: 4  Warnings: 0


(testing)[email protected] [mysql]> commit;
Query OK, 0 rows affected (0.00 sec)


(testing)[email protected] [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)


(testing)[email protected] [mysql]> exit
Bye
[[email protected] local]# mysql -uroot -p -S /tmp/mysql.sock 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
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.


(testing)[email protected] [(none)]> 
  相关解决方案