avatar
文章
156
标签
74
分类
16

Home
Archives
Link
About
Liarlee's Notebook
搜索
Home
Archives
Link
About
K8S将loop-lvm改为direct-lvm说明
发表于2019-09-24|更新于2025-09-23|Kubernetes
对k8s集群进行存储驱动的调整,从loop-lvm 切换到direct-lvm。 k8s的几种不同的存储驱动 AUFS - 这是一个经过时间检验的存储驱动 DeviceMapper - Redhat系默认的驱动,有loop和direct两种不同配置 Btrfs - 我…. 这个文件系统的快照真的是贼好用,但是性能什么的….我倒觉得都一般 ZFS - 还没用过 VFS - 还没用过 Overlay2 - 简单的接触了一下,docker目前推荐的存储驱动 关于存储驱动选择的相关博客及文章 Docker引擎 - 选择存储驱动Docker五种存储驱动原理及应用场景和性能测试对比Docker系统八:Docker的存储驱动 Loop-lvm这是docker默认安装之后的选择,因为这样可以out-of-box,但是据说稳定性不佳,我没遇到稳定性的问题,但是遇到了IO高导致的整个虚拟机运行缓慢。Loop-LVM其实使用了linux中的使用loop设备我之前安装的一套k8s默认是使用overlay2的存储,可能是内核的版本过低导致无法使用其他的存储驱动,所以我觉得默认使用了loop-lvm。 loop-lvm的工作模式是,默认在/var/lib/docker/devicemapper/devicemapper/目录下生成data&metadata两个稀疏文件(我目前还不知道什么叫做稀疏文件),并将两个文件挂载为loop设备做为块设备来使用。按照这个说法的话确实如果直接对裸设备的想能和稳定性都应该更强。所以下面可以动手啦~ Direct-lvm这里直接放一个官方文档的链接好了。Device-Mapper-driver 切换loop-lvm到direct-lvm想要切换的原因其实是已经安装好的这个k8s的master节点在跑了很久之后,总是被zabbix监控到报警,硬盘负载高;cpu进程数高。cpu的进程数量高可以理解,毕竟监控了如此多的容器。硬盘负载高这个报警在系统中发现是/dev/loop2这个设备。对应去查找 docker info中的信息,发现这是k8s的存储所使用的。进而搜索到了关于loop-lvm&direct-lvm的相关问题,发现使用loop设备的方式应该实在性能上有影响的,k8s不推荐生产环境使用,所以考虑切换过来,今后毕竟还是要长期使用的。值得注意的是:切换一定会导致之前的容器无法使用。而且目前来看关键的数据是不能恢复的,所以最好是在之前已经做好了计划。 自动托管配置自动托管的配置主要是两部分,首先是建立一个空的LVM,不需要挂载,只要系统识别到即可。之后是更改配置文件及重启docker服务。 在虚拟机中加入一块新的硬盘,fdisk中识别为/dev/sdb; 关闭docker。systemctl stop docker. 在配置文件中加入如下的配置,注意格式不要错,不要丢下末尾的逗号:{ "storage-driver": "devicemapper", # 告诉docker应用使用的存储驱动 "storage-opts": [ "dm.directlvm_device=/dev/sdb", # 指定使用的块设备,不需要格式化,不需要分区。在这里指定了设备docker会自动完成创建LVM等等操作。 "dm.thinp_percent=95", # 指定Thinpool占用的百分比 "dm.thinp_metapercent=1", # 指定Thinpool Meta数据使用的百分比 "dm.thinp_autoextend_threshold=80", # 指定自动扩容的阈值 "dm.thinp_autoextend_percent=20", # 指定自动扩容的比例 "dm.directlvm_device_force=false" # 是否强制格式化设备,默认是false。如果使用dockerd启动的时候出现了提供需要强行格式化设备的提示,就改为True。 ] } 重新启动docker服务。如果正常启动可通过docker info 查看是否已经切换过来。 如果没有能成功启动,尝试重启虚拟机;尝试使用dockerd命令直接启动,根据dockerd的日志信息进行相应的修改。 常见错误有:Sep 23 18:38:03 k8s-master dockerd: time="2019-09-23T18:38:03.931876136+08:00" level=warning msg="[graphdriver] WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release" # 存储驱动将会在未来的版本被移除的警告。这不会导致docker无法运行。 Sep 23 18:25:52 localhost dockerd: Error starting daemon: error initializing graphdriver: /dev/sdb is already part of a volume group "docker": must remove this device from any volume group or provide a different device # 这个问题说明 docker 认为你的/dev/sdb上已经被创建了LVM,你需要手动指定,自动托管不会对这个设备进行操作。这会导致docker无法启动。 # 首先你需要把/dev/sdb这个设备从LVM里面移除,lvdelete,pvdelete,vgdelete, 将设备还原为默认的状态,之后重启docker,将设备的所有操作控制都交给docker来做,就不会有这个错误了。 总结在更换之后目前性能稳定,IO的负载也下来了。总体来看还是不错的。不过随着kubernetes的发展,我觉得这种问题应该会越来越少。还是推荐在安装的时候直接调整,不然数据的随时确实带来了一些麻烦。
RabbitMQ_SysV风格管理脚本模板
发表于2019-09-23|更新于2025-09-23|Linux
需要自己写一个RabbitMQ的SysV脚本,所以找了一个模板,如果需要的时候可以改改就用了。 SysV脚本#!/bin/sh # # rabbitmq-server RabbitMQ broker # # chkconfig: - 80 05 # description: Enable AMQP service provided by RabbitMQ # ### BEGIN INIT INFO # Provides: rabbitmq-server # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Description: RabbitMQ broker # Short-Description: Enable AMQP service provided by RabbitMQ broker ### END INIT INFO # Source function library. . /etc/init.d/functions # 一些加注释的位置是需要修改的参数 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/data/erlang/bin # 更改PATH指向Erlang的路径 NAME=rabbitmq-server # 服务的名称,可以和脚本名称一致 DAEMON=/data/rabbitmq_server-3.6.13/sbin/${NAME} # 启动为守护进程的命令所在绝对路径 CONTROL=/data/rabbitmq_server-3.6.13/sbin/rabbitmqctl # 制定rabbitmqctl程序的所在位置, 绝对路径 DESC=rabbitmq-server # 目标服务 USER=root # 运行时的用户, 线上服务都使用了root用户 export HOME=/data/rabbitmq_server-3.6.13/ # 指定RabbitMQ的HOME目录,默认是在安装目录下;也有可能是在运行RabbitMQ用户的家目录下 ROTATE_SUFFIX= # INIT_LOG_DIR=/usr/local/rabbitmq/var/rabbitmq INIT_LOG_DIR=/data/rabbitmq_server-3.6.13/var/log/rabbitmq # 指出log的目录 # PID_FILE=/var/run/rabbitmq/pid PDI_FILE=/data/rabbitmq_server-3.6.13/var/lib/rabbitmq/mnesia/rabbit@ean-online-dubbo-zk-rmq-server-209.pid # 指出当前RabbitMQ的PID文件所在目录 START_PROG="daemon" LOCK_FILE=/var/lock/subsys/$NAME test -x $DAEMON || exit 0 test -x $CONTROL || exit 0 RETVAL=0 set -e [ -f /etc/default/${NAME} ] && . /etc/default/${NAME} [ -f /etc/sysconfig/${NAME} ] && . /etc/sysconfig/${NAME} ensure_pid_dir () { PID_DIR=`dirname ${PID_FILE}` if [ ! -d ${PID_DIR} ] ; then mkdir -p ${PID_DIR} chown -R ${USER}:${USER} ${PID_DIR} chmod 755 ${PID_DIR} fi } remove_pid () { rm -f ${PID_FILE} rmdir `dirname ${PID_FILE}` || : } start_rabbitmq () { status_rabbitmq quiet if [ $RETVAL = 0 ] ; then echo RabbitMQ is currently running else RETVAL=0 # RABBIT_NOFILES_LIMIT from /etc/sysconfig/rabbitmq-server is not handled # automatically if [ "$RABBITMQ_NOFILES_LIMIT" ]; then ulimit -n $RABBITMQ_NOFILES_LIMIT fi ensure_pid_dir set +e RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \ > "${INIT_LOG_DIR}/startup_log" \ 2> "${INIT_LOG_DIR}/startup_err" \ 0<&- & $CONTROL wait $PID_FILE >/dev/null 2>&1 RETVAL=$? set -e case "$RETVAL" in 0) echo SUCCESS if [ -n "$LOCK_FILE" ] ; then touch $LOCK_FILE fi ;; *) remove_pid echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\} RETVAL=1 ;; esac fi } stop_rabbitmq () { status_rabbitmq quiet if [ $RETVAL = 0 ] ; then set +e $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err RETVAL=$? set -e if [ $RETVAL = 0 ] ; then remove_pid if [ -n "$LOCK_FILE" ] ; then rm -f $LOCK_FILE fi else echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err fi else echo RabbitMQ is not running RETVAL=0 fi } status_rabbitmq() { set +e if [ "$1" != "quiet" ] ; then $CONTROL status 2>&1 else $CONTROL status > /dev/null 2>&1 fi if [ $? != 0 ] ; then RETVAL=3 fi set -e } rotate_logs_rabbitmq() { set +e $CONTROL rotate_logs ${ROTATE_SUFFIX} if [ $? != 0 ] ; then RETVAL=1 fi set -e } restart_running_rabbitmq () { status_rabbitmq quiet if [ $RETVAL = 0 ] ; then restart_rabbitmq else echo RabbitMQ is not runnning RETVAL=0 fi } restart_rabbitmq() { stop_rabbitmq start_rabbitmq } case "$1" in start) echo -n "Starting $DESC: " start_rabbitmq echo "$NAME." ;; stop) echo -n "Stopping $DESC: " stop_rabbitmq echo "$NAME." ;; status) status_rabbitmq ;; rotate-logs) echo -n "Rotating log files for $DESC: " rotate_logs_rabbitmq ;; force-reload|reload|restart) echo -n "Restarting $DESC: " restart_rabbitmq echo "$NAME." ;; try-restart) echo -n "Restarting $DESC: " restart_running_rabbitmq echo "$NAME." ;; *) echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2 ...
All this I did without you
发表于2019-09-19|更新于2025-09-23|Books
Letter No. 028 July 31st, 1978 Gerald Durrell, a respected conservationist wrote a love letter to his future wife, and then one of his students taking her PhD at Duke University, Lee McGeorge. ~ My darling McGeorge, You said that things seemed clearer when they were written down. Well, here with is a very boring letter in which I will try and put everything down so that you may read and re-read it in horror at your folly in getting involved with me. Deep breath. To begin with I love you with a depth and passion that I have felt for no one else in this life and if it astonishes you it astonishes me as well. Not I hasten to say, because you are not worth loving. Far from it. It’s just that, first of all, I swore I would not get involved with another woman. Secondly, I have never had such a feeling before and it is almost frightening. Thirdly, I would never have thought it possible that another human being could occupy my waking (and sleeping) thoughts to the exclusion of almost everything else. Fourthly, I never thought that — even if one was in love — one could get so completely besotted with another person, so that a minute away from them felt like a thousand years. Fifthly, I never hoped, aspired, dreamed that one could find everything one wanted in a person. I was not such an idiot as to believe this was possible. Yet in you I have found everything I want: you are beautiful, gay, giving, gentle, idiotically and deliciously feminine, sexy, wonderfully intelligent and wonderfully silly as well. I want nothing else in this life than to be with you, to listen and watch you (your beautiful voice, your beauty), to argue with you, to laugh with you, to show you things and share things with you, to explore your magnificent mind, to explore your magnificent mind, to explore your wonderful body, to help you, protect you , serve you, and bash you on the head when I think you are wrong… not to put too fine a point on it I consider that I am the only man outside mythology to have found the crock of gold at the rainbow’s end. But — having said all that — let us consider things in detail. Don’t let this become public but… well, I have one or two faults. Minor ones, I hasten to say. For example, I am inclined to be overbearing. I do it for the best possible motives (all tyrants say that) but I do tend (without thinking) to tread people underfoot. You must tell me when I am doing it to you, my sweet, because it can be a very bad thing in a marriage. Right. Second blemish. This, actually, is not so much a blemish of character as a blemish of circumstance. Darling I want you to be you in your own right, and I will do everything I can to help you in this. But you must take into consideration that I am also me in my own right and that I have a headstart on you… what I am trying to say is that you must not feel offended if you are sometimes treated simply as my wife. Always remember that what you lose on the swings, you gain on the roundabouts. But I am an established ‘creature’ in the world, and so — on occasions — you will have to live in my shadow. Nothing gives me less pleasure than this but it is a fact of life to be faced. Third (and very important and nasty) blemish: jealousy. I don’t think you know what jealousy is (thank God) in the real sense of the word. I know you have felt jealousy over Lincoln’s wife and child but this is what I call normal jealousy, and this — to my regret — is not what I’ve got. What I have got is a black moster that can pervert my good sense, my good humour and any goodness that I have in my make-up. It is really a Jekyll and Hyde situation… my Hyde is stronger than my good sense and defeats me, hard though I try. As I told you, I have always known that this lurks within me, but I couldn’t control it, and my monster slumbered and nothing happened to awake it. Then I met you and I felt my monster stir and become half awake when you told me of Lincoln and others you have known, and with your letter my monster came out of its lair, black, irrational, bigoted, stupid, evil, malevolent. You will never know how terribly corrosive jealousy is; it is a physical pain as though you had swallowed acid or red hot coals. It is the most terrible of feelings. But you can’t help it — at least I can’t, and God knows I’ve tried. I don’t want any ex-boyfriends sitting in church when I marry you. On our wedding day, I want nothing but happiness, for both you and me, and I know I won’t be happy if there is a church full of your ex-conquests. When I marry you I will have no past, only a future: I don’t want to drag my past into our future and I don’t want you to do it , either. Remember I am jealous of you because I love you. You are never jealous of something you don’t care about. OK, enough about jealousy. Now, let me tell you something… I have seen a thousand sunsets and sunrises, on land where it floods forest and mountains with honey-coloured light, at sea where it rises and sets like a blood orange in a mul ...
Gnome快捷键
发表于2019-09-19|更新于2025-09-23|Linux
Gnome桌面环境的快捷键。 快速启动一个应用 Super Hot Corner这两个我都用,HotCorner不是一个按键,而是一个动作,是指屏幕的右上角,鼠标指针用力撞过去,撞开所有的应用窗口。在Gnome的环境中,Super是一个超方便的键,当我需要打开vscode的时候,可以在任意时候通过super+code+Enter直接打开vscode应用。当按下Super的时候会自动触发一个全局的搜索,可以通过Super快速查看自己的需要的文件或者应用,这个功能是我最喜欢Gnome的地方。 执行命令 Alt+F2最常用的就是重启Gnome环境,通过Alt+F2 调出的命令窗口,使用r命令重启Gnome。 应用的切换 Super+TAB使用Super+TAB可以在应用之间快速切换。如果Cover-alt-tab的插件,还有三维动画。 Super+`这个组合键是切换应用内窗口的,我自己用的不多。 快速显示主屏幕应用菜单 Super+a快速显示主屏幕的所有应用程序页。 切换工作区 Super+PageUP or PageDown Ctrl+Alt+UP or DOWN可以在多个工作区之间快速切换,但是我自己常用的是第二种。键位上舒服一些。 移动窗口到其他工作区 Ctrl+Alt+Shift+UP or Down Super+Shift+PageUP or PageDown将当前的焦点窗口移动到前后的工作区,并保持当前窗口的焦点不变。这个也是特别好用的快捷键。 呼出通知中心和日历 Super+m这个快捷键最早的Gnome上是通知栏,现在用的比较少了,毕竟Gnome已经不是下方的通知栏了,是上面的日历加上通知中心的方式了。我自己的用的时候大部分是看时间和日历。 截图 PrintScreen截取所有屏幕内容,保存到文件。 Alt+PrintScreen截取当前窗口的内容,保存到文件。 Shift+PrintScreen截取选择的区域,保存到文件。 NOTE: 最方便的就是,使用Ctrl+Shift PrintScreen和Ctrl+PrintScreen 可以直接选取的区域截图,将截图保存在剪贴板,截图完成直接粘贴即可。 最大化最小化和分屏 Super+UP最大化到铺满屏幕 Super+LEFT靠左占据一般屏幕 Super+RIGHT靠右占据一般屏幕 Super+H最小化,隐藏 这些基本上就是我觉得常用而且好用的快捷键啦,但是还是可以自定义的,在设置里面,也可以随便设置,但是那样的话就不是拿来直接可以用的啦。
Nginx配置文件中if判断与try_files
发表于2019-09-19|更新于2025-09-23|Linux
Nginx的if判断问题,导致try_files字段未能正常生效。 配置文件server { listen 80; server_name liarlee.site; set $mobile_rewrite do_not_perform; if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") { set $mobile_rewrite perform; } if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-)") { set $mobile_rewrite perform; } if ($http_cookie ~ 'gotopc=true') { set $mobile_rewrite do_not_perform; } location / { root /var/html/www/[PC_WEB_ROOT]; # 问题出现在了这里。 if ($mobile_rewrite = perform) { root /var/html/www/[MOBILE_WEB_ROOT]; } index index.html index.htm error_page 404 index.html # 问题就出现在了这里。 try_files $uri $uri/ /index.html 404; } } 表现在访问请求来的同时,判断是不是手机访问,如果是PC使用默认的PC_WEB_ROOT, 如果是手机的话,访问到MOBILE_WEB_ROOT。本身逻辑和使用是没有问题的,但是需要使用try_files字段的时候,会导致PC站点的tryfiles可以正常生效;但是手机不会有tryfile的效果。 可行的方式 - Proxypass看到了一篇文章说到nginx的IF语句,可以正常不出奇怪问题的只有Proxy_pass,Rewrite两个,因为项目无法用rewrite所以选择了Proxypass。配置文件分为两个部分,每个网站放在一个Server下。 PC配置文件server { listen 80; server_name liarlee.site; set $mobile_rewrite do_not_perform; if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") { set $mobile_rewrite perform; } if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo| ...
虚拟机制作模板的步骤及设置
发表于2019-09-18|更新于2025-09-23|ESXi
换了工作之后接管了这边旧的ESXi和上面的虚拟机,之前的模板不是特别的合适,自己开始动手做模板。最终期望的目标是: 修改IP地址 yum install 收工 CentOS虚拟机模板制作流程系统的硬件配置系统的硬件规格 4cpu 8G-RAM OS的版本系统的版本 CentOS 7.6 1810 x64 安装VMwareToolsyum install -y epel vim wget curl net-tools open-vm-tools htop iotop iftop tree atop sysstat 安装Zabbix-agentrpm -ivh zabbix-agent-$version.rpm 关闭SELinuxsed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config 更改hostnamehostname有一些有趣的问题,CentOS6.8 中的hostname可以定义在/etc/sysconfig/network文件中,系统启动的时候先读取/etc/sysconfig/network文件中的定义,如果没有的话读取/etc/hosts文件中的定义.和我自己的之前的记忆不一样。我之前一直都是之间编辑/etc/hostname,直接将主机名echo到这个文件中就可以了,不过想来这些区别都不大,先这样吧。 清除硬件及网卡的信息将网卡配置文件中的UUID和 HWADDR直接删除或者是注释掉,IPADDR留空。 /etc/sysconfig/network-scripts/ifcfg-eth0 删除udevrm -rf /etc/udev/rules.d/70-* ``` NOTE:命令的效果貌似和 sys-unconfig 的效果是一样的。 ### 关闭防火墙 ```bash systemctl disable firewalld iptables -F iptables -X iptables -Z 更改Grub的等待时间虚拟机中的模板大部分是不需要等待grub给出的操作选单时间的,等待操作的时间是5秒,我们给出1秒就够了。 vim /etc/default/grub GRUB_TIMEOUT=1 清理工作rm -rf /etc/ssh/*key*. rm -rf /root/.ssh/ systemctl stop rsyslog systemctl stop auditd /usr/bin/yum clean all logrotate -f /etc/logrotate.conf rm -f /var/log/dmesg.old rm -rf /var/log/anaconda* cat /dev/null > /var/log/audit/audit.log cat /dev/null > /var/log/wtmp cat /dev/null > /var/log/lastlog cat /dev/null > /var/log/grubby 清除系统的唯一ID> /etc/machine-id 清除系统命令历史记录unset HISTFILE history -c && rm -rf /root/.bash_histroy Sys-unconfig关机执行sys-unconfig等待关机,然后转换为模板。
通过systemd管理软件和服务
发表于2019-09-17|更新于2025-09-23|Linux
通过systemctl 来管理系统的服务和软件,但是如果是自己安装的软件就没有办法使用了。其实是可以自己定义systemd的管理脚本的,类似与之前的SysV风格的管理脚本。 Systemd systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and automount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. 管得还是挺多的,主要是启动PID为1的进程并启动其他的程序,并行执行,维护挂载点及自动挂载,服务之间的依赖关系,日志进程, Systemd的Units文件Systemd默认的文件配置路径有: - /etc/systemd/system/* - /run/systemd/system/* - /usr/lib/systemd/system/* Systemd Unit File 的模板有这样的几个模块: [Unit] [Service] [Install] UnitUnit的作用是记录文件的通用信息。 Descripition – 对软件或服务的描述。 Before OR After – 定义启动的顺序,在某些服务 启动之前 OR 启动之后 ,在启动这个服务。其中还定义了服务的依赖关系,先后顺序。常用的值有 network.target, Multi-User.target, network.service 等等。 Requires – 并行启动所指定的其他服务。 RequireOverrideable – 类似与require,但是不同的是手动启动的时候不会报错。 Requisite – 只要启动失败了就直接报错停止,强硬版本的requires。 Wants – 启动依赖单元的常用选项,在启动的同时调起其他的Unit,如果其他单元启动失败了也不会影响当前定义的Unit的启动。 Conflicts – 冲突单元,启动的时候发现了Conflict中定义的其他单元就会尝试终止Unit。 Service Type – 对服务类型的定义,通常有如下三种:- simple 默认的类型,启动就启动,停止就结束了。- forking 守护进程的类型,把必要的启动之后留下守护进程。- oneshot 一次性的服务,启动后就结束了。 ExecStart – 启动的时候执行的命令, 这条命令就是服务的主体。 ExecStartPre OR ExecStartPost – ExecStart执行前后的动作。 ExecStop – 指定服务结束的动作,如果未指定直接kill。 Restart – 定义了重启的条件和动作,常用的参数有: no, on-sucess, on-failure, on-watchdog, on-abort。 SuccessExitStatus – ExecStart的返回值。 SuccessExitStatus=1 2 8 SIGKILL Install WantedBy – 定义启动的情景,几种不同的target: multi-user.target | poweroff.target | rescue.target | graphical.target | reboot.target Alias – 别名的设置在这里定义。 标准配置文件 - Libvirtd[Unit] Description=Virtualization daemon Requires=virtlogd.socket Requires=virtlockd.socket Wants=systemd-machined.service Before=libvirt-guests.service After=network.target After=dbus.service After=iscsid.service After=apparmor.service After=local-fs.target After=remote-fs.target After=systemd-logind.service After=systemd-machined.service Documentation=man:libvirtd(8) Documentation=https://libvirt.org [Service] Type=simple EnvironmentFile=-/etc/conf.d/libvirtd ExecStart=/usr/bin/libvirtd $LIBVIRTD_ARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure # At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent). # eg if we want to support 4096 guests, we'll typically need 8192 FDs # If changing this, also consider virtlogd.service & virtlockd.service # limits which are also related to number of guests LimitNOFILE=8192 # The cgroups pids controller can limit the number of tasks started by # the daemon, which can limit the number of domains for some hypervisors. # A conservative default of 8 tasks per guest results in a TasksMax of # 32k to support 4096 guests. TasksMax=32768 [Install] WantedBy=multi-user.target Also=virtlockd.socket Also=virtlogd.socket
ElasticSearch 安装记录
发表于2019-09-11|更新于2025-09-23|ElasticSearch
ElasticSearch的安装过程。 准备源码包 需要下载的包有三个:网站地址 ElasticSearch- 分布式、RESTful 风格的搜索和分析。/usr/local/src/elasticsearch Logstash - 采集、转换、充实,然后输出。/usr/local/src/logstash Kibana - 实现数据可视化。在 Elastic Stack 中进行导航。/usr/local/src/kibana 安装 ElasticSearch 解压下载的安装包 tar zxvf elasticsearch-7.3.1-linux-x86_64.tar.gz tar zxvf kibana-7.3.1-linux-x86_64.tar.gz tar zxvf logstash-7.3.1.tar.gz 修改系统参数 vim /etc/sysctl.conf fs.file-max=65535 vm.max_map_count=262144 sysctl -p : 重新读取配置文件中的参数,更新的条目会显示在命令执行结果中。 vim /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft noproc 4096 * hard noproc 4096 保存退出。 建立elk用户 useradd elk -p "YOUR-PASSWD" 将/usr/local/src/elasticsearch目录的权限给elk用户。 chown -R elk:elk /usr/local/src/elasticsearch/ 在/usr/local/src/elasticsearch/elasticsearch/config/目录下修改配置文件elasticsearch.yml。 cluster.name: CLUSTER_NAME node.name: HOSTNAME & ROLES node.master: true node.data: true network.host: YOUR_HOSTNAME discovery.zen.ping.unicast.hosts: ["YOUR_OTHER_NODE_HOSTNAME "] 切换到elk用户,尝试启动elk su elk cd /usr/local/src/elasticsearch/elasticsearch/bin/ ./elasticsearch 如果没有错误就可以使用 -d 选项将服务启动到后台。
文件系统及文件管理
发表于2019-07-24|更新于2025-09-23|Linux
Linux文件管理笔记 文件系统默认的规定是遵守FHS规定的。 FHS(Filesystem Hierarchy Standard) defines the directory structure and directory contents in Linux distributions.FHS_Website 标准的根文件系统,应该具有如下的结构,所有的文件目录均在根文件系统下。 /bin – 单用户模式下可运行的二进制命令。所有用户都可以使用。 /sbin – 基本的系统二进制文件。 /boot – 一般为BootLoaderFiles,例如内核,ramfs,grub等等。 /etc – 常用的应用程序的全局配置文件。Host-specific system-wide configruation。 /etc/opt – /opt目录下的程序的配置文件。 /usr – 包含了主要的多用户工具及应用。 /usr/share – Architecture-independent(shared) data.独立架构的共享数据。 /usr/sbin – 非基础的系统库文件,例如网络管理的守护进程。 /usr/src – 放内核源码及头文件的目录。 /usr/bin – 非基础的命令二进制文件,不需要运行在单用户模式下的命令。 /usr/local – 特指存放本地的数据,例如源码包,二进制包等等。 /usr/lib – /usr/bin & /usr/sbin下的命令所需要的库文件。 /opt – Optional application software packages. /mnt – 文件系统的临时挂载位置。 /media – 默认的可移动设备挂载位置。 /dev – 所有的设备,字符设备,块设备。 /lib – 为/bin & /sbin目录下的文件及程序提供的库文件。 /lib64 – 可替代格式的库文件,这个目录不是必须存在的,例如64位程序会需要这个目录。 /tmp – 临时文件存放目录。定期清除。 /sys – 设备,驱动,一些内核功能的相关信息。 /proc – 虚拟文件系统展示进程及内核信息文件。系统启动目录创建,系统关闭目录消失。 /var – 变量文件。在系统运行的过程中反复变化的文件。比如日志,邮件,信息输出等。 /var/log – 系统应用程序产生的日志文件默认存放路径。 /var/spool/mail – 每个用户的邮件。 /home – 用户的家目录,saved files, personal settings,etc. Bash文件色彩显示的定义在: /etc/DIR_COLORS , 文件中定义了所有文件类型在Bash中的色彩。新技巧: 有一个$OLDPWD,可通过cd - 切换到上一次离开的目录
Kubernetes集群的学习笔记(2)
发表于2019-07-23|更新于2025-09-23|Kubernetes
Kubernetes的基本使用命令。 对控制命令进行分类整理: 查看k8s整体状态的命令 kubectl describe node node1.docker 查看node的详细信息 kubectl version 查看kube的版本信息,同时显示客户端的版本及服务端的版本 kubectl cluster-info 查看kube的集群信息,master节点的所在地址及kubeDNS的所在地址 手动运行Pods的命令 kubectl run nginx –image=nginx –replicas=5 启动5个nginx的pods kubectl run nginx –image=nginx –port:80 –replicas=5 –dry-run=true 启动5个nginx的pod的测试,但不执行改变,并expose端口80 查看Pods的命令 kubectl get pods 列出所有节点正在运行的pod的状态信息 kubectl get deployment 列出所有的deployment控制器的信息,所有的pod属于cni0桥,不属于docker桥 删除单独一个Pods的命令 kubectl delete pods hayden-nginx-6dd3ffd4c5-ww7mk删除一个指定的pod 手动建立Pods并对外发布的命令 kubectl expose deployment hayden-nginx –type=[{ClusterIP},NodePort,LoadBalancer,ExternalName] –name=nginx-service –target-port=80 –protocol=TCP创建一个新的service,将内部的通信以service的形式对外交付 查看svc状态的命令 kubectl get svc查看service的状态 查看属于某个名称空间的命令 kubectl get nodes -n kube-system -o wide查看属于kube-system的节点的信息 kubectl get svc -n kube-system -o wide查看属于kube-system的服务的信息 从不重启Pods的设置 kubectl run t-centos –image=centos -it –restart=Never –replicas=1启动1个普通的容器作为客户端进行服务的访问 kubectl describe svc nginx-service查看指定服务的详细信息 kubectl get nodes –show-labels查看节点的标签 对svc进行编辑和修改 kubectl edit svc nginx-service编辑一个service的属性,命令打开vim的编辑界面进行配置文件的更改 kubectl delete svc nginx-service删除一个service kubectl get deployment -w长时间监控一个控制器的状态改变 对Pods的升级和回滚 kubectl set image deployment hayden-nginx hayden-nginx=nginx:latest对容器指定其他的镜像进行动态的升级及更新 kubectl rollout status deployment hayden-nginx对容器版本的更新进行进度的查看 指定版本的回滚 kubectl rollout undo deployment hayden-nginx对升级的版本进行回滚,可指定回滚的版本,默认是上一个版本 Service发布到NodePort外部访问到service的方法是定义type为NodePort,可在创建service的时候定义类型,或者使用kubectl edit svc nginx-service将type变更为NodePort 。 创建资源的逻辑思路刚从docker的管理思路过来的时候还是有些茫然, 不太知道该怎么用。其实从k8s的管理逻辑上,我们将之前的container 变更为 pod,将pod的管理交给一个deployment,将deployment已经启动的所有容器通过对外提供service的方式expose到外部。例如:我需要一个httpd服务,不需要直接去docker启动了,我直接在k8s上定义一个deployment-httpd,通过k8s的控制器去调度容器。如果需要控制容器对外提供服务,那就直接创建一个service,通过service去直接定义和管理对外的服务即可。
1…111213…16
avatar
Liarlee
Archlinux User, Support Engineer
文章
156
标签
74
分类
16
Follow Me
公告
都道无人愁似我,今夜雪,有梅花,似我愁。
最新文章
CheatSheet_Kubernetes2333-12-08
CheatSheet_Linux2333-12-08
CheatSheet_Databases2333-12-08
CheatSheet_awscli2333-12-08
PeaZip添加智能解压到win11右键菜单2025-09-14
Fortio 笔记2025-05-09
分类
  • AWS2
  • Application6
  • Books5
  • Database8
  • Docker6
  • EKS5
  • ESXi1
  • ElasticSearch2
标签
VIM Bash Ranger Docker GRUB2 Strace Memory cert OpenSearch RIME SElinux Python Tailscale RPM Perf Prometheus JAVA Ceph PeaZip EBS Application Harbor Steam EKS Firefox Personal CoreOS btrfs English CPU EC2 Ansible LVM TrueNasScale MySQL Redis Kubernetes NAS IO Cilium
归档
  • 十二月 23334
  • 九月 20251
  • 五月 20251
  • 十一月 20241
  • 九月 20242
  • 八月 20241
  • 七月 20243
  • 六月 20242
网站资讯
文章数目 :
156
本站总字数 :
183.1k
本站访客数 :
本站总访问量 :
最后更新时间 :
©2020 - 2025 By Liarlee
框架 Hexo|主题 Butterfly
搜索
数据库加载中