常用Linux命令总结

常用命令总结

  • 1. Linux
    • 1.1 防火墙
    • 1.2 开/关机
    • 1.3 文件和目录
  • 2. Sysbench
  • 3. JMeter
  • 4. YCSB
  • 5. MySQL
  • 6. Kubernetes & Docker

1. Linux

1.1 防火墙

  • 关闭防火墙

    setenforce 0  (selinux防火墙临时生效)
    service iptables stop
    
  • 开启防火墙

    setenforce 1
    service iptables start
    
  • 查看防火墙状态

    getenforce (selinux防火墙)
    service iptables status
    

1.2 开/关机

  • 关机

    shutdown -h now 
    
  • 重启

    reboot
    shutdown -r now
    
  • 注销

    logout 
    

1.3 文件和目录

  • 进入某一级目录
    cd /home     进入 /home目录
    cd ..        返回上一级目录
    cd -         返回上次所在目录
    cd           返回~
    pwd          显示工作路径
    ls           显示该目录下的文件&目录
    ll           显示该目录下文件&目录的详细信息
    
  • 新建目录
    mkdir d1     在该目录下新建d1目录
    mkdir d1 d2  在该目录下新建d1、d2两个目录
    
  • 删除文件
    rm -f test.txt    删除该目录下的文件test.txt
    rm -rf d1         删除该目录下的d1目录及其文件
    rm -rf d1 d2      删除该目录下的d1、d2目录及其文件
    rm -rf /home/d1   删除/home下的d1目录及其文件
    
  • 移动&复制文件
    mv /home/d1 new_d1   将/home下的d1文件移到当前目录下并命名为new_d1
    cp -rf /home/d1 d1   将/home下的d1目录及其文件复制到当前目录
    scp -r [email protected]:/home/d1  /home     远程将主机192.168.1.128上的文件复制到/home下
    
  • 解压/压缩文件
    tar -cvf t.tar /home/d1     将/home/d打包成t.tar
    tar -xvf t.tar              将t.tar文件解压到当前目录
    
    zip -r t.zip /home/d1       压缩zip格式
    unzip -r t.zip              解压
    
    tar -zcvf t.tar.gz /home/d1  打包且压缩  
    tar -zxvf t.tar              解压
    
  • 寻找文件所在位置
    whereis test      寻找test文件的位置
    which test
    find /home/d1 -name \*.bin    在目录 '/home/d1' 中搜索带有'.bin' 结尾的文件
    
  • 创建一个指向文件或目录的软链接
    ln -s file1 lnk1 
    
  • 新建&查看文件
    touch t.java
    vi t.java          新建并打开t.java文件
    
    cat t.java         显示t.java文件内容
    more t.java
    head -100 t.java
    tail  -100 t.java
    
  • 用户切换
    su  用户名
    su                 切换到root用户 
    
  • 文件权限
    chmod 777 /home/t.java       t.java可读可写可执行
    chown -R mysql ./            将该目录的所有者改为mysql
    
  • yum相关
    yum update               更新
    yum clean all            删除所有缓存的包和头文件 
    yum install xxx          使用yum下载xxx
    yum remove pack_name     删除一个rpm包
    
    
  • 网络
    ifconfig                      查看网络详情
    service network start/stop/status/restart     启动/停止/查看状态/重启网络 
    systemctl start/stop/status/restart  network
    netstat -an |grep 8080        查看8080端口的进程
    ps                            显示进程
    ping  www.baidu.com           查看网络是否畅通
    curl  192.168.1.128:8080      查看该ip的该端口
    talent  192.168.1.128:8080	
    wget 文件链接                  从链接下载文件
    

2. Sysbench

  • 下载

    可以从github上下载 https://github.com/akopytov/sysbench

  • 编译&依赖包

    yum -y install  make automake libtool pkgconfig libaio-devel vim-common
    ./autogen.sh
    ./configure --prefix=/usr/local/sysbench/ --with-mysql --with-mysql-includes=/usr/local/mysql/include \
      --with-mysql-libs=/usr/local/mysql/lib
    make && make install
    
  • 准备/开始/清除测试

    连续测试需要重启mysql数据库,清除缓存。

     ./src/sysbench /home/lmc/test/sysbench-1.0/src/lua/oltp_point_select.lua --mysql-user=root \
      --mysql-password=mysql --mysql-host=192.168.2.26 --mysql-port=3306 --mysql-db=test  \
      --mysql-storage-engine=innodb --table-size=10000 --tables=100 --threads=512 --time=300 \
      --report-interval=10 prepare/run/cleanup
    

