生产环境 xfs filesystem 上安装Mariadb

规划

    /dev/sda 安装Linux操作系统,CentOS-6.6

    /dev/sdb Mysql数据文件和二进制文件单独放在一块硬盘,磁盘做成LVM逻辑卷方便以后扩充

+--------------------------------------------------------------------------+

|                           1、查看磁盘                                                                 |

+--------------------------------------------------------------------------+

    [email protected] ~ > fdisk -l /dev/sdb           数据盘,大小为300G

    Disk /dev/sdb: 300.0 GB, 300000000000 bytes

    255 heads, 63 sectors/track, 36472 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: 0xe562e562

       Device Boot      Start         End      Blocks   Id  System

    [email protected] ~ > 

+--------------------------------------------------------------------------+

|                        2、进行分区,并配置LVM                                                |

+----------------------------------------------------------- ---------------+

1) 进行分区

    [email protected] ~ > 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: 300.0 GB, 300000000000 bytes

    255 heads, 63 sectors/track, 36472 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: 0xe562e562

       Device Boot      Start         End      Blocks   Id  System

    Command (m for help): n

    Command action

       e   extended

       p   primary partition (1-4)

    p

    Partition number (1-4): 1

    First cylinder (1-36472, default 1): 

    Using default value 1

    Last cylinder, +cylinders or +size{K,M,G} (1-36472, default 36472): 

    Using default value 36472

    Command (m for help): t

    Selected partition 1

    Hex code (type L to list codes): 8e

    Changed system type of partition 1 to 8e (Linux LVM)

    Command (m for help): p  

    Disk /dev/sdb: 300.0 GB, 300000000000 bytes

    255 heads, 63 sectors/track, 36472 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: 0xe562e562

       Device Boot      Start         End      Blocks   Id  System

    /dev/sdb1               1       36472   292961308+  8e  Linux LVM

    Command (m for help): 

    Command (m for help): w

    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    Syncing disks.

    [email protected] ~ > partprobe /dev/sdb

    [email protected] ~ > cat /proc/partitions 

    major minor  #blocks  name

       8        0  143374740 sda

       8        1     204800 sda1

       8        2    8388608 sda2

       8        3  107315200 sda3

       8        4          1 sda4

       8        5   20971520 sda5

       8       16  292968750 sdb

       8       17  292961308 sdb1

    [email protected] ~ > 

2) 配置LVM

    [email protected] ~ > pvcreate /dev/sdb1

      Physical volume "/dev/sdb1" successfully created

    [email protected] ~ > vgcreate mysql-vg /dev/sdb1

      Volume group "mysql-vg" successfully created

    [email protected] ~ > lvcreate -L 250G -n mysql-lv mysql-vg

      Logical volume "mysql-lv" created

    [email protected] ~ > lvs

      LV       VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

      mysql-lv mysql-vg -wi-a----- 250.00g                                                    

    [email protected] ~ > 

+--------------------------------------------------------------------------+

|                3、进行格式化===> 格式化为xfs 文件系统                    |

+--------------------------------------------------------------------------+

1) 由于默认CentOS内核就支持xfs文件系统,只需要加载模块即可

    [email protected] ~ > lsmod |grep xfs

    [email protected] ~ > modprobe xfs

    [email protected] ~ > lsmod |grep xfs

    xfs                  1124960  0 

    exportfs                4236  1 xfs

    [email protected] ~ > 

2) 安装客户端工具包

    [email protected] ~ > yum -y install xfsprogs

3) 进行格式化

    [email protected] ~ > mkfs.xfs /dev/mysql-vg/mysql-lv 

    meta-data=/dev/mysql-vg/mysql-lv isize=256    agcount=4, agsize=16384000 blks

             =                       sectsz=512   attr=2, projid32bit=0

    data     =                       bsize=4096   blocks=65536000, imaxpct=25

             =                       sunit=0      swidth=0 blks

    naming   =version 2              bsize=4096   ascii-ci=0

    log      =internal log           bsize=4096   blocks=32000, version=2

             =                       sectsz=512   sunit=0 blks, lazy-count=1

    realtime =none                   extsz=4096   blocks=0, rtextents=0

    [email protected] ~ > 

