分类 Linux 下的文章

redis批量导入

cat test.txt
a,1
b,2
c,3
cat test.txt | awk -F "," '{print $1" "$2" "$3" "$4}'
a 1
b 2
c 3
cat ../test.txt | awk -F "," '{print $1" "$2}' | xargs -n4 sh -c 'src/redis-cli set $1 $2' sh
cat ../test.txt | awk -F "," '{print "set "$1" "$2}' | src/redis-cli --pipe
cat ../f0.txt | awk -F "," '{print "set "$1" "$2}' | src/redis-cli --pipe
time cat ../f0.txt | awk -F "," '{print "set "$1" "$2}' | src/redis-cli -n 0 --pipe

挂载exFat分区

原来也不是直接可以挂载的,还要装点儿东西
sudo apt-get install exfat-fuse
然后就可以挂啦
sudo mount /dev/sda /mnt/usb_flash

单机HBase

http://www.apache.org/dyn/closer.cgi/hbase/
https://mirror.bit.edu.cn/apache/hbase/
https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/hbase-1.3.6/hbase-1.3.6-bin.tar.gz
tar zxf hbase-1.3.6-bin.tar.gz
mv hbase-1.3.6 hbase

sudo vi /etc/profile 添加

export HBASE_HOME=/home/user/hbase
export PATH=$HBASE_HOME/bin:$PATH

source /etc/profile
hbase version
HBase 1.3.6

Source code repository git://Sakthis-MacBook-Pro-2.local/Users/sakthi/dev/hbase revision=806dc3625c96fe2cfc03048f3c54a0b38bc9e984
Compiled by sakthi on Tue Oct 15 01:55:41 PDT 2019
From source with checksum d587feefff2057a2e5001da5db4a6fac

JDK要配好java -version

vi /home/user/hbase/conf/hbase-env.sh

export JAVA_HOME=/home/user/miku/jdk
export HBASE_MANAGES_ZK=true

vi /home/user/hbase/conf/hbase-site.xml

<configuration>
    <property>
        <name>hbase.rootdir</name>
        <value>file:/home/user/miku/data</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>file:/home/user/miku/data/zookeeper</value>
    </property>
</configuration>

/home/user/hbase/bin/start-hbase.sh # stop-hbase.sh 停止
hbase shell

status
create 'table1','field1'
t1 = get_table('table1')
t1.put 'row1', 'field1:qualifier1', 'value1'
t1.scan

参考:
https://blog.csdn.net/ouzhuangzhuang/article/details/89876152

Binary file (standard input) matches

执行命令:

cat 文件名 | grep 'test'

报错:

Binary file (standard input) matches

搜索一番,意思是二进制文件不能直接grep。

解决方法:

cat 文件名 | grep -a 'test'

参考:
https://www.liudon.org/1282.html

阻止IP访问

iptables -A INPUT -s 103.98.19.x -p TCP -j DROP
也可以组织网段
iptables -A INPUT -s 103.98.19.0/24 -p TCP -j DROP

iptables -L INPUT --line-numbers
登录日志
cat /var/log/auth.log | grep Accepted

https://www.linuxidc.com/Linux/2015-02/113586.htm