91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux在DB運維時常用的命令有哪些

發布時間:2021-11-02 17:05:43 來源:億速云 閱讀:134 作者:小新 欄目:MySQL數據庫

這篇文章主要介紹了linux在DB運維時常用的命令有哪些,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

  1. # cat /etc/issue

  2. CentOS release 6.5 (Final)

  3. Kernel \r on an \m

我使用的測試機是CentOS 6.5,目前比較流行的linux發行版本有:

  1. Red Hat   http://www.redhat.com (目前企業版最佳版本,不過商業服務收費,對操作系統安全負責)

  2. Fedora        http://fedoraproject.org (Red Hat的開發版本,更新速度快)

  3. Mandriva      http://mandriva.com

  4. Novell SuSE     http://novell.com/linux

  5. Debian          http://debian.org

  6. Slackware       http://slackware.com

  7. Gentoo          http://gentoo.org (性能較好)

  8. Ubuntu          http://ubuntu.com (基于Debian)

  9. CentOS          http://centos.org (免費服務器版本,意思就是專業盜版Red Hat,記住專業)

  10. Ubuntu Kylin    http://www.ubuntukylin.com (國產版本,基于Ubuntu,現在16.04貌似很友好)

  11. Deepin         https://www.deepin.org/ (國內第一個基于Debian的系統,社區支持相當友好發布了很多國內軟件的linux版本,Ubuntu、Ubuntu Kylin都是其受益者,這個情操給滿分)

其次,我們肯定要看看CPU、硬盤大小、內存這些硬件信息了啥

  1. 查看CPU信息(型號)

  2. # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c

  3. 4  Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz          E5410   @ 2.33GHz

  4. (看到有8個邏輯CPU, 也知道了CPU型號)

  5. # cat /proc/cpuinfo | grep physical | uniq -c

  6. 4 physical id : 0 

  7. 4 physical id : 1 

  8. (說明實際上是兩顆4核的CPU)

  9. # getconf LONG_BIT

  10. 64

  11. (說明當前CPU運行在32bit模式下, 但不代表CPU不支持64bit)

  12. # cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

  13. 4

  14. (結果大于0, 說明支持64bit計算. lm指long mode, 支持lm則是64bit)

  15. 查看機器型號 
    # dmidecode | grep "Product Name"

  16. 查看網卡信息 
    # dmesg | grep -i eth

  17. # df -lh
    Filesystem                    Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root   50G  7.2G   40G  16% /
    tmpfs                         1.9G   68K  1.9G   1% /dev/shm
    /dev/sda1                     485M   40M  421M   9% /boot
    /dev/mapper/VolGroup-lv_home   49G  7.8G   39G  17% /home

目前市面上CPU基本都是x86和PowerPC吧,特定機器可能會使用Sun公司的SPARC系列。
CPU內部含有微指令集,不同的微指令集會導致CPU工作效率的優勢
CPU的頻率:CPU每秒鐘可以進行的工作次數
CPU頻率3.0G表示這個CPU在一秒內可以進行3.0*10^9次工作
所以主頻高的CPU性能不一定就好,還要看微指令集。

機器到手,最后最重要肯定是要有網絡啥,不然玩不轉呀。

  1. ifconfig

  2. eth0      Link encap:Ethernet  HWaddr 00:50:56:B3:6B:6D

  3.           inet addr:172.15.11.73  Bcast:172.15.11.255 Mask:255.255.255.0

  4.           inet6 addr: fe80::250:56ff:feb3:6b6d/64 Scope:Link

  5.           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

  6.           RX packets:40487206 errors:0 dropped:0 overruns:0 frame:0

  7.           TX packets:791120 errors:0 dropped:0 overruns:0 carrier:0

  8.           collisions:0 txqueuelen:1000

  9.           RX bytes:5193260758 (4.8 GiB) TX bytes:296331233 (282.6 MiB)


  10. linux設置靜態IP

  11. cd /etc/sysconfig/network-scripts/

  12. #vim ifcfg-eth0

  13. DEVICE=eth0

  14. HWADDR=00:50:56:B0:07:B6

  15. TYPE=Ethernet

  16. UUID=ceb36fa0-487e-4f8a-bba1-9f94728086e5

  17. ONBOOT=yes

  18. NM_CONTROLLED=yes

  19. BOOTPROTO=static

  20. IPADDR=192.168.6.203

  21. NETMASK=255.255.255.0

  22. GATEWAY=192.168.6.2

  23. DNS1=192.168.0.5

