Mar 25, 2020
Life就在刚才领导问:“XX厂商下午来交流虚拟化,想不想了解一下?”
“不想”
他当然诧异,为毛我号称云计算组的不去交流交流。于是我说在某地上的项目时我们就很了解它的技术架构了,他听了也没说什么。
真实原因是:
- 现场方案的落地权根本不在我职责范围内,各地想用什么方案恐怕连公司都没法做主。即便公司能做主,也会在事业部的层面决定选用谁家的方案。那么,这种推介直接推到我这个部门层面是否有必要?
- 放牛割草的故事。你是割草的,他是放牛的。他陪着你聊天,聊了一整天。到黄昏时候,他的牛吃饱了,你的草篓依然是空的。厂商肯上门来做技术推介的,多半是售前,售前的工作就是耗"可能的客户"的时间,某种程度上来说,售前和那些卖保险的没什么差别。他的牛吃饱了,你的草呢?站在这个角度想一想,去和人聊天不如静下心来做自己的东西。
- 国产厂商对于虚拟化/云等技术的理解及技术积累。都是靠堆人技术,把国外开源的拿过来改巴改巴。如果你有能力消化开源社区的东西,且提升成自己的方案,干嘛去听个二道贩子忽悠?
- Life is short, enjoy/play/learn more. 肺炎在外面是如此的惨烈,何必浪费宝贵时间听别人吹嘘自家产品?
- 珍惜生命。毕竟肺炎还没有过去,谁都不知道会不会有二次爆发。在太多的不确定前,尽量缩减face-to-face的所谓交流。
- 相当鄙视领导的这种安排。他妈的你说去就去啊?一次成熟的技术交流应该是: 事先沟通,主动获取相应的材料,先学习一下看有没有当面交流的必要; 若有,当面交流时再深入探讨。就你这样的,人家说要来交流你就给他机会,他过来念他不知道念了几百次的浅显易懂的PPT给你洗脑,何必呢?至于我,说句不好听的,就是你拉过去撑场面、烘托气氛的吧。我自己也没那么贱,没必要陪你去浪费时间吧。
这类技术交流我事先有听过不知道多少次,每次都让我觉得如吞苍蝇。很高兴老子今天直接说了no,life is short, enjoy/play/learn more.
Mar 20, 2020
TechnologyContent
On how to modify the chinese kl system.
This system is based on ubuntu16.04, but the manufacturer changed into a chinese version, so they could sell it at a very high price. Following are the steps for cracking this system.
Preparation
Unbox the machine, tear down its hard disk(1T), insert into as the usb disk, then dd it into a gzipped file:
sudo dd if=/dev/sdc | gzip -c > /media/sda/to_be_fucked.img
Now transfer the img into a powerful arm64 server(HW’s arm64), and gunzip it into its origin size, 1T.
Install a clean ubuntu16.04.6 vm (arm64 version), like following:
After installation, shutdown this vm, but don’t destroy it. Later we will use it, this is the crated kl system located.
Now we will dump the kl system’s partition into our ubuntu system. Use another vm(ubuntu or centos, choose as you wish), attach the to_be_fucked.img
and readonly.qcow2
(previous vm image) together, then startup:
Login and check the partition,
Check every partition of the /dev/vdb
, we found the /dev/vdb2
is the root filesystem. so we mount it , also we mount the readonly.qcow2
's root directory:
# sudo mkdir -p /media/crack /media/kl
# sudo vgscan
# sudo mount /dev/mapper/ubuntu-system-root /media/crack
# sudo mount /dev/vdb2 /media/kl
# sudo rsync -avz /media/kl /media/crack
Wait for a while, after the rsync finished, you actually got the kl system into your ubuntu16.04.6 vm.
Crack
Make sure you are in the /media/crack
folder, do following steps:
Edit the etc/fstab
file, in kl system its partition will be changed as we are in cracked system:
# vim /media/crack/etc/fstab
/dev/mapper/ubuntu--vg-root / ext4 rw,noatime 0 1
Change the /boot
content in cracked partition, enable the read/write for root partition, and enable the serial port output:
# mount /dev/vdc2 /mnt
# vim /mnt/grub/grub.cfg
...... find the corresponding location
else
search --no-floppy --fs-uuid --set=root 39f71c29-80a2-43ad-b812-5d699ac4e94f
fi
echo 'Loading Linux 4.4.0-142-generic ...'
+++ linux /vmlinuz-4.4.0-142-generic root=/dev/mapper/ubuntu--vg-root rw console=ttyS0,115200
echo 'Loading initial ramdisk ...'
initrd /initrd.img-4.4.0-142-generic
}
........
Now shutdown our 1804 vm, bootup the cracked 16.04.6 system, it will startup and hang at the very beginning.
Boot the 1804 vm, mount the cracked partition, copy the origin systemd
binary file from a ubuntu16.04.6
system:
# mv /media/crack/lib/systemd/systemd /media/crack/lib/systemd/systemd.back
# cp the_origin_ubuntu16.04.6_systemd /media/crack/lib/systemd/systemd
Remove the activation check service:
root@arm01:/media/kylin/etc/systemd/system/multi-user.target.wants# pwd
/media/kylin/etc/systemd/system/multi-user.target.wants
root@arm01:/media/kylin/etc/systemd/system/multi-user.target.wants# mv kylin-activation-check.service /media/kylin/
After Cracked
Now reboot the system, this time the system will bootup and we use virsh for checking its ip address:
Get the ip address:
virsh net-dhcp-leases default |grep e4
2020-03-23 10:45:33 52:54:00:39:d6:e4 ipv4 192.168.122.150/24 fuckgfw-os -
Login with our physical machine’s username and password:
ssh fuckgfw@192.168.122.150
[Unauthorized System] fuckgfw@fuckgfw-os:~$
Tips for usage
to avoid the mtod, just change the /etc/motd
, and use the zsh for replacing the bash.
Enable remote desktop(vncserver), using metacity for replacing the default gpu powered window manager.
# vim /etc/motd
__________________________
< 麒麟: 我原本是Ubuntu . >
--------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
__ __ __ __ __ .______ __ __ .__ __. .___________. __ __
| | | | | | | | | | | _ \ | | | | | \ | | | || | | |
| |__| | | | | | | | | |_) | | | | | | \| | `---| |----`| | | |
| __ | | | | | | | | _ < | | | | | . ` | | | | | | |
| | | | | | __ | `--' | | |_) | | `--' | | |\ | | | | `--' |
|__| |__| |__| (_ ) \______/ |______/ \______/ |__| \__| |__| \______/
|/
Also change the contents under this folder:
vnc server
Configure the mate session for vncserver for:
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
metacity &
exec mate-session &
Configure the configuration via dconf-editor
, also configure the desktop manager via mate-tweak
.
Configure the rdesktop server as:
# vim ~/.xsession
metacity&
mate-session
# apt-get install -y xrdp
Thus you could visit the remote desktop via rdesktop
Mar 17, 2020
TechnologyTips
官方默认的源是无法安装的
备份后换成Ubuntu官方源:
# vim /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
# sudo apt-get update -y
成功。
System
Create a vm based on Ubuntu16.04.6, thus you get the qcow2 of the basic images. Copy another:
# cp ubuntu.qcow2 crack_FT.qcow2
Create the disk image via dd:
# sudo dd if=/dev/sdc | gzip -c > /media/sda/kylin_FT.img
Then gunzip it in a very large disk system
GREEN KFZ
Working.
1. all of the binarys are in portable mode.
2. ansible in portable.
3. docker/docker-compose in binary mode.
4. install-socat in docker images, arm64 distribution.
5. ignore installing any packages.
Mar 14, 2020
TechnologyRecords the steps for generating the chinese language version of linstor documentation.
Source Code Preparation
Clone the whole source tree from github:
$ git clone https://github.com/LINBIT/linbit-documentation.git
For I want to generate chinese version, I need asciidoctorr-pdf-cjk-kai_gen_gothic
to be installed and also its fonts, so I changed the Dockerfile for generating the docker images which could support chinese language pdf generation:
# vim Dockerfile
FROM debian:buster
MAINTAINER Roland Kammerer <roland.kammerer@linbit.com>
RUN groupadd --gid 1000 makedoc
RUN useradd -u 1000 -g 1000 makedoc
RUN apt-get update && apt-get install -y make inkscape ruby po4a patch
RUN gem install --pre asciidoctor-pdf
RUN gem install --pre asciidoctor-pdf-cjk
RUN gem install asciidoctor-pdf-cjk-kai_gen_gothic
RUN asciidoctor-pdf-cjk-kai_gen_gothic-install
USER makedoc
# make dockerimage
# sudo docker images | grep linbit
linbit-documentation latest 118d89f74702 47 hours ago 902MB
Generate the po files:
# cd linbit-documentation-master
# chmod 777 -R *
# make UG9-pot-docker
# cd UG9/en
# ls *.pot
about-linstor.pot administration-manual.pot docker-linstor.pot features.pot internals.pot lvm.pot opennebula-linstor.pot pacemaker.pot recent-changes.pot xen.pot
about.pot benchmark.pot docker.pot fundamentals.pot kubernetes.pot man-pages.pot opennebula.pot proxmox-linstor.pot rhcs.pot
administration-drbdmanage.pot build-install-from-source.pot drbdmanage-more.pot gfs.pot latency.pot more-info.pot openstack-linstor.pot proxmox.pot throughput.pot
administration-linstor.pot configure.pot drbd-users-guide.pot install-packages.pot linstor-users-guide.pot ocfs2.pot openstack.pot proxy.pot troubleshooting.pot
The pot (portable object template) which holds the tranlatable items. I wrote a simple python script which uses baidu api for translating them into chinese:
# cd UG9/en
# vim autotrans.py
import re
import polib
import sys
import translators as ts
# pot files should be passed in argv, e.g python autotrans.py example.pot
print("#######################################################################3")
print("#######################################################################3")
print("#######################################################################3")
print("################# Processing "+ sys.argv[1] + "###############################")
print("#######################################################################3")
print("#######################################################################3")
print("#######################################################################3")
print("#######################################################################3")
po = polib.pofile(sys.argv[1])
for entry in po:
# If contains '\n', then ignore translation
print(entry.msgid)
if "\n" in entry.msgid:
print("********************Ignore translation***********************")
entry.msgstr = entry.msgid
else:
# Normal texts should be translated.
entry.msgstr = ts.baidu(entry.msgid, 'auto', 'zh-CN')
print(entry.msgstr)
# msgid is the origin one, while msgstr should be translated one.
# << some_text_here >> should be selected out
msgstr_links = []
msgid_links = []
# origin ones
msgid_links = re.findall(r"(\<\<*.*?\>\>)", entry.msgid)
# translated ones, needs to be recover using origin ones.
msgstr_links = re.findall(r"(\<\<*.*?\>\>)", entry.msgstr)
if len(msgstr_links)>0:
### only run in matched at least once
for i in range(0, len(msgstr_links)):
entry.msgstr = entry.msgstr.replace(msgstr_links[i], msgid_links[i])
po.save('./cn/' + sys.argv[1])
Use a shell wrapped commands for tranlating all of the pot files:
# for i in `ls *.pot`
do
python3 autotrans.py $i
done
The tranlation goes one-by-one, until all of the pot files has been translated.
Notice: the auto translation got many errors, you have to correct them manually.
Building steps
I use ja language for start, cause japanese version has been translated:
# cd UG9
# cp -r ja cn
# cd cn/
# rm -f *.po
# cp ../cn/*.pot .
Write a simple shell script for changing name from pot
to po
:
# vim rename.sh
for i in `ls *.pot`
do
name=`echo $i | awk -F '.' {'print $1'}`
mv $i $name.po
done
# chmod 777 rename.sh
# ./rename.sh
# rm -f rename.sh
# ls *.po
about-linstor.po administration-manual.po docker-linstor.po features.po internals.po lvm.po opennebula-linstor.po pacemaker.po recent-changes.po xen.po
about.po benchmark.po docker.po fundamentals.po kubernetes.po man-pages.po opennebula.po proxmox-linstor.po rhcs.po
administration-drbdmanage.po build-install-from-source.po drbdmanage-more.po gfs.po latency.po more-info.po openstack-linstor.po proxmox.po throughput.po
administration-linstor.po configure.po drbd-users-guide.po install-packages.po linstor-users-guide.po ocfs2.po openstack.po proxy.po troubleshooting.po
Add cn
to UG-top.mk
:
- languages = en ja
+ languages = en ja cn
Change UG-build.mk
for adding cn
selection:
# diff UG-build.mk UG-build-back.mk
77c77
< if [ -d $(FONTDIR) ] && [ "$(lang)" != "ja" ] && [ "$(lang)" != "cn" ]; then \
---
> if [ -d $(FONTDIR) ] && [ "$(lang)" != "ja" ]; then \
83c83
< if [ -d $(FONTDIR) ] && [ "$(lang)" != "ja" ] && [ "$(lang)" != "cn" ]; then \
---
> if [ -d $(FONTDIR) ] && [ "$(lang)" != "ja" ]; then \
Change the Makefile for generating cn language pack:
# vim UG9/cn/Makefile
ASCIIDOCTOR_ADD_OPTIONS=-r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicCN
lang=cn
include ../../UG-build-po.mk
include ../../UG-build.mk
Add the default-theme.yml
under the UG9/cn
folder, and changes its fonts to CN related fonts:
# docker run --rm --entrypoint /bin/sh linbit-documentation:latest -c "cat /var/lib/gems/2.5.0/gems/asciidoctor-pdf-1.5.3/data/themes/default-theme.yml" > default-theme.yml
# vim default-theme.yml
font:
catalog:
# Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols
Noto Serif:
normal: KaiGenGothicCN-Regular.ttf
bold: KaiGenGothicCN-Bold.ttf
italic: KaiGenGothicCN-Regular-Italic.ttf
bold_italic: KaiGenGothicCN-Bold-Italic.ttf
# M+ 1mn supports ASCII and the circled numbers used for conums
M+ 1mn:
normal: KaiGenGothicCN-Regular.ttf
bold: KaiGenGothicCN-Bold.ttf
italic: KaiGenGothicCN-Regular-Italic.ttf
bold_italic: KaiGenGothicCN-Bold-Italic.ttf
page:
..........
Change the patch files under UG9/cn
:
# mv UG9/cn/drbd-users-guide.adoc-ja.patch UG9/cn/drbd-users-guide.adoc-cn.patch
# vim UG9/cn/drbd-users-guide.adoc-cn.patch
@@ -1,4 +1,23 @@
:doctype: article
+:lang: ja
+:chapter-label:
+:toc-title: 目录
+:preface-title: 前言标题
+:appendix-caption: 附录标题
+:caution-caption: 注意
+:example-caption: 示例标题
+:figure-caption: 图形标题
+:important-caption: 重要
+:last-update-label: 最終更新
+:listing-caption: 列表标题
+:manname-title: 人名
+:note-caption: 注記
+:preface-title: 前言标题
+:table-caption: 表标题
+:tip-caption: 要点标题
+:untitled-label: 未命名标签
+:version-label: 版本标签
+:warning-caption: 警告
:source-highlighter: bash
:listing-caption: Listing
:icons: font
Now change the permission for all of the folder, thus docker could have write priviledge to current folder:
# chmod a+w -R *
# make UG9-pdf-finalize-docker lang=cn
By running make UG9-pdf-finalize-docker
could generate chinese version’s pdf, By running make UG9-html-finalize-docker lang=cn
will generate chinese version’s htmls.
Mar 13, 2020
TechnologyAIM
Using redash for representing Wuhan’s nCov dataset.
Environment
Hardware/Software/OS is listed as following:
kvm vm with 2cores and 3072MB memory plus 200G disk.
Using docker/docker-compose for redash website.
OS is ubuntu 18.04.3
IP: 192.168.137.100
Redash bootstrap
Using the repository which located at:
https://github.com/getredash/setup
You have to git clone this repository and run setup.sh under the directory. After setup the docker-compose file located in /opt/redash
, if you want to quickly setup another docker/docker-compose based environment, simply copy the folder and the related docker images to remote machine’s /opt/redash
, up and running again.
root@node:/opt/redash# ls
docker-compose.yml env postgres-data
root@node:/opt/redash# docker-compose run --rm server create_db
root@node:/opt/redash# docker-compose up -d
Creating network "redash_default" with the default driver
Creating redash_redis_1 ... done
Creating redash_postgres_1 ... done
Creating redash_scheduled_worker_1 ... done
Creating redash_adhoc_worker_1 ... done
Creating redash_scheduler_1 ... done
Creating redash_server_1 ... done
Creating redash_nginx_1 ... done
The redash environment rested in 7 docker instance, could be examined using docker ps
:
root@node:/opt/redash# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e701e0bb8d2 redash/nginx:latest "nginx -g 'daemon of…" 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp, 443/tcp redash_nginx_1
5c00c609baa6 redash/redash:8.0.0.b32245 "/app/bin/docker-ent…" 7 minutes ago Up 6 minutes 0.0.0.0:5000->5000/tcp redash_server_1
8dcd4c2db0f8 redash/redash:8.0.0.b32245 "/app/bin/docker-ent…" 7 minutes ago Up 6 minutes 5000/tcp redash_scheduled_worker_1
5d1dbd77f4ce redash/redash:8.0.0.b32245 "/app/bin/docker-ent…" 7 minutes ago Up 6 minutes 5000/tcp redash_adhoc_worker_1
6d56d7cd9040 redash/redash:8.0.0.b32245 "/app/bin/docker-ent…" 7 minutes ago Up 6 minutes 5000/tcp redash_scheduler_1
c8efb3ff7437 postgres:9.6-alpine "docker-entrypoint.s…" 7 minutes ago Up 7 minutes 5432/tcp redash_postgres_1
a78dd1b1727f redis:5.0-alpine "docker-entrypoint.s…" 7 minutes ago Up 7 minutes 6379/tcp redash_redis_1
Now visit the vm’s 80 port you will see:
After login you will get the following page:
Until now your redash environment has been bootstraped.
Click your username and select Data Sources
:
Click New Data Source
button for adding a new data source:
Select sqlite and you will be leading to following window:
Fill in some infos for finishing:
Get Sqlite db
We take following page for refrence:
https://discuss.redash.io/t/example-data-source-for-the-choropleth-maps/3696
First fetch the example sqlite db using following command:
# wget https://dbhub.io/x/download/justinclift/DB4S%20daily%20users%20by%20country.sqlite?commit=28a554c2795170d5739b7a41df9baa2ad13b985b325d238bd869a14d1148f9ea
# mv DB4S\ daily\ users\ by\ country.sqlite first.db
Copy this db into following docker instance:
# docker cp first.db redash_scheduled_worker_1:/app
# docker cp first.db redash_server_1:/app
# docker cp first.db redash_adhoc_worker_1:/app
# docker cp first.db redash_scheduler_1:/app
Now click Test Connection
you will get Succeed
.
Create Query
Click Create Query
, you will be leading to following window:
Create a new query:
SELECT country, users
FROM query_6
WHERE date = '2019-04-22'
Click Execute
you will get the table listed as:
Click New Visualization
for editing the visualization:
Edit like following:
The map will be rendered like:
Click save
for saving the map, then rename this query:
Dashboard
Create the first dashboard:
An empty dashboard:
Click Add Widget
, select our newly created map:
Select the map:
Effect:
Conclusion
Now we have created the first visualization in redash easily displayed a
sqlite database, in next chapter we will take a look at how to display the
nCov statistics.