Category - Linux

2020-03-19 14:51:38    1037    0    0

在Centos 7.6 中,进行kvm 安装,virt-install 之后,在图形图面中,鼠标可以使用,键盘不可以使用,按键之后图形界面无反应,但是每按一次键盘CLI终端有一行warning 输出。

(virt-viewer:32227): GSpice-CRITICAL **: 02:22:38.179: send_key: assertion 'scancode != 0' failed

 


virt-install --name vm1 -r 8192 --disk path=/var/lib/libvirt/images/vm1.img,size=20 --vcpu=2 --network bridge=br0,model=e1000 --cdrom=/public/ubuntu-18.04.2-server-amd64.iso
Starting install...
Allocating 'vm1.img'                                                                                                              |  20 GB  00:00:01     
(virt-viewer:32227): GSpice-WARNING **: 02:22:36.541: PulseAudio context failed Connection refused
(virt-viewer:32227): GSpice-WARNING **: 02:22:36.541: pa_context_connect() failed: Connection refused
(virt-viewer:32227): GSpice-WARNING **: 02:22:36.605: Warning no automount-inhibiting implementation available
(virt-viewer:32227): vnc-keymap-WARNING **: 02:22:36.642: Unknown keycode mapping '(null)'.
Please report to gtk-vnc-list@gnome.org
including 
? qcow2 ?    2020-03-11 09:43:31    685    0    0

https://cloudinit.readthedocs.io/en/latest/topics/modules.htm

https://cloudinit.readthedocs.io/en/latest/topics/examples.html

 

安装工具:

apt-get install cloud-init​

 

使用cloud-localds命令生成一个seed.img , 然后在virt-install qcow2 image 的时候同时指定这个seed.img

 

即 把初始化镜像时的自定义修改放到seed.img中, 然后将它作为一个参数传给kvm 。

 

cloud-localds seed.img user-data meta-data​

 

这个命令是指user-data meta-data 中的配置加载到seed.img ,并生成seed.img 。 所以首先我们要编辑user-data meta-data 。格式与yaml相同。用法参见https://cloudinit.readthedocs.io/en/latest/topics/examples.html

 

注意,write file 是生成新文件,会覆盖。如要修改已有文件的个别部分,应该修改后的全文贴入对应部分

生成seed.img 之后,virt-install 时加上--disk path=/vob/cloud-init/seed.img,bus=virtio,format=raw

qemu-img resize xxxx.qcow2 +30G
virt-install -d --connect qemu:///system --name casa-mobile-a -r 61440 --vcpus 4 --cpu host  \
--disk path=/vob/cloud-init/xxxxxxx.qcow2,format=qcow2,bus=virtio --import   \
--disk path=/vob/cloud-init/seed.img,bus=virtio,format=raw    \
--autostart --noautoconsole​

 

user-data 的一个示例,必须是以#cloud-config 开头

还可用于修改root 密码之类的变更,用passwd 。

2020-03-05 17:45:09    517    0    0

待整理

2020-01-19 10:00:21    1521    0    0

ubuntu ISO 安装镜像的定制

 

1. 基本的系统镜像需要哪些组成部分

 

2.引导部分

 

3.软件预装设置

https://help.ubuntu.com/16.04/installation-guide/amd64/apb.html

https://help.ubuntu.com/18.04/installation-guide/amd64/index.html

 

 

4.preseed

 

5.isolinux

 

6.grub.cfg

 

7. ubuntu 18

支持的架构有4:AMD64, ARM, POWER8, LinuxONE and z Systems 

ubuntu 10 及以前, 桌面版和服务器版的内核版本是有作区分。这以后,便合并为一个单独的通用内核版本,以降低维护成本。

Ubuntu 18.04支持六种主要的架构和每一种架构的几种变体,称为“口味”。另一个架构(IBM/Motorola PowerPC)有一个非官方的端口。支持AMD64和Intel 64处理器。

 

Debian

Debian是一个全志愿组织,致力于开发自由软件和促进自由软件社区的理想。Debian项目开始于1993年,当时Ian Murdock向软件开发人员发出了一个开放的邀请,邀请他们为一个基于相对较新的Linux内核的完整和一致的软件发行版做出贡献。最初由自由软件基金会(Free Software Foundation)资助并受GNU哲学影响的这一小群热心的爱好者,经过多年的发展,已经成长为一个大约有1026名Debian开发人员的组织。

 

universe 组件? 

For users that want access to every known package, Ubuntu provides a "universe" component (set of packages) where users of Ubuntu systems install the latest version of any package that is not in the supported set. Most of the packages in Ubuntu universe are also in Debian, although there are other sources for universe to

? expect ?    2019-10-23 15:31:52    445    0    0

 

前面在 “expect:scp/ftp 自动化 ”  这一篇中提到:

interact:执行完毕后保持交互状态,并等待手工输入的操作了。

由于ftp 输入密码时敲错时不能使用ctrl+ backspace 进行回退,于是写了一个脚本用于自动操作登录部分,并在脚本执行结束时,将操作交互权交回给控制台,继续手工执行ftp 命令

 