linux卸載多余啟動項
第一種方法
1.首先列出系統中正在使用的內核: 
# uname -a 
2.查詢系統中全部的內核: 
# rpm -qa | grep kernel 
3.將你想刪除的內核刪除掉:(例如,在我的系統中,我要刪掉kernel-2.6.32-279.9.1.el6.x86_64的內核,需要把所有含有kernel-2.6.32-279.9.1.el6.x86_64字樣的全部刪掉) 
#yum remove kernel-2.6.32-279.9.1.el6.x86_64 
4.重啟后就可以看到,內核被刪掉了,同時多余的啟動項也自動被刪掉了。 
第二種方法 
手動修改/boot/grub/menu.lst   把多余的項刪除。

linux刷新內存
清除頁面緩存

  1. # sync; echo 1 > /proc/sys/vm/drop_caches

清除目錄項和inode  

  1. # sync; echo 2 > /proc/sys/vm/drop_cachesc 

清除頁面換粗 目錄項和inode

  1. # sync; echo 3 > /proc/sys/vm/drop_caches

swap清理

  1. swapoff -a && swapon -a


干完上面的事,就來說我們要來完成的編譯安裝percona的任務了
首先是下載到最新的安裝包

  1. #cd /home

  2. # wget http://jaist.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz

  3. # wget xxxx.cmake-3.3.2.tar.gz

  4. # wget xxxx.percona-server-5.7.13-6.tar.gz

  5. # wget xxxx/lib_mysqludf_sys-master.zip

下載這么多安裝,說明一下
MySQL currently requires boost_1_59_0
CMake 2.8.2 higher
這兩個是編譯percona-server-5.7.13-6的硬性要求,不然不給編譯
CMake和boost_1_59_0安裝編譯都是很簡單
CMake新的發行版本可能已經很高了,編譯安裝之前可以先查看一下,比CMake 2.8.2更新的版本可以不用安裝也行了。

  1. # cmake --version

  2. cmake version 2.8.12.2

  1. CMake:

  2. # ./bootstrap

  3. # make&&make install

  4. boost_1_59_0:

  5. #tar -zxvf boost_1_59_0.tar.gz

  6. #mv  boost_1_59_0  /usr/local/boost

  7. # cd  /usr/local/boost

  8. # ./bootstrap.sh

  9. # ./b2

boost_1_59_0這個很傷,這個包好像很大,不過官方版本就集成boost_1_59_0的源碼,percona好像還沒。
照著前面寫的步驟,然后慢慢的等就得了。這個編譯坑,沒個進度條。
gcc.compile.c++ bin.v2/libs/wave/build/gcc-4.4.7/release/link-static/threading-multi/cpplexer/re2clex/cpp_re.o
gcc.archive bin.v2/libs/wave/build/gcc-4.4.7/release/link-static/threading-multi/libboost_wave.a
common.copy stage/lib/libboost_wave.a
...failed updating 56 targets...
...skipped 6 targets...
...updated 1069 targets...
當完成到這一步就證明已經完成了boost_1_59_0的安裝,這些都是準備工作。
現在來正式開始安裝percona-server-5.7.13-6
①Set timezone(設置服務器的時區:亞洲上海)

  1. #Set timezone(設置服務器的時區:亞洲上海)

  2. rm -rf /etc/localtime

  3. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  4. ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime(這個是美帝時間額)

  5. # ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
    # date
    Tue Aug  9 02:11:37 EDT 2016
    # ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    # date
    Tue Aug  9 14:11:47 CST 2016

