作者:小徐
制作时间:20180601
联系方式:xiaoxubigdata@163.com
# cat /etc/inittab
***************
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
0-halt 关机,让init关闭所有进程并关机
1-Single user mode 单用户字符界面,通常又称为s或S
2-Multiuser,without NFS 不具备网络文件系统功能的多用户字符界面
3-Full multiuser mode 具备网络文件系统功能的多用户字符界面
4-unused 保留不用
5-X11 具备网络功能的图形用户界面
6-reboot 关闭所有运行的进程并重新启动系统
启动后进入图形界面,设为3则进入具备网络文件系统功能的多用户字符界面
按照以下标红的进行修改,没有的则添加即可
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.199.50
NETMASK=255.255.255.0
GATEWAY=192.168.199.1
DNS1=192.168.199.1
DNS2=8.8.8.8
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=0ddfc571-6d5d-4d1e-9442-f3ef337e7f12
DEVICE=enp0s3
ONBOOT=yes
# service network restart
# pifconfig
lo
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: host
UP LOOPBACK RUNNING
enp0s3 HWaddr 08:00:27:25:cc:9c
inet addr:192.168.0.50 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::32a8:4a1a:3b8c:4cbd/64 Scope: link
UP BROADCAST RUNNING MULTICAST
临时修改
# hostnamectl set-hostname test-cn-01
永久修改
# vi /etc/sysconfig/network
# Created by anaconda
HOSTNAME=test-cn-01
临时关闭
# setenforce 0
永久关闭
#vi /etc/selinux/config
修改为SELINUX=disabled
修改
# vi /etc/yum/pluginconf.d/refresh-packagekit.conf
添加enabled=0
修改
# vi /etc/security/limits.conf
* soft noproc 10240
* hard noproc 10240
* soft nofile 10240
* hard nofile 10240
# lscpu 或用一下命令
# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz # 配置的详细信息
stepping : 9
microcode : 18
cpu MHz : 2394.639
cache size : 3072 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 2 # 此标识说明服务器是1核的
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx f16c hypervisor lahf_lm arat epb pln pts dts fsgsbase smep
bogomips : 4789.27
clflush size : 64
cache_alignment : 64
address sizes : 42 bits physical, 48 bits virtual
power management:
以下命令是查看所有的磁盘的信息
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0008bfe5
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2350 18566144 83 Linux
/dev/sda3 2350 2611 2097152 82 Linux swap / Solaris
以下是查看某个磁盘的详细信息
# fdisk -l /dev/sda1
# cat /proc/meminfo
MemTotal: 1787468 kB
MemFree: 1149248 kB
Buffers: 764 kB
Cached: 113048 kB
SwapCached: 0 kB
Active: 478212 kB
Inactive: 96940 kB
Active(anon): 461616 kB
Inactive(anon): 8368 kB
Active(file): 16596 kB
Inactive(file): 88572 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2097148 kB
SwapFree: 2097148 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 461360 kB
Mapped: 22596 kB
Shmem: 8644 kB
Slab: 36216 kB
SReclaimable: 11392 kB
SUnreclaim: 24824 kB
KernelStack: 800 kB
PageTables: 3096 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 2990880 kB
Committed_AS: 926184 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 6664 kB
VmallocChunk: 34359709440 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 10176 kB
DirectMap2M: 2086912 kB
实例:sudo ln -s 源文件 目标文件
删除:# rm -rf 源文件
第一种方法
# clear
快捷键的使用
Ctrl + l 清屏快捷键
在机器上关闭防火墙
# service iptables stop
开启开机自关
# chkconfig iptables off
# service mysqld stop
# chkconfig mysqld off
# service network restart
# service httpd restat
Usage: httpd {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}
查看状态
# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
说明是开启的
# vim /etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
付给权限
# chmod +x /etc/rc.d/rc.local
重启机器再次查看THP信息
# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
说明是关闭的
# echo 1772 |awk '{printf("%x\n", $0)}'
6ec
em1是网卡的名字,可以通过ifconfig获取
# ethtool em1
Settings for em1:
Supported ports: [ FIBRE ]
Supported link modes: 1000baseT/Full
10000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: No
Advertised link modes: 10000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 10000Mb/s (表示万M网卡,如果是1000M则表示千M网卡)
Duplex: Full
Port: FIBRE
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000000 (0)
Link detected: yes
# pkill java
或
# killall java
或
# Jps | zargs kill -9
此命令主要用于在系统上查找文件
-x (BSD) -xdev (Linux) :留于同一文件系统 (fstab 中的 dev)
-exec cmd {} \;执行命令并用全路径替换 {}
-iname:同 -name 一样,但不区分大小写
-ls:显示关于文件的信息(同 ls -la)
-size n :n 为 +-n (k M G T P)
-cmin n :查找系统中最后 n 分钟改变文件状态的文件
以下命令是在根目录下查找 tomcat-7.0.88的文件夹
# find / -name tomcat-7.0.88
以下命令表示在/home/user目录下查找最后10分钟创建的文件
# find /home/user/ -cmin 10 -print
主目录中找到所有的 JPEG 文件
# find ~ -name “*jpg”
不分大小写查找文件
# find ~ -iname “*jpg”
查找多个后缀的文件
# find ~ ( -name “*jpg” -o -iname “*jpeg” )
# top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2232 root 20 0 5915768 607124 17240 S 8.6 3.8 4:49.39 java
29719 hbase 20 0 4117880 716964 34732 S 2.7 4.4 0:30.95 java
24265 hdfs 20 0 2967592 342520 28220 S 2.0 2.1 0:16.28 java
81839 oozie 20 0 5798504 497616 39468 S 2.0 3.1 0:21.52 java
30510 ams 20 0 3529116 533008 27036 S 1.7 3.3 0:47.99 java
***************
# printf "%x\n" 2232
8b8
# jstack 2232 | fgrep -A10 8b8
- parking to wait for <0x00000000a339d8b8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.LinkedBlockingDeque.takeFirst(LinkedBlockingDeque.java:492)
at java.util.concurrent.LinkedBlockingDeque.take(LinkedBlockingDeque.java:680)
at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:118)
at org.apache.ambari.server.view.ViewDirectoryWatcher$2.run(ViewDirectoryWatcher.java:112)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
# yum -y install gcc make gcc-c++ openssl-devel flex byacc libpcap ncurses ncurses-devel libpcap-devel
下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
安装前请先把系统默认的安装包卸载掉:
# rpm -qa | grep jdk
# yum -y remove java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el6_8.x86_64
-c : 参数是把软件包解压到制定的目录下
# tar -zxvf jdk-7u80-linux-x64.tar.gz -C /usr/local/
# vi /etc/profile
export JAVA_HOME=/home/jdk1.7
如果遇到Java -version还是系统的配置,请执行以下操作:
# echo $JAVA_HOME
# which java
# mv /usr/bin/java /usr/bin/java_bak
# source /etc/profile
# tar -zxvf apache-tomcat-7.0.69.tar.gz
# vi /etc/profile
export TOMCAT_HOME=/usr/local/apache-tomcat-7.0.69
# source /etc/profile
# tar -zxvf nginx-1.8.1.tar.gz -C /usr/local/
export NGINX_HOME=/usr/local/nginx/sbin
# yum list|grep mysql
Error: Cannot find a valid baseurl for repo: extras
这个问题可能是DNS没有配置好,建议重新配置DNS
vi /etc/resolv.conf
查看是否有rum命令
# rum remove mysql-libs
-bash: rum: command not found
搜索rum软件并安装
# yum list|grep rum
oniguruma.i686 5.9.1-3.1.el6 base
oniguruma.x86_64 5.9.1-3.1.el6 base
oniguruma-devel.i686 5.9.1-3.1.el6 base
oniguruma-devel.x86_64 5.9.1-3.1.el6 base
smc-suruma-fonts.noarch 04.2-11.el6 base
# yum install oniguruma.x86_64
安装mysql
service mysqld stop
yum remove mysql mysql-*
yum list installed | grep mysql
rpm -e --nodeps `rpm -qa | grep mysql`
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum install mysql-community-server
mysql -V
service mysqld start
登录mysql密码为空,直接回车
# mysql -uroot -p
安装下载:链接:http://pan.baidu.com/s/1jIiD3FK 密码:7kwf 或者登陆http://mirrors.sohu.com/mysql/网站下载。 如果无法下载请联系作者。
查看本地的mysql安装包并删除
# yum list|grep mysql*
# yum remove mysql* mysql-*
# yum remove mysq-libs
查看正在使用的内核的版本
# uname -r
2.6.32-431.el6.x86_64
在线下载mysql5.7安装包
# wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-1.el6.i686.rpm-bundle.tar
# chmod a+x mysql-5.7.17-1.el6.i686.rpm-bundle.tar
# tar xvf mysql-5.7.17-1.el6.i686.rpm-bundle.tar
赋给执行的权限
# chmod a+x *.rpm
安装mysql需要的包
# yum localinstall mysql-community-common-5.7.17-1.el6.i686.rpm
# yum localinstall mysql-community-libs-5.7.17-1.el6.i686.rpm
安装客户端
# yum localinstall mysql-community-client-5.7.17-1.el6.i686.rpm
安装服务端
# yum localinstall mysql-community-server-5.7.17-1.el6.i686.rpm
查看版本
# mysql -V
mysql Ver 14.14 Distrib 5.7.17, for Linux (i686) using EditLine wrapper
初始化表
# mysqld -initialize
查看初始的密码
# grep 'temporary password' /var/log/mysqld.log
2017-01-07T04:02:51.271722Z 1 [Note] A temporary password is generated for root@localhost: eqgF_AdFI4Wa
启动mysql
# service mysqld start
登陆mysql
# mysql -uroot -p
// 校验密码的强度。5.7要求用户的密码为复杂。
mysql> set global validate_password_policy=0;
mysql> SET PASSWORD = PASSWORD('123abc,.');
mysql> FLUSH PRIVILEGES;
开启mysql的远程登录权限
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
刷新使之立刻生效
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>grant select,insert,update,delete,create,drop on vtdc.employee to ‘joe@hadoop1’ identified by 'bigdata';
给来自hadoop1的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为bigdata。
mysql>grant all privileges on vtdc.* to ‘joe@hadoop1’ identified by 'bigdata';
给来自hadoop1的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为bigdata。
mysql>grant all privileges on *.* to ‘joe@hadoop1’ identified by 'bigdata';
给来自hadoop1的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为bigdata。
mysql>grant all privileges on *.* to ‘joe@localhost’ identified by 'bigdata';
给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为bigdata。
修改mysql密码
# mysql -uroot -p
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password("123456") where user='root';
Query OK, 5 rows affected (0.01 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> source /user.test.sql
Query OK, 0 rows affected (0.00 sec)
# mysql -uroot -p123456 <scripts-master/db_schema/graph-db-schema.sql
Warning: Using a password on the command line interface can be insecure.
有警告提示,可以忽略,提示密码暴露在外部
# mysql -uroot -p123456 lepus < lepus_table.sql
Warning: Using a password on the command line interface can be insecure.
# mysql -uroot -p123456 lepus < lepus_data.sql
Warning: Using a password on the command line interface can be insecure.
有警告提示,可以忽略,其中lepus 是数据库,lepus_table.sql是表的信息,lepus_data.sql 是表的数据,具体的可以查看:
http://blog.csdn.net/xfg0218/article/details/53207932
http://blog.csdn.net/xfg0218/article/details/53207908
增加用户
用户名是:lepus
密码是:lepus
mysql> insert into mysql.user(Host,User,Password,ssl_cipher,x509_issuer,x509_subject) values('localhost','lepus',password('lepus'),'BLOB','BLOB','BLOB');
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'lepus'@'%' IDENTIFIED BY 'lepus' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
授权模板
mysql> CREATE DATABASE {db-name} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
mysql> GRANT ALL PRIVILEGES ON {db-name}.* TO '{db-user}'@'%' IDENTIFIED BY '{password}';
mysql> GRANT ALL PRIVILEGES ON {db-name}.* TO '{db-user}'@'localhost' IDENTIFIED BY '{password}';
mysql> flush privileges;
# chkconfig mysqld on
# mysql -ulepus -h 192.168.215.154 -p
Enter password:
-u 需要链接的username
-h 需要链接的IP
-p 登录密码
mysql> show global variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port | 3306 |
+---------------+-------+
1 row in set (0.01 sec)
mysql> show global status like 'qcache%';
+-------------------------+-----------+
| Variable_name | Value |
+-------------------------+-----------+
| Qcache_free_blocks | 22756 |
| Qcache_free_memory | 76764704 |
| Qcache_hits | 213028692 |
| Qcache_inserts | 208894227 |
| Qcache_lowmem_prunes | 4010916 |
| Qcache_not_cached | 13385031 |
| Qcache_queries_in_cache | 43560 |
| Qcache_total_blocks | 111212 |
+-------------------------+-----------+
MySQL查询缓存变量解释:
Qcache_free_blocks:缓存中相邻内存块的个数。数目大说明可能有碎片。FLUSH QUERY CACHE会对缓存中的碎片进行整理,从而得到一个空闲块。
Qcache_free_memory:缓存中的空闲内存。
Qcache_hits:每次查询在缓存中命中时就增大
Qcache_inserts:每次插入一个查询时就增大。命中次数除以插入次数就是不中比率。
Qcache_lowmem_prunes:缓存出现内存不足并且必须要进行清理以便为更多查询提供空间的次数。这个数字最好长时间来看;如果这个数字在不断增长,就表示可能碎片非常严重,或者内存很少。(上面的 free_blocks和free_memory可以告诉您属于哪种情况)
Qcache_not_cached:不适合进行MySQL查询缓存变量,通常是由于这些查询不是 SELECT 语句或者用了now()之类的函数。
Qcache_queries_in_cache:当前缓存的查询(和响应)的数量。
Qcache_total_blocks:缓存中块的数量。
我们再查询一下服务器关于query_cache的配置:
mysql> show variables like 'query_cache%';
+------------------------------+-----------+
| Variable_name | Value |
+------------------------------+-----------+
| query_cache_limit | 2097152 |
| query_cache_min_res_unit | 4096 |
| query_cache_size | 203423744 |
| query_cache_type | ON |
| query_cache_wlock_invalidate | OFF |
+------------------------------+-----------+
各字段的解释:
query_cache_limit:超过此大小的查询将不缓存
query_cache_min_res_unit:缓存块的最小大小
query_cache_size:查询缓存大小
query_cache_type:缓存类型,决定缓存什么样的查询,示例中表示不缓存 select sql_no_cache 查询
query_cache_wlock_invalidate:当有其他客户端正在对MyISAM表进行写操作时,如果查询在query cache中,是否返回cache结果还是等写操作完成再读表获取结果。
query_cache_min_res_unit的配置是一柄”双刃剑”,默认是4KB,设置值大对大数据查询有好处,但如果你的查询都是小数据查询,就容易造成内存碎片和浪费。
查询缓存碎片率 = Qcache_free_blocks / Qcache_total_blocks * 100%
如果查询缓存碎片率超过20%,可以用FLUSH QUERY CACHE整理缓存碎片,或者试试减小query_cache_min_res_unit,如果你的查询都是小数据量的话。
查询缓存利用率 = (query_cache_size - Qcache_free_memory) / query_cache_size * 100%
查询缓存利用率在25%以下的话说明query_cache_size设置的过大,可适当减小;查询缓存利用率在80%以上而且Qcache_lowmem_prunes > 50的话说明query_cache_size可能有点小,要不就是碎片太多。
查询缓存命中率 = (Qcache_hits - Qcache_inserts) / Qcache_hits * 100%
示例服务器 查询缓存碎片率 = 20.46%,查询缓存利用率 = 62.26%,查询缓存命中率 = 1.94%,命中率很差,可能写操作比较频繁吧,而且可能有些碎片。
启动:service mysqld start
停止:service mysqld stop
重启:service mysqld restart
重载配置:service mysqld reload
# yum install mycli
# mycli -h localhost -uroot
Password:
Version: 1.8.1
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - jweiland.net
mysql root@localhost:(none)> show DATABASES;
可以体验一下快捷键补全的效果
导出数据库
# mysqldump -u root -psecret --add-drop-database dbname > dbname_sql.dump
# mysql -u root -psecret -D dbname < dbname_sql.dump
导出多个数据库
mysqldump -d -B mysql information_schema -u root -p1234 > mysql-test.sql
mysql , information_schema 是数据库的名字
导出一张表
mysqldump -t dbname1 tablename1 -u root -p > xxx.sql
导出多个表数据
mysqldump -d -B dbname1 --tables tablename1 tablename2 -u root -p > xxx.sql
导出一个表结构以及数据
mysqldump dbname1 tablename1 -u root -p > xxx.sql
导出多个表结构以及数据
mysqldump -B dbname1 --tables tablename1 tablename2 -u root -p > xxx.sql
# mysqldump -u root -psecret --add-drop-database --all-databases > full.dump
# mysql -u root -psecret < full.dump
这里 mysql root 的密码为”secret”,-p 选项后面没有空格。当单独使用 -p 选项(不跟密码),命令行提示符后会要求输入密码
# yum install php.x86_64 -y
# php -v
PHP 5.3.3 (cli) (built: Aug 11 2016 20:33:53)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。
常用screen 快捷键
ctrl + o + c : 复制一个会话
ctrl + o + A :对会话进行重命名
详细语法请查看:http://www.cnblogs.com/mchina/archive/2013/01/30/2880680.html
官网介绍:
http://www.slac.stanford.edu/comp/unix/package/epics/extensions/iocConsole/screen.1.html
# yum list|grep screen
# yum install screen.x86_64
# vi .screenrc
escape ^Oo
caption always "%{Yk}%-w%50>%{rb}%n %t%{-}%+w%81<%{- Yk}%{Bk}|%=%{bk} %Y-%m-%d %C "
defencoding UTF-8
encoding UTF-8 GBK
vbell off
注意.screenrc一般放在~目录下,.screenrc是隐藏文件,前面有个.号
创建一个会话
#screen -S xiaoxu
查看已经创建的会话
# screen -ls
There are screens on:
56422.xiaoxu-ycsb (action)
56382.xiaoxu (Detached)
进入到action的会话中
# screen -r 56422
进入到Detached状态的会话
#screen -x 56382
杀掉某个进程
# kill -9 56382杀掉当前的回话
清除该回话
# screen -wipe
ag :比grep、ack更快的递归搜索文件内容,详情查看http://www.dongwm.com/archives/ack/
-l --files-with-matches :只打印不包含匹配的文件夹
-L --files-without-matches :只打印包含匹配的文件夹
-A --after [LINES] : 匹配后的打印行,默认的是2行
-B --before [LINES] : 匹配前的打印行,默认的是2行
-c --count: 只打印每个文件中的匹配数
-G --file-search-regex : 模式限制搜索到文件名匹配模式
--hidden : 搜索隐藏文件
$ yum install silversearcher-ag
详细使用请使用
$ag --help
$ ag "s"
1.log
5:s
7:s
9:sss
2.log
1:sdsfefe
$ ag "s" 1.log
5:s
7:s
9:sss
$ ag -l --java "JDBC Multitable Consumer"
以下软件适用于ubuntu直接安装,主要介绍meld与diffuse安装与使用
$ sudo apt-get install meld
#sudo apt-get install diffuse
http://blog.csdn.net/xfg0218/article/details/79029993
#sudo apt-get install python-xlib
#wget http://packages.linuxdeepin.com/deepin/pool/main/d/deepin-scrot/deepin-scrot_2.0-0deepin_all.deb
#sudo apt-get -f install
#sudo dpkg -i deepin-scrot*
#deepin-scrot
停止打印服务
# /etc/init.d/cups stop d
# chkconfig cups o ff
# vim /etc/modprobe.conf
在下面添加一下配置:
alias net-pf-10 off
alias ipv6 off
查看当前的文件的数量:
# ulimit -n
1024
# ulimit -n 1000000
# ulimit -n
1000000
# vi /etc/security/limits.conf 在文件最后加上:
* soft nofile 65535
* hard nofile 65535
* soft nproc 65535
* hard nproc 65535
# vi /etc/sysctl.conf
在文本的最后追加一下内容:
net.core.somaxconn = 32768
表示物理内存使用到 90%(100-10=90)的时候才使用 swap 交换区
在最后追加一下内容
/dev/sda2 /data ext3 noatime,nodiratime 0 0
MTU是Maximum Transmission Unit的缩写。意思是网络上传送的最大数据包。
查看:# cat /sys/class/net/eth0/mtu
设置:# echo "1460" > /sys/class/net/eth0/mtu
# more /proc/sys/net/core/somaxconn
128
# echo 50000 > /proc/sys/net/core/somaxconn
# more /proc/sys/net/core/somaxconn
50000
# more /proc/sys/net/ipv4/tcp_tw_recycle
0
# cd /proc/sys/net/ipv4/
# echo 1 > tcp_tw_recycle
# more /proc/sys/net/ipv4/tcp_tw_recycle
1
# cd /proc/sys/net/ipv4
# more /proc/sys/net/ipv4/tcp_tw_reuse
0
# echo 1 > tcp_tw_reuse
# more /proc/sys/net/ipv4/tcp_tw_reuse
1
# who
04:39:39 up 1:30, 1 user, load average: 0.01, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 192.168.215.1 04:27 0.00s 0.16s 0.02s w
# last
***************
root pts/2 hadoop2 Sun Oct 16 15:52 - 15:52 (00:00)
root pts/1 192.168.215.1 Sun Oct 16 15:39 - down (00:23)
hadoop pts/0 :0.0 Sun Oct 16 00:33 - down (15:30)
hadoop tty1 :0 Sun Oct 16 00:31 - down (15:31)
reboot system boot 2.6.32-573.el6.x Sun Oct 16 08:16 - 16:03 (07:47)
# history
***************
683 last
684 clear
685 last
686 clear
687 history
# pstree -a
init
├─NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
├─abrtd
├─acpid
├─atd
├─auditd
│ └─{auditd}
├─bonobo-activati --ac-activate --ior-output-fd=12
*******************
# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 19352 1544 ? Ss 03:09 0:02 /sbin/init
root 2 0.0 0.0 0 0 ? S 03:09 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 03:09 0:00 [migration/0]
root 4 0.0 0.0 0 0 ? S 03:09 0:00 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S 03:09 0:00 [stopper/0]
# netstat -nltl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN
tcp 0 0 :::2181 :::* LISTEN
tcp 0 0 :::37129 :::* LISTEN
# netstat -nulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 0 0 0.0.0.0:631 0.0.0.0:* 2089/cupsd
# netstat -nxlp
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 13954 2136/hald @/var/run/hald/dbus-WAkpL6y5o7
unix 2 [ ACC ] STREAM LISTENING 16245 2614/gnome-session @/tmp/.ICE-unix/2614
unix 2 [ ACC ] STREAM LISTENING 15966 2524/Xorg @/tmp/.X11-unix/X0
unix 2 [ ACC ] STREAM LISTENING 13947 2136/hald @/var/run/hald/dbus-QUMwKtSaJ5
unix 2 [ ACC ] STREAM LISTENING 13818 2089/cupsd /var/run/cups/cups.sock
*********************
# free -m
total used free shared buffers cached
Mem: 1862 475 1386 1 27 202
-/+ buffers/cache: 245 1616
Swap: 2047 0 2047
# free -g
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 15 7 1 0 6 6
交换: 1 0 1
# uptime
04:59:59 up 1:50, 1 user, load average: 0.00, 0.00, 0.00
当前时间 04:59:59
系统已运行的时间 1:50
当前在线用户 1 user
平均负载:0.00, 0.00, 0.00,最近1分钟、5分钟、15分钟系统的负载
P:按%CPU使用率排行
T:按MITE+排行
M:按%MEM排行
# top
top - 12:26:46 up 16:21, 1 user, load average: 0.00, 0.00, 0.00
Tasks: 82 total, 1 running, 81 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.1%sy, 0.0%ni, 99.7%id, 0.1%wa, 0.0%hi, 0.1%si, 0.0%st
Mem: 1895288k total, 665188k used, 1230100k free, 20628k buffers
Swap: 2097144k total, 0k used, 2097144k free, 80392k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2269 root 20 0 15056 1080 832 R 2.0 0.1 0:00.01 top
1 root 20 0 19356 1536 1228 S 0.0 0.1 0:01.81 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
4 root 20 0 0 0 0 S 0.0 0.0 0:01.13 ksoftirqd/0
5 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
6 root RT 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/0
7 root 20 0 0 0 0 S 0.0 0.0 0:41.30 events/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cgroup
9 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper
***********************
# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
# ethtool eth0
*******************
Handle 0x0229, DMI type 33, 31 bytes
64-bit Memory Error Information
Type: OK
Granularity: Unknown
Operation: Unknown
Vendor Syndrome: Unknown
Memory Array Address: Unknown
Device Address: Unknown
Resolution: Unknown
Handle 0x022A, DMI type 126, 4 bytes
Inactive
Handle 0x022B, DMI type 127, 4 bytes
End Of Table
# iostat
Linux 2.6.32-573.el6.x86_64 (hadoop1) 10/21/2016 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.17 0.00 0.56 2.15 0.00 97.11
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 1.49 75.27 10.68 645224 91568
# vmstat 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 1322196 30688 298892 0 0 37 5 39 57 0 1 97 2 0
0 0 0 1322140 30688 298920 0 0 0 0 57 84 1 1 99 0 0
*********************
# mpstat 2 10
Linux 2.6.32-573.el6.x86_64 (hadoop1) 10/21/2016 _x86_64_ (1 CPU)
05:37:26 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
05:37:28 AM all 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00
05:37:30 AM all 0.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.50
05:37:32 AM all 0.00 0.00 0.00 0.00 0.00 0.50 0.00 0.00 99.50
*********************
# yum -y install dstat
# dstat --top-io --top-bio
----most-expensive---- ----most-expensive----
i/o process | block i/o process
bash 53k 316B|init 19k 198B
sshd: root@ 301B 340B|tpvmlpd2 0 4096B
sshd: root@ 136B 180B|jbd2/sda2-8 0 56k
# mount
/dev/sda2 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,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
打开一下文件进行编辑
# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Oct 16 07:55:57 2016
#
# 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
#
UUID=b89c0aae-3284-4835-9b1b-04986146cd96 / ext4 defaults 1 1
UUID=a1313d92-6873-402d-95a6-add6cd1321c6 /boot ext4 defaults 1 2
UUID=6a5cde98-2fc5-4d8f-976c-92acb39ab2a9 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
# vgs
# pvs
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 6.2G 11G 38% /
tmpfs 932M 72K 932M 1% /dev/shm
/dev/sda1 283M 41M 228M 16% /boot
# lsof +D / /* beware not to kill your box */
***************
lsof 3907 root mem REG 8,2 22536 265965 /lib64/libdl-2.12.so
lsof 3907 root mem REG 8,2 1926480 265960 /lib64/libc-2.12.so
lsof 3907 root mem REG 8,2 124624 265966 /lib64/libselinux.so.1
lsof 3907 root mem REG 8,2 99158576 394281 /usr/lib/locale/locale-archive
**************
net.ipv6.nf_conntrack_frag6_high_thresh = 4194304
net.ipv6.ip6frag_secret_interval = 600
net.ipv6.mld_max_msf = 64
net.nf_conntrack_max = 65536
net.unix.max_dgram_qlen = 10
abi.vsyscall32 = 1
crypto.fips_enabled = 0
irq的序号, 在各自cpu上发生中断的次数,可编程中断控制器,设备名称(request_irq的dev_name字段)
# cat /proc/interrupts
CPU0
0: 261 IO-APIC-edge timer
1: 8 IO-APIC-edge i8042
4: 4838 IO-APIC-edge
8: 1 IO-APIC-edge rtc0
9: 0 IO-APIC-fasteoi acpi
查看链接数据库的信息
# cat /proc/net/ip_conntrack /* may take some time on busy servers */
**************
cat: sys/: Is a directory
cat: tmp/: Is a directory
cat: usr/: Is a directory
cat: var/: Is a directory
# netstat
************
unix 3 [ ] STREAM CONNECTED 13648
unix 3 [ ] STREAM CONNECTED 13647
unix 3 [ ] DGRAM 10073
unix 3 [ ] DGRAM 10072
# ss -s
Total: 602 (kernel 610)
TCP: 15 (estab 4, closed 0, orphaned 0, synrecv 0, timewait 0/0), ports 8
Transport Total IP IPv6
* 610 - -
RAW 0 0 0
UDP 1 1 0
TCP 15 5 10
INET 16 6 10
FRAG 0 0 0
# dmesg [ tail / less / grep / more ]
*************
eth0: no IPv6 routers present
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
hrtimer: interrupt took 2588670 ns
# less /var/log/messages
Oct 16 08:16:22 localhost kernel: imklog 5.8.10, log source = /proc/kmsg started.
Oct 16 08:16:22 localhost rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="1604" x-info="http://www.rsyslog.com"] start
Oct 16 08:16:22 localhost kernel: Initializing cgroup subsys cpuset
Oct 16 08:16:22 localhost kernel: Initializing cgroup subsys cpu
*************
ccze 可以把日志的信息进行高亮,它可以用不同颜色高亮日志,协助管理员进行区分和查看分析
# sudo apt-get install ccze
# tail -F /var/log/syslog/| ccze
# less /var/log/secure
Oct 16 08:17:06 localhost sshd[8287]: Server listening on 0.0.0.0 port 22.
Oct 16 08:17:06 localhost sshd[8287]: Server listening on :: port 22.
Oct 16 00:22:58 localhost polkitd(authority=local): Registered Authentication Agent for session /org/freedesktop/ConsoleKit/Session1 (system bus name :1.25 [/usr/libexec/polkit-gnome-authentication-agent-1], object path /org/gnome/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
********************
# ls /etc/cron* + cat
/etc/cron.daily:
cups logrotate makewhatis.cron mlocate.cron prelink readahead.cron tmpwatch
/etc/cron.hourly:
0anacron
/etc/cron.monthly:
readahead-monthly.cron
/etc/cron.weekly:
# for user in $(cat /etc/passwd | cut -f1 -d:); do crontab -l -u $user; done
no crontab for root
no crontab for bin
no crontab for daemon
在安装的软件中搜索以安装的软件,关键字creator即可看到以下图标
以上创建后便可以直接作为启动盘使用了
工具下载http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
按照以下的步骤选择镜像文件并插入U盘后会自动发现,点击create创建即可
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。