3. JMeter

github地址: https://github.com/apache/jmeter

  • 使用

    [root@localhost Desktop]# cd apache-jmeter-5.0/
    
    [root@localhost apache-jmeter-5.0]# ls
    backups  bin  docs  extras  lib  LICENSE  licenses  NOTICE  printable_docs  README.md
    
    [root@localhost bin]# sh jmeter.sh -v
    Jun 28, 2019 12:05:27 AM java.util.prefs.FileSystemPreferences$1 run
    INFO: Created user preferences directory.
        _    ____   _    ____ _   _ _____       _ __  __ _____ _____ _____ ____     
       / \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \   
      / _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) | 
     / ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <  
    /_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 5.0 r1840935  
    
    Copyright (c) 1999-2018 The Apache Software Foundation
    
    [root@localhost bin]# ./jmeter -n -t TCP-big.jmx -l test.jtl
    OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
    Creating summariser 
    Created the tree successfully using TCP-big.jmx
    Starting the test @ Fri Jun 28 00:17:56 PDT 2019 (1561706276354)
    Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
    summary =      1 in 00:00:00 =   11.1/s Avg:    16 Min:    16 Max:    16 Err:     0 (0.00%)
    Tidying up ...    @ Fri Jun 28 00:17:56 PDT 2019 (1561706276909)
    ... end of run
    
    

4. YCSB

  • 下载&编译
    github地址: https://github.com/brianfrankcooper/YCSB
    需要有maven环境。

    mvn clean package      编译
    mvn -pl com.yahoo.ycsb:hbase10-binding -am clean package   单独编译一个
    mvn clean package -Dmaven.test.skip=true        出错时用这个
    
  • redis

    //装载数据
    bin/ycsb load redis -s -P workloads/workloada -p "redis.host=127.0.0.1" -p "redis.port=6379"         
    
    //运行workload
    bin/ycsb run redis -s -P workloads/workloada -p "redis.host=127.0.0.1" \
    	-p "redis.port=6379"  -threads 128 \
    	-p "operationcount=10000" -p "measurementtype=timeseries"  -p "timeseries.granularity=5000"
    
  • hbase

    //装载数据
    bin/ycsb load hbase10 -P workloads/workloada -cp/xxx/hbase/conf/ -p table=usertable \
      -p columnfamily=family -s -threads128
      
    //运行workload
    bin/ycsb run hbase10 -Pworkloads/workloada -cp /xxx/hbase/conf/ -p table=usertable \
      -p columnfamily=family -s –threads 128 
    
  • mysql

    //装载数据
    bin/ycsb load -s -P E:/YCSB-master/workloads/workloada -threads 128 \
      -p b.url=jdbc:mysql://222.20.xxx.xxx:3306/test,jdbc:mysql://127.0.0.1:3306/test  \
      -p db.user=root -p db.passwd=123456
      
    //运行workload
    bin/ycsb run -s -P E:/YCSB-master/workloads/workloada -threads 128 \
      -p db.url=jdbc:mysql://222.20.xxx.xxx:3306/test,jdbc:mysql://127.0.0.1:3306/test \
      -p db.user=root -p db.passwd=123456
    

5. MySQL

  • 数据库安装编译
    参考这篇文章:linux下安装mysql

  • 数据库启动/停止/重启/状态

    service mysql start/stop/restart/status
    
  • 登录

    [root@hserver1 mysql]# mysql -uroot -p
    Enter password: 
    
  • 修改密码

    ##登录成功后修改密码
    mysql> use mysql;
    Database changed
    mysql> update user set password=password("123456") where user="root";    
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
  • 拒绝访问修改密码
    出现该错误信息:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES);
    首先修改/etc/my.ini,在[mysqld]后添加skip-grant-tables,即在登陆的时候跳过检查,然后重启MySQL服务器,登录进去,不用输密码,之后修改密码,退出mysql,删除/etc/my.ini中添加的那句话,重启MySQL服务器即可。

  • 压测时设置连接的最大线程数

    set global max_connections=2048;
    set global max_prepared_stmt_count=10000000;
    

6. Kubernetes & Docker

单机版k8s安装参考–>k8s单机版配置

打包war包参考–>eclipse打包war包


【未更完】

你可能感兴趣的:(小白启程,linux命令,sysbench,ycsb,mysql,常用命令)