②Remove MySQL if exists mysql (刪除服務器上已存在MySQL,切記數據庫備份)
service mysql stop
rpm -qa|grep mysql
rpm -e mysql
yum -y remove mysql-server mysql mysql-libs
因為很多機器到手的時候可能被yum安裝了數據庫,這個的提前處理一下
③常用依賴安裝
centos:
yum -y install patch make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils
debian:
yum -y install build-essential gcc g++ make cmake autoconf automake re2c wget cron bzip2 libzip-dev libc6-dev file rcconf flex vim nano bison m4 gawk less make cpp binutils diffutils unzip tar bzip2 libbz2-dev libncurses5 libncurses5-dev libtool libevent-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlibc openssl libsasl2-dev libxml2 libxml2-dev libltdl3-dev libltdl-dev libmcrypt-dev zlib1g zlib1g-dev libbz2-1.0 libbz2-dev libglib2.0-0 libglib2.0-dev libpng3 libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libjpeg-dev libpng-dev libpng12-0 libpng12-dev curl libcurl3 libmhash3 libmhash-dev libpq-dev libpq5 gettext libncurses5-dev libcurl4-gnutls-dev libjpeg-dev libpng12-dev libxml2-dev zlib1g-dev libfreetype6 libfreetype6-dev libssl-dev libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev mcrypt libcap-dev diffutils ca-certificates debian-keyring debian-archive-keyring
ubuntu:
apt-get -yf install build-essential gcc g++ make cmake automake autoconf re2c wget cron bzip2 libzip-dev libc6-dev file rcconf flex vim nano bison m4 gawk less make cpp binutils diffutils unzip tar bzip2 libbz2-dev unrar p7zip libncurses5-dev libncurses5 libncurses5-dev libncurses5-dev libtool libevent-dev libpcre3 libpcre3-dev libpcrecpp0  libssl-dev zlibc openssl libsasl2-dev libltdl3-dev libltdl-dev libmcrypt-dev zlib1g zlib1g-dev libbz2-1.0 libbz2-dev libglib2.0-0 libglib2.0-dev libpng3 libjpeg62 libjpeg62-dev libjpeg-dev libpng-dev libpng12-0 libpng12-dev curl libcurl3 libmhash3 libmhash-dev libpq-dev libpq5 gettext libncurses5-dev libcurl4-gnutls-dev libjpeg-dev libpng12-dev libxml2-dev zlib1g-dev libfreetype6 libfreetype6-dev libssl-dev libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev mcrypt libcap-dev diffutils ca-certificates debian-keyring debian-archive-keyring

依賴很多,不一定每個都會用到,不過也沒有就當更新一下軟件吧
④MySQL賬戶創建
groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql

⑤創建MySQL數據庫存放目錄,日志目錄也要單獨給磁盤這樣I/O分開壓力會小一些,這里就放一起了
mkdir -p /home/database
chown -R mysql:mysql /home/database

⑥預編譯camke
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  -DSYSCONFDIR=/etc \
  -DENABLED_PROFILING=1 \
  -DMYSQL_DATADIR=/home/database \
  -DMYSQL_TCP_PORT=3306 \
  -DWITH_MYISAM_STORAGE_ENGINE=1 \
  -DWITH_PARTITION_STORAGE_ENGINE=1 \
  -DWITH_CSV_STORAGE_ENGINE=1 \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_EXTRA_CHARSETS=gbk,gb2312,utf8,ascii,utf8mb4 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDEFAULT_CHARSET=utf8 \
  -DENABLED_LOCAL_INFILE=1 \
  -DWITH_EDITLINE=bundled \
  -DWITH_ZLIB=system \
  -DWITH_BOOST=/usr/local/boost

  1. 如果之前有出錯先清理錯誤編譯日志

  2. make clean

  3. rm CMakeCache.txt

  4. 完成這個步驟后,再cmake

  5. cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

  6.   -DSYSCONFDIR=/etc \

  7.   -DENABLED_PROFILING=1 \

  8.   -DMYSQL_DATADIR=/home/database \

  9.   -DMYSQL_TCP_PORT=3306 \

  10.   -DWITH_MYISAM_STORAGE_ENGINE=1 \

  11.   -DWITH_PARTITION_STORAGE_ENGINE=1 \

  12.   -DWITH_CSV_STORAGE_ENGINE=1 \

  13.   -DWITH_INNOBASE_STORAGE_ENGINE=1 \

  14.   -DWITH_EXTRA_CHARSETS=gbk,gb2312,utf8,ascii,utf8mb4 \

  15.   -DDEFAULT_COLLATION=utf8_general_ci \

  16.   -DDEFAULT_CHARSET=utf8 \

  17.   -DENABLED_LOCAL_INFILE=1 \

  18.   -DWITH_EDITLINE=bundled \

  19.   -DWITH_ZLIB=system \

  20.   -DWITH_BOOST=/usr/local/boost

  21. -- INSTALL perconaserverclient.pc lib/pkgconfig

  22. -- CMAKE_BUILD_TYPE: RelWithDebInfo

  23. -- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H

  24. -- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement

  25. -- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter

  26. -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF

  27. -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -D_FORTIFY_SOURCE=2 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF

  28. -- Configuring done

  29. -- Generating done

  30. -- Build files have been written to: /home/percona-server-5.7.13-6

⑦編譯
開始編譯安裝
make -j`grep processor /proc/cpuinfo | wc -l` && make install
這個100%安裝完成后
cp support-files/my-default.cnf /etc/my.cnf
ln -sf /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -sf /usr/local/mysql/include/mysql /usr/include/mysql
ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe
這里搞這么多鏈接,也是為了不搞環境變量
cp support-files/mysql.server /etc/init.d/mysql
chmod 700 /etc/init.d/mysql
chkconfig --add mysql 
chkconfig --level 35 mysql on
進去修改一下這兩個,其余的就是配置文件的事情了,這里暫時不討論
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /home/database
# port = .....
# server_id = .....
# socket = .....
⑧初始化數據庫,并啟動數據庫修改掉隨機密碼
安裝完成后,初始化數據庫

  1. [root@DB-73 mysql]# rm -rf /home/database/*

  2. [root@DB-73 mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/home/database

  3. 2016-08-05T07:21:48.113959Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

  4. 2016-08-05T07:21:48.114054Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.

  5. 2016-08-05T07:21:48.114066Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.

  6. 2016-08-05T07:21:53.194657Z 0 [Warning] InnoDB: New log files created, LSN=45790

  7. 2016-08-05T07:21:54.195562Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

  8. 2016-08-05T07:21:54.469438Z 0 [Warning] No existing UUID has been found, so we assume that this is the

  9. first time that this server has been started. Generating a new UUID: 4941b58f-5add-11e6-8c4c-005056b36b6d.

  10. 2016-08-05T07:21:54.500735Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.

  11. 2016-08-05T07:21:54.502227Z 1 [Note] A temporary password is generated for root@localhost: aXx!

# /etc/init.d/mysql start
Starting MySQL (Percona Server).. [ OK ]
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.13-6
Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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.
mysql> use mysql;
mysql> alter user 'root'@'localhost' identified by 'jiayifei';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>quit
⑨加裝UDF
# cat lib_mysqludf_sys-master/lib_mysqludf_sys.sql

  1. [root@DB-73 lib_mysqludf_sys-master]# gcc -DMYSQL_DYNAMIC_PLUGIN -fPIC -Wall -I/usr/local/mysql/include -I. -shared lib_mysqludf_sys.c -o /usr/local/mysql/lib/mysql/plugin/lib_mysqludf_sys.so

  2. [root@DB-73 lib_mysqludf_sys-master]# mysql -uroot -p

  3. Enter password:

  4. Welcome to the MySQL monitor. Commands end with ; or \g.

  5. Your MySQL connection id is 4

  6. Server version: 5.7.13-6 Source distribution


  7. Copyright (c) 2009-2016 Percona LLC and/or its affiliates

  8. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


  9. Oracle is a registered trademark of Oracle Corporation and/or its

  10. affiliates. Other names may be trademarks of their respective

  11. owners.


  12. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


  13. mysql> DROP FUNCTION IF EXISTS lib_mysqludf_sys_info;

  14. Query OK, 0 rows affected, 1 warning (0.00 sec)


  15. mysql> DROP FUNCTION IF EXISTS sys_get;

  16. Query OK, 0 rows affected, 1 warning (0.00 sec)

  17. ......

⑩#添加防火墻
防火墻的3306端口默認沒有開啟,若要遠程訪問,需要開啟這個端口
打開/etc/sysconfig/iptables
在“-A INPUT –m state --state NEW –m tcp –p –dport 22 –j ACCEPT”,下添加:
-A INPUT -m state --state NEW -m tcp -p -dport 3306 -j ACCEPT
然后保存,并關閉該文件,在終端內運行下面的命令,刷新防火墻配置:
service iptables restart CentOS 7中默認使用Firewalld做防火墻,所以修改iptables后,在重啟系統后,根本不管用。
Firewalld中添加端口方法如下:
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

感謝你能夠認真閱讀完這篇文章,希望小編分享的“linux在DB運維時常用的命令有哪些”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

长沙县| 泾川县| 柘荣县| 吉木萨尔县| 太谷县| 德化县| 武邑县| 景泰县| 于都县| 岢岚县| 湛江市| 石台县| 吐鲁番市| 安龙县| 瑞安市| 吴忠市| 连城县| 合水县| 琼中| 横峰县| 米易县| 汉中市| 娄烦县| 鹤岗市| 资中县| 东方市| 余庆县| 西充县| 湘乡市| 秭归县| 邳州市| 磐安县| 泽普县| 吉木乃县| 昌都县| 简阳市| 平邑县| 和顺县| 绥德县| 定远县| 紫云|