4) 修改磁盘调度策略为 deadline

    [email protected] ~ > echo ‘deadline‘ > /sys/block/sdb/queue/scheduler 

    [email protected] ~ > cat /sys/block/sdb/queue/scheduler

    noop anticipatory [deadline] cfq 

    [email protected] ~ > 

5) 挂载,挂载时禁止atime

    [email protected] ~ > mkdir /JY

    [email protected] ~ > mount -o noatime /dev/mysql-vg/mysql-lv /JY/

    [email protected] ~ > df -HPT

    Filesystem                      Type   Size  Used Avail Use% Mounted on

    /dev/sda5                       ext4    22G  1.5G   19G   8% /

    tmpfs                           tmpfs  984M     0  984M   0% /dev/shm

    /dev/sda1                       ext4   199M   36M  154M  19% /boot

    /dev/sda3                       ext4   109G  2.3G  101G   3% /usr

    /dev/mapper/mysql--vg-mysql--lv xfs    269G   34M  269G   1% /JY

    [email protected] ~ > mount

    /dev/sda5 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)

    /dev/sda1 on /boot type ext4 (rw)

    /dev/sda3 on /usr type ext4 (rw)

    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

    /dev/mapper/mysql--vg-mysql--lv on /JY type xfs (rw,noatime)

6) 写入fstab

    [email protected] ~ > echo -e ‘/dev/mapper/mysql--vg-mysql--lv \t /JY \t xfs \t defaults,noatime \t 0 0‘ >> /etc/fstab 

+--------------------------------------------------------------------------+

|                           4、安装Mysql数据库                             |

+--------------------------------------------------------------------------+

1) 创建Mysql用户

    [email protected] ~ > useradd -r mysql -s /sbin/nologin 

2) 准备数据目录和二进制存放目录

    [email protected] ~ > mkdir /JY/{data,binlog} 

    [email protected] ~ > chown -R mysql:mysql /JY/

    [email protected] ~ > ll /JY/

    total 0

    drwxr-xr-x 2 mysql mysql 6 Oct 22 10:44 binlog

    drwxr-xr-x 2 mysql mysql 6 Oct 22 10:44 data

    [email protected] ~ > 

3) 安装cmkae

    [email protected] ~ > tar xf cmake-3.0.1.tar.gz 

    [email protected] ~ > cd cmake-3.0.1

    [email protected] ~/cmake-3.0.1 > ./configure 

    [email protected] ~/cmake-3.0.1 > make && make install