loginftp.sh  ${yuser}  ${ypassword}

#!/usr/bin/expect
set timeout 7200
set FTP "ftp>"
spawn ftp ftp.xxxx.com
 expect {
 "):"
 { send "${yuser}\n"
 expect "*assword:" {send "${ypassword}\n"}
 }
 "*couldn't execute*no such file*"
 {
 print "ftp not install"
 }
}
interact​

 

2019-10-12 14:46:06    208    0    0

http://www.zsythink.net/archives/tag/iptables/

 

整理中。。

iptable

  • iptable 按设置的规则执行
  • 规则规定了 源地址 目标地址 传输协议 服务类型 等
  • 数据包如果符合这些规则,就进行对应的操作
  • 操作的类型的 放行(accept),拒绝(reject),丢弃(drop)

 

而我们对iptables 的配置,实际是就是对iptable中 的规则进行增 删 改。

 

 

概念:

数据包流向,链,表

 

1. 数据包流向

 

2. 链

 

3. 表

iptable 定义了4种表,缺省是filter, 其他表可用-t 指定

2019-10-12 10:22:29    292    0    0

Ubuntu - 64位系统缺失32位共享库

报错

  1. Invocation of this Java Application has caused an InvocationTargetException. This application will now exit. (LAX)
  2. Stack Trace:
  3. java.lang.UnsatisfiedLinkError: /opt/AccuRev/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
  4. at java.lang.ClassLoader$NativeLibrary.load(Native Method)
  5. #../jre/lib/**i386**/xawt/libmawt.so:libXext.so.6
  6. 这个报错表明程序安装目录有一个32位的libmawt.so需要调用32位的共享库libXext.so.6,但是找不到该库。

解决思路

一般报此错是因为64位系统执行的软件需要32位共享库的支持:

  1. #确认64位内核架构
  2. >dpkg --print-architecture
  3. amd64
  4. #确认‘支持32位’ 是否打开
  5. >dpkg --print-foreign-architectures
  6. i386
  7. #如果没有打开支持32位的功能,需打开
  8. >sudo dpkg --add-architecture i386

安装32位库:

  1. apt-get install libxext6:i386
  2. #安装报错指出的库后,再行,发现已经pass , 继续报其他丢失库,继续安装
  3. apt-get install libxtst6:i386
  4. apt-get install libxi6:i386
? shell ? ? gitlab ?    2019-09-18 10:38:35    654    0    0

JQ URL

https://stedolan.github.io/jq/download/
https://stedolan.github.io/jq/manual/#Invokingjq
这是一个开源工具,用于处理json 。

前言

"The API uses JSON to serialize data. You don’t need to specify .json at the end of an API URL."

在linux 下使用gitlab API 返回json 对象,经常使用python处理返回结果。 如果只是单纯地使用shell脚本中,常将其当作文本,并用sed ,grep,cut分解。但是因为它不是准确地分解对象中的组成,而是简单地通过关键字进行筛选和切割,所以经常会有遗漏或不够准确。

在linux 中安装jq , 可以在shell 中直接使用jq 对json 对象进行处理。

安装jq

下载 jq 源码包编译安装
  1. # configure ,make ,make install
  2. cd jq
  3. autoreconf -i
  4. ./configure --disable-maintainer-mode
  5. make
  6. sudo make install

下载二进制文件直接使用

  1. [root@huangbei ~]# chmod +x jq-linux64
  2. [root@huangbei ~]# mv jq-linux64 /usr/bin/jq
  3. [root@huangbei ~]# jq
  4. jq - commandline JSON processor [version 1.6]
  5. Usage: jq [options] <jq filter> [file...]
  6. jq [options] --args <jq filter> [strings...]
  7. jq [options] --jsonargs <jq filter> [JSON_TEXTS...]
  8. jq is a tool for processing JSON inputs, applying the given
? shell ?    2019-09-10 15:18:37    399    0    0


包含行首尾的空格

  1. echo ${#Massage}

不包含行首尾的空格

  1. echo $Massage | awk '{print length($0)}'

示例

  1. [lcf@huangbei ~]$ Massage=" Usage: $0 \${RELEASE_NOTE_FULL_PATH} "
  2. [lcf@huangbei ~]$ echo ${#Massage}
  3. 39
  4. [lcf@huangbei ~]$ echo $Massage | awk '{print length($0)}'
  5. 37
  1. [lcf@huangbei ~]$ Massage="Usage: $0 \${RELEASE_NOTE_FULL_PATH}"
  2. [lcf@huangbei ~]$ echo ${#Massage}
  3. 37
? shell ?    2019-07-10 15:19:11    459    0    0

 

shell 里做 判断时[ 左边一直报错,语法无问题,有redhat 里执行没有问题,脚本放到ubuntu 时报错

[: test: unexpected operator​

 

解决:

ubuntu 的shell 默认指向dash , 需要改回bash

sudo dpkg-reconfigure dash

选择 no

4/7