生产环境 xfs filesystem 上安装Mariadb_MySQL
规划
/dev/sda 安装Linux操作系统,CentOS-6.6
/dev/sdb Mysql数据文件和二进制文件单独放在一块硬盘,磁盘做成LVM逻辑卷方便以后扩充
+--------------------------------------------------------------------------+
| 1、查看磁盘 |
+--------------------------------------------------------------------------+
root@nginx1 ~ > 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
root@nginx1 ~ >
+--------------------------------------------------------------------------+
|2、进行分区,并配置LVM|
+----------------------------------------------------------- ---------------+
1) 进行分区
root@nginx1 ~ > 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.
root@nginx1 ~ > partprobe /dev/sdb
root@nginx1 ~ > cat /proc/partitions
major minor #blocks name
80 143374740 sda
81 204800 sda1
828388608 sda2
83 107315200 sda3
84 1 sda4
85 20971520 sda5
8 16 292968750 sdb
8 17 292961308 sdb1
root@nginx1 ~ >
2) 配置LVM
root@nginx1 ~ > pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
root@nginx1 ~ > vgcreate mysql-vg /dev/sdb1
Volume group "mysql-vg" successfully created
root@nginx1 ~ > lvcreate -L 250G -n mysql-lv mysql-vg
Logical volume "mysql-lv" created
root@nginx1 ~ > lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
mysql-lv mysql-vg -wi-a----- 250.00g
root@nginx1 ~ >
+--------------------------------------------------------------------------+
|3、进行格式化===> 格式化为xfs 文件系统|
+--------------------------------------------------------------------------+
1) 由于默认CentOS内核就支持xfs文件系统,只需要加载模块即可
root@nginx1 ~ > lsmod |grep xfs
root@nginx1 ~ > modprobe xfs
root@nginx1 ~ > lsmod |grep xfs
xfs 1124960 0
exportfs4236 1 xfs
root@nginx1 ~ >
2) 安装客户端工具包
root@nginx1 ~ > yum -y install xfsprogs
3) 进行格式化
root@nginx1 ~ > mkfs.xfs /dev/mysql-vg/mysql-lv
meta-data=/dev/mysql-vg/mysql-lv isize=256agcount=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
root@nginx1 ~ >
4) 修改磁盘调度策略为 deadline
root@nginx1 ~ > echo 'deadline' > /sys/block/sdb/queue/scheduler
root@nginx1 ~ > cat /sys/block/sdb/queue/scheduler
noop anticipatory [deadline] cfq
root@nginx1 ~ >
5) 挂载,挂载时禁止atime
root@nginx1 ~ > mkdir /JY
root@nginx1 ~ > mount -o noatime /dev/mysql-vg/mysql-lv /JY/
root@nginx1 ~ > df -HPT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda5 ext422G 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 xfs269G 34M 269G 1% /JY
root@nginx1 ~ > 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
root@nginx1 ~ > echo -e '/dev/mapper/mysql--vg-mysql--lv \t /JY \t xfs \t defaults,noatime \t 0 0' >> /etc/fstab
+--------------------------------------------------------------------------+
| 4、安装Mysql数据库 |
+--------------------------------------------------------------------------+
1) 创建Mysql用户
root@nginx1 ~ > useradd -r mysql -s /sbin/nologin
2) 准备数据目录和二进制存放目录
root@nginx1 ~ > mkdir /JY/{data,binlog}
root@nginx1 ~ > chown -R mysql:mysql /JY/
root@nginx1 ~ > 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
root@nginx1 ~ >
3) 安装cmkae
root@nginx1 ~ > tar xf cmake-3.0.1.tar.gz
root@nginx1 ~ > cd cmake-3.0.1
root@nginx1 ~/cmake-3.0.1 > ./configure
root@nginx1 ~/cmake-3.0.1 > make && make install
4) 安装数据库
root@nginx1 ~ > tar xf mariadb-10.0.21.tar.gz
root@nginx1 ~ > cd mariadb-10.0.21
root@nginx1 ~/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
root@nginx1 ~/mariadb-10.0.21 > make && make install
root@nginx1 ~/mariadb-10.0.21 > cd /usr/local/mysql/
root@nginx1 /usr/local/mysql > chown -R mysql:mysql ./*
root@nginx1 /usr/local/mysql >
root@nginx1 /usr/local/mysql > scripts/mysql_install_db --user=mysql --datadir=/JY/data/
root@nginx1 /usr/local/mysql > cp support-files/my-large.cnf /etc/my.cnf
root@nginx1 /usr/local/mysql > cp support-files/mysql.server /etc/init.d/mysqld
root@nginx1 /usr/local/mysql > chkconfig mysqld --add
root@nginx1 /usr/local/mysql > chkconfig mysqld on
root@nginx1 /usr/local/mysql > echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
root@nginx1 /usr/local/mysql > chmod +x /etc/profile.d/mysql.sh
root@nginx1 /usr/local/mysql > source /etc/profile.d/mysql.sh
root@nginx1 /usr/local/mysql > echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
root@nginx1 /usr/local/mysql > ldconfig
root@nginx1 /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
root@nginx1 /usr/local/mysql >
root@nginx1 /usr/local/mysql > ln -s /usr/local/mysql/include /usr/include/mysql
root@nginx1 ~ > /etc/init.d/mysqld start
Starting MySQL.[ OK ]
root@nginx1 ~ >
5) 配置Mysql配置文件
root@nginx1 ~ > vi /etc/my.cnf
root@nginx1 ~ > 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
root@nginx1 ~ > /etc/init.d/mysqld restart
Shutting down MySQL... [ OK ]
Starting MySQL.............. [ OK ]
root@nginx1 ~ >
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]>

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Windows復原環境(WinRE)是用來修復Windows作業系統錯誤的環境。進入WinRE後,您可以執行系統還原、出廠重設、卸載更新等操作。如果無法引導到WinRE,本文將指導您使用修復程式解決此問題。無法引導至Windows復原環境如果無法引導至Windows復原環境,請使用下方提供的修復程式:檢查Windows復原環境的狀態使用其他方法進入Windows復原環境您是否意外刪除了Windows復原分割區?執行Windows的就地升級或全新安裝下面,我們已經詳細解釋了所有這些修復。 1]檢查Wi

在本文中,我們將了解Python和Anaconda之間的差異。 Python是什麼? Python是一種開源語言,非常重視使程式碼易於閱讀並透過縮進行和提供空白來理解。 Python的靈活性和易於使用使其非常適用於各種應用,包括但不限於對於科學計算、人工智慧和數據科學,以及創造和發展的線上應用程式。當Python經過測試時,它會立即被翻譯轉化為機器語言,因為它是一種解釋性語言。有些語言,例如C++,需要編譯才能被理解。精通Python是一個重要的優勢,因為它非常易於理解、開發,執行並讀取。這使得Pyth

在Windows11上設定環境變數可以幫助您自訂系統、執行腳本和設定應用程式。在本指南中,我們將討論三種方法以及逐步說明,以便您可以根據自己的喜好配置系統。有三種類型的環境變數系統環境變數–全域變數處於最低優先權,可由Windows上的所有使用者和應用程式訪問,通常用於定義系統範圍的設定。使用者環境變數–優先順序越高,這些變數僅適用於在該帳戶下執行的目前使用者和進程,並由在該帳戶下執行的使用者或應用程式設定。進程環境變數–具有最高優先權,它們是臨時的,適用於當前進程及其子進程,為程式提供

php整合環境套件有:1、PhpStorm,功能強大的PHP整合環境;2、Eclipse,開放原始碼的整合開發環境;3、Visual Studio Code,輕量級的開源程式碼編輯器;4、Sublime Text,受歡迎的文本編輯器,廣泛用於各種程式語言;5、NetBeans,由Apache軟體基金會開發的整合開發環境;6、Zend Studio,為PHP開發者設計的整合開發環境。

Laravel環境設定檔.env的常見問題及解決方法在使用Laravel框架開發專案時,環境設定檔.env是非常重要的,它包含了專案的關鍵配置信息,如資料庫連接資訊、應用程式金鑰等。然而,有時在配置.env檔案時會出現一些常見問題,本文將針對這些問題進行介紹並提供解決方法,同時附上具體的程式碼範例供參考。問題一:無法讀取.env檔當我們設定好了.env文件

Python是一種高階程式語言,由於它跨平台、簡單易學、功能強大等特性,一些大型公司,如Google、Dropbox等都選擇使用Python進行開發。隨著最近幾年來Web應用程式逐漸成為主流應用,Python也逐漸成為了Web應用程式的首選開發語言。本文將介紹如何在Windows系統上建置PythonWeb開發環境,包含Pyth

go語言環境配置方法:1、下載go語言的編譯器,雙擊運行安裝程式;2、接受許可協議,點選next;3、設定安裝目錄,點選OK;4、安裝完成後,將go安裝目錄下的bin目錄加入環境變數中即可。

一鍵刪除Conda環境:快速清理無用環境的技巧隨著資料科學和機器學習的快速發展,使用Python進行開發和分析的需求也越來越強烈。 Conda作為一種流行的Python套件管理器和環境管理工具,被廣泛應用於專案開發和環境配置中。然而,隨著時間的推移,我們常常會在電腦上留下許多無用的Conda環境,這不僅浪費了磁碟空間,還可能導致環境混亂和不必要的麻煩。本文將介