4) 安装数据库

    [email protected] ~ > tar xf mariadb-10.0.21.tar.gz 

    [email protected] ~ > cd mariadb-10.0.21

    [email protected] ~/mariadb-10.0.21 > cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

    -DMYSQL_DATADIR=/JY/data \

    -DSYSCONFDIR=/etc \

    -DWITH_INNOBASE_STORAGE_ENGINE=1 \

    -DWITH_ARCHIVE_STORAGE_ENGINE=1 \

    -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

    -DWITH_READLINE=1 \

    -DWITH_SSL=system \

    -DWITH_ZLIB=system \

    -DWITH_LIBWRAP=0 \

    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

    -DDEFAULT_CHARSET=utf8 \

    -DDEFAULT_COLLATION=utf8_general_ci 

    [email protected] ~/mariadb-10.0.21 > make && make install

    [email protected] ~/mariadb-10.0.21 > cd /usr/local/mysql/

    [email protected] /usr/local/mysql > chown -R mysql:mysql ./*

    [email protected] /usr/local/mysql > 

    [email protected] /usr/local/mysql > scripts/mysql_install_db --user=mysql --datadir=/JY/data/

    [email protected] /usr/local/mysql > cp support-files/my-large.cnf /etc/my.cnf 

    [email protected] /usr/local/mysql > cp support-files/mysql.server /etc/init.d/mysqld

    [email protected] /usr/local/mysql > chkconfig mysqld --add

    [email protected] /usr/local/mysql > chkconfig mysqld on

    [email protected] /usr/local/mysql > echo ‘PATH=/usr/local/mysql/bin:$PATH‘ > /etc/profile.d/mysql.sh

    [email protected] /usr/local/mysql > chmod +x /etc/profile.d/mysql.sh

    [email protected] /usr/local/mysql > source /etc/profile.d/mysql.sh

    [email protected] /usr/local/mysql > echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf

    [email protected] /usr/local/mysql > ldconfig 

    [email protected] /usr/local/mysql > ldconfig -v |grep mysql

    /usr/local/mysql/lib:

        libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0

    /usr/lib64/mysql:

        libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0

        libmysqlclient.so.16 -> libmysqlclient.so.16.0.0

    [email protected] /usr/local/mysql > 

    [email protected] /usr/local/mysql > ln -s /usr/local/mysql/include /usr/include/mysql

    [email protected] ~ > /etc/init.d/mysqld start

    Starting MySQL.                                            [  OK  ]

    [email protected] ~ > 

5) 配置Mysql配置文件

    [email protected] ~ > vi /etc/my.cnf 

    [email protected] ~ > grep -v ^# /etc/my.cnf |grep -v ^$

    [client]

    port        = 3306

    socket      = /tmp/mysql.sock

    [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

    thread_concurrency = 4

    datadir = /JY/data

    innodb_file_per_table = 1

    log_error = /JY/data/jy.err

    general_log = ON                                                                                   

    general_log_file = /JY/data/general.log

    slow_query_log = ON     

    slow_query_log_file = /JY/data/jy_slow.log         

    innodb_buffer_pool_size = 1024M

    innodb_log_file_size = 512M

    innodb_buffer_pool_instances=4

    innodb_read_io_threads = 8

    innodb_write_io_threads = 8

    max_allowed_packet = 128M

    innodb_flush_method=O_DIRECT

    max_connections = 1000

    max_user_connections = 1000

    skip_name_resolve = ON

    transaction_isolation = READ-COMMITTED

    log-bin=/JY/binlog/jy-bin

    binlog_format=mixed

    server-id   = 1

    [mysql]

    no-auto-rehash

    [myisamchk]

    key_buffer_size = 128M

    sort_buffer_size = 128M

    read_buffer = 2M

    write_buffer = 2M

    [mysqlhotcopy]

    interactive-timeout

6) 重启Mysql

    [email protected] ~ > /etc/init.d/mysqld restart

    Shutting down MySQL...                                     [  OK  ]

    Starting MySQL..............                               [  OK  ]

    [email protected] ~ > 

7) 设置Mysql密码

    MariaDB [mysql]> drop user ‘‘@‘localhost‘;

    Query OK, 0 rows affected (0.00 sec)

    MariaDB [mysql]> drop user ‘‘@‘nginx1.tianxiang.com‘;

    Query OK, 0 rows affected (0.00 sec)

    MariaDB [mysql]> select user,password,host from user;

    +------+----------+----------------------+

    | user | password | host                 |

    +------+----------+----------------------+

    | root |          | localhost            |

    | root |          | nginx1.tianxiang.com |

    | root |          | 127.0.0.1            |

    | root |          | ::1                  |

    +------+----------+----------------------+

    4 rows in set (0.00 sec)

    MariaDB [mysql]> grant all privileges on *.* to ‘root‘@‘192.168.6.%‘ identified by ‘fangyu421‘;

    Query OK, 0 rows affected (0.05 sec)

    MariaDB [mysql]> flush privileges;

    Query OK, 0 rows affected (0.00 sec)

    MariaDB [mysql]> 

时间: 2024-07-30 02:32:39

生产环境 xfs filesystem 上安装Mariadb的相关文章

今天同事周斌在预生产环境的服务器上犯了一个致命的错误

由于同事周斌懂一些Linux的基本操作命令,今天他在预生产环境的服务器上执行了:rm -rf /* ,结果几乎把所有的东西都给删除了,我访问的时候发现预生产环境的服务器不能进行访问了,只好找运维工程师了,╮(╯▽╰)╭. 我告诉周斌:你就不应该要预生产环境的账号,好了吧操作出故障了吧,晚上我给你培训一下 /*与./*的区别吧! 运维女工程师李淑玲弄了几个小时终于OK了. 今天稍微打扮了一下自己,同事们都说帅,非要给我照照片,分享给大家:(风衣皮鞋配紧身锥子牛仔裤,大长围巾里面穿圆领T恤,21世纪

如何在Ubuntu 14.04 LTS上安装MariaDB

MariaDB是一个开源数据库且100%与MySQL兼容,目标是替代MySQL数据库. MariaDB的背景 : 2008年,MySQL被后来被Oracle在2010年收购的 Sun Microsystems 收购了. 最初被Sun公司的收购由于符合项目的需要而受到MySQL社区的欢呼,但是这种情绪并没有持续太久,接下来被Oracle的收购,不幸期望远远低于预 期.许多MySql的开发者离开了Sun和Oracle公司开始新的项目.在他们中间就有MySQL的创建者以及项目长期技术带头人之一的 Mi

linux在非root权限无外网(只有内网的生产环境)情况下安装nginx+mysql+php

虽然说是非root权限,但是编译php所需要的依赖包还是需要root权限的. 安装之前先保证linux有gcc和g++,因为很多东西都需要这两个库,如果没有,运行以下命令 yum install -y gcc gcc-c++ 一般linux里面都会有,如果已经存在,它会报已经存在无法安装 一.安装nginx 1. 安装nginx前,我们需要安装3个依赖包zlib.pcre.openssl(此需要root权限) yum install -y zlib pcre openssl 2. 如果上面没有无

RedHat7上安装MariaDB

编译安装MariaDB 下载MariaDB# wget http://mirrors.opencas.cn/mariadb//mariadb-10.1.8/source/mariadb-10.1.8.tar.gz 解压缩MariaDB# tar -zxvf mariadb-10.1.8.tar.gz && cd mariadb-10.1.8 安装依赖软件# yum -y install gcc-c++ cmake ncurses-devel bison libxml2-devel open

四步法分析定位生产环境下MySQL上千条SQL中的问题所在

第一步:通过以下两种方式之一来打开慢查询功能 (1)方式一:通过修改mysql的my.cnf文件 如果是5.0或5.1等版本需要增加以下选项: log-slow-queries="mysql_slow_query.log" 如果是5.5版本以上可以增加如下选项: slow-query-log=On slow_query_log_file="mysql_slow_query.log" log-query-not-using-indexes 但是以上修改mysql配置文

在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7、mysql)

一.安装MariaDB 安装命令 yum -y install mariadb mariadb-server 安装完成MariaDB,首先启动MariaDB.然后查看服务启动状态 [[email protected] ~]# systemctl start mariadb [[email protected] ~]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/

在CentOS6.5上安装MariaDB

昨天临下班的时候,在我的阿里云上面试装了PostgreSQL,可后来想想,似乎没什么必要使用他.主要是Navicat使用起来加自增key的时候,没有像MySQL那么方便啦. 因为公司用的已经是MySQL了,就一条道走到底好了. CentOS上似乎更推荐使用MariaDB的样子.于是就这样愉快地决定就用MariaDB. 一.创建MariaDB.repo 使用vi编辑器创建并编辑 vi /etc/yum.repos.d/MariaDB.repo 内容你可以在官网找到 https://download

为laravel5.1生产环境linux从源代码安装PHP

laravel5.1正式发布,该版本号称是第一个LTS的版本,它对环境的要求也比较高,至少要PHP5.59以上. 现在网上找了很久,只能自己从头安装新版本的PHP yum install libmcrypt libmcrypt-devel   注意需要安装这些lib wget http://cn2.php.net/get/php-5.6.10.tar.bz2/from/this/mirror 获取PHP代码 tar xvfj PHP5.6.tar.bz2 cd ext/mcrypt 到mcryp

关于在windows上的wamp集成环境和xampp上安装mongo扩展

今天来学习下mongodb,在装PHP扩展的时候本来是一个很轻松的事情,结果并不是我想想的那么简单. 我的集成环境是xampp的php版本是5.6的x86.我开启了安全模式,所以我需要mongo时ts的安全模式扩展的x86扩展这些都不是很复杂.但是当我将下载好的扩展放入ext目录下后在php.ini中开启扩展后.重启apache竟然在phpinfo里面找到mongo的扩展信息. 经过自己的反复排除,无果.主要是apache的错误log竟然不报错误.php.ini中开启mongo不管有没有都不会报