通过Mondo Rescue开源工具来实现linux系统的打包备份,如果你经常需要安装很多软件在服务器上,并且服务器较多,那么是否需要直接将你已安装好的系统打包成镜像文件,然后制作成你自己的系统,之后只需要直接安装就可以了。
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Friday, September 6, 2019
Sunday, July 14, 2019
Linux运维跳槽必备面试题
如何优化 Linux系统(可以不说太具体)?
1、root,添加普通用户,通过sudo授权管理;2、更改默认的远程连接SSH服务端口及禁止root用户远程连接;3、自动更新服务器时间;4、配置国内yum源;5、关闭selinux及iptables(iptables工作场景如果有外网IP一定要打开,高并发除外); 6、调整文件描述符的数量;7、精简开机启动服务(crond rsyslog network sshd);8、内核参数优化(/etc/sysctl.conf);9、更改字符集,支持中文,但建议还是用英文字符集,防止乱码;10、锁定关键系统文件;11、清空/etc/issue,去除系统及内核版本登录前的屏幕显示
Centos开机流程:
1、开机加电自检,加载BIOS的硬件信息,获取第一个启动设备;2、读取第一个启动设备MBR的引导加载程序(grub)的启动信息;3、加载核心操作系统的核心信息,核心开始解压缩,并尝试驱动所有的硬件设备;4、核心执行init程序,并获取默认的运行信息;5、init程序执行/etc/rc.d/rc.sysinit文件;6、启动核心的外挂模块;7、init执行运行的各个批处理文件scripts;8、init执行/etc/rc.d/rc.local;9、执行/bin/login程序,等待用户登录;10、登录后开始以shell控制主机。
1、root,添加普通用户,通过sudo授权管理;2、更改默认的远程连接SSH服务端口及禁止root用户远程连接;3、自动更新服务器时间;4、配置国内yum源;5、关闭selinux及iptables(iptables工作场景如果有外网IP一定要打开,高并发除外); 6、调整文件描述符的数量;7、精简开机启动服务(crond rsyslog network sshd);8、内核参数优化(/etc/sysctl.conf);9、更改字符集,支持中文,但建议还是用英文字符集,防止乱码;10、锁定关键系统文件;11、清空/etc/issue,去除系统及内核版本登录前的屏幕显示
Centos开机流程:
1、开机加电自检,加载BIOS的硬件信息,获取第一个启动设备;2、读取第一个启动设备MBR的引导加载程序(grub)的启动信息;3、加载核心操作系统的核心信息,核心开始解压缩,并尝试驱动所有的硬件设备;4、核心执行init程序,并获取默认的运行信息;5、init程序执行/etc/rc.d/rc.sysinit文件;6、启动核心的外挂模块;7、init执行运行的各个批处理文件scripts;8、init执行/etc/rc.d/rc.local;9、执行/bin/login程序,等待用户登录;10、登录后开始以shell控制主机。
Friday, May 17, 2019
磁盘空间不足的故障处理和系统中增加swap(实战经验)
1、du命令的学习
du 使用方法,磁盘block满了,使用这个命令找出哪些文件或目录占用的空间大
大小三者的区别:du du -h--人类可以读的方式 du -sh 显示目录的
du 使用方法,磁盘block满了,使用这个命令找出哪些文件或目录占用的空间大
大小三者的区别:du du -h--人类可以读的方式 du -sh 显示目录的
Thursday, August 24, 2017
Bandwidth Arbitrator 9.62 on Debian Sarge 2.6.5
It is from http://www.linuxhelp.net/forums/lofiversion/index.php/t7763.html
Introduction :
This is going to be a Badwidth Arbitrator (ver 9.62) install guide on Debian Sarge
First of all you will need to download Debian Sarge cd1 from here http://cdimage.debian.org/debian-cd/3.1_r2...86-binary-1.iso .
Note about the computer I used for my network of 145~ computers and a 512kbit/s down, and 512kbit/s up optical line :
CPU : Intel Pentium 3Ghz
RAM : 256 MB DDR
HDD : 80GB Western Digital ( because I was unable to find a smaller drive at the time)
ETHERNET : 2x Realtek 100Mbps (RTL8193too) ( but any other will do, if you can go with intel , intel seems to be better supported by some software)
START
You put in the Debian Sarge cd1 into your machine and you just install it choosing the apropriate time zones , locations ... root password etc,etc.
Once you went trough the installer which is quiet simple for Debian Sarge. You will do the following,
first login as root and type the following.
This will take a while to download, once it is done do the following :
With this the kernel is in place, so now let's go focus on the bridge utils :
Now it's time to move on to the kernel source (2.6.5) :
WARNING:
If you used for example realtek cards when you install rh9 it detected them and it is working, but if you look at Network Devices and 100mbps ethernet in menuconfig you'll see that they are compiled in as modules only, now this will be a problem , since rh9 will no longer see the realtek cards once you reboot to the 2.4.19 kernel, so instead of using the rtl8139 as module you must compile it in , change that M in front of it to a * .
Once done edit your /usr/src/linux/.config file and make sure the following are set to Y otherwise
you'll have problems.
config_fb=y
config_fb_vesa=y
config_framebuffer_console=y
Then search for EXT3 in the config file and select Y for everything that has a EXT3 in it , otherwise the new kernel won't be able to see your file system, thus wont boot.
With this the bridge utils and kernel menu config are done for now, let's continue with installing Arbitrator9.62.
You basically select Y till the end, that will install arbitrator to the right places, so now we compile
bridge-utils again.
Now we'll continue compiling the new kernel :
Now we need to create the /boot/initrd.img-2.6.5 so you'll need to download the right tools and do
the following :
So the finall step is to add the new kernel into your /boot/grub/menu.lst file , add the following few
lines right after the original Debian Sarge kernel 2.4.x entry :
title Debian GNU/Linux, kernel 2.6.5
root (hd0,0)
kernel /boot/vmlinuz-2.6.5 root=/dev/hda1 ro vga=788
initrd /boot/initrd.img-2.6.5
savedefault
boot
You might wanna remove vga=788 if you get a blank screen , otherwise it's gona enable you to view the screen at a higher resolution.
Once this is done type , you'll need to edit the following file to make arbitrator autostart on restart :
/etc/init.d/bootmisc.sh
Add the following few lines to the end of it :
Don't forget to modify the ip addresses here according to your own needs.
Now copy the brctl and brctld file to the following location /usr/local/sbin/ like this :
Once done edit /etc/arbdefault.conf make sure the ip address there matches the ip address you used for the bridge !!!
Reboot, and there you have it Arbitrator 9.62 on kernel 2.6.5 running .
This would be recommended for those who used the older Arbitrator on 2.4.19 kernel and encountered panics sometimes. Those should try to upgrade to this newer Arbitrator.
END
Introduction :
This is going to be a Badwidth Arbitrator (ver 9.62) install guide on Debian Sarge
First of all you will need to download Debian Sarge cd1 from here http://cdimage.debian.org/debian-cd/3.1_r2...86-binary-1.iso .
Note about the computer I used for my network of 145~ computers and a 512kbit/s down, and 512kbit/s up optical line :
CPU : Intel Pentium 3Ghz
RAM : 256 MB DDR
HDD : 80GB Western Digital ( because I was unable to find a smaller drive at the time)
ETHERNET : 2x Realtek 100Mbps (RTL8193too) ( but any other will do, if you can go with intel , intel seems to be better supported by some software)
START
You put in the Debian Sarge cd1 into your machine and you just install it choosing the apropriate time zones , locations ... root password etc,etc.
Once you went trough the installer which is quiet simple for Debian Sarge. You will do the following,
first login as root and type the following.
CODE
apt-get build-dep kernel-source-2.6.8
apt-get install libncurses5-dev
cd /home
wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.5.tar.gz
wget http://www.bandwidtharbitrator.com/bridge-utils-0.9.5.tar
wget http://www.bandwidtharbitrator.com/downloads/arbitrator9.62.tar.gz
apt-get install libncurses5-dev
cd /home
wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.5.tar.gz
wget http://www.bandwidtharbitrator.com/bridge-utils-0.9.5.tar
wget http://www.bandwidtharbitrator.com/downloads/arbitrator9.62.tar.gz
This will take a while to download, once it is done do the following :
CODE
cd /usr/src
tar zxfv /home/linux-2.6.5.tar.gz
ln -s linux-2.6.5 linux
ln -s linux-2.6.5 linux-2.6
tar zxfv /home/linux-2.6.5.tar.gz
ln -s linux-2.6.5 linux
ln -s linux-2.6.5 linux-2.6
With this the kernel is in place, so now let's go focus on the bridge utils :
CODE
mkdir /bridge
cd /bridge
tar xvf /home/bridge-utils-0.9.5.tar
cd /bridge-utils
make
cd /bridge
tar xvf /home/bridge-utils-0.9.5.tar
cd /bridge-utils
make
Now it's time to move on to the kernel source (2.6.5) :
CODE
cd /usr/src/linux
make menuconfig
make menuconfig
WARNING:
If you used for example realtek cards when you install rh9 it detected them and it is working, but if you look at Network Devices and 100mbps ethernet in menuconfig you'll see that they are compiled in as modules only, now this will be a problem , since rh9 will no longer see the realtek cards once you reboot to the 2.4.19 kernel, so instead of using the rtl8139 as module you must compile it in , change that M in front of it to a * .
Once done edit your /usr/src/linux/.config file and make sure the following are set to Y otherwise
you'll have problems.
config_fb=y
config_fb_vesa=y
config_framebuffer_console=y
Then search for EXT3 in the config file and select Y for everything that has a EXT3 in it , otherwise the new kernel won't be able to see your file system, thus wont boot.
With this the bridge utils and kernel menu config are done for now, let's continue with installing Arbitrator9.62.
CODE
mkdir /art
cd /
tar zxvf /home/arbitrator9.62.tar.gz
cd /arbitrator9.62.tar.gz
./install.sh
cd /
tar zxvf /home/arbitrator9.62.tar.gz
cd /arbitrator9.62.tar.gz
./install.sh
You basically select Y till the end, that will install arbitrator to the right places, so now we compile
bridge-utils again.
CODE
cd /bridge/bridge-utils
make
make
Now we'll continue compiling the new kernel :
CODE
make
make bzImage
make modules
make modules_install
make install
make bzImage
make modules
make modules_install
make install
Now we need to create the /boot/initrd.img-2.6.5 so you'll need to download the right tools and do
the following :
CODE
apt-get install module-init-tools
mkinitrd -o /boot/initrd.img-2.6.5 2.6.5
mkinitrd -o /boot/initrd.img-2.6.5 2.6.5
So the finall step is to add the new kernel into your /boot/grub/menu.lst file , add the following few
lines right after the original Debian Sarge kernel 2.4.x entry :
CODE
title Debian GNU/Linux, kernel 2.6.5
root (hd0,0)
kernel /boot/vmlinuz-2.6.5 root=/dev/hda1 ro vga=788
initrd /boot/initrd.img-2.6.5
savedefault
boot
You might wanna remove vga=788 if you get a blank screen , otherwise it's gona enable you to view the screen at a higher resolution.
Once this is done type , you'll need to edit the following file to make arbitrator autostart on restart :
/etc/init.d/bootmisc.sh
Add the following few lines to the end of it :
CODE
/usr/local/sbin/brctl addbr my
/usr/local/sbin/brctl addif my eth0
/usr/local/sbin/brctl addif my eth1
/sbin/ifconfig eth0 0.0.0.0
/sbin/ifconfig eth1 0.0.0.0
/sbin/ifconfig my 192.168.10.3 netmask 255.255.255.0 up
/sbin/route add default gw 192.168.10.1
/etc/init.d/arbitrate start
/usr/local/sbin/brctl addif my eth0
/usr/local/sbin/brctl addif my eth1
/sbin/ifconfig eth0 0.0.0.0
/sbin/ifconfig eth1 0.0.0.0
/sbin/ifconfig my 192.168.10.3 netmask 255.255.255.0 up
/sbin/route add default gw 192.168.10.1
/etc/init.d/arbitrate start
Don't forget to modify the ip addresses here according to your own needs.
Now copy the brctl and brctld file to the following location /usr/local/sbin/ like this :
CODE
cd /bridge/brctl
cp brctl /usr/local/sbin
chmod 700 /usr/local/sbin/brctl
cp brctld /usr/local/sbin
chmod 700 /usr/local/sbin/brctld
cp brctl /usr/local/sbin
chmod 700 /usr/local/sbin/brctl
cp brctld /usr/local/sbin
chmod 700 /usr/local/sbin/brctld
Once done edit /etc/arbdefault.conf make sure the ip address there matches the ip address you used for the bridge !!!
Reboot, and there you have it Arbitrator 9.62 on kernel 2.6.5 running .
This would be recommended for those who used the older Arbitrator on 2.4.19 kernel and encountered panics sometimes. Those should try to upgrade to this newer Arbitrator.
END
Wednesday, July 12, 2017
Linux Learning Resources
马哥linux运维教程全套(初级中级高级)
Linux系统管理技术手册 - Linux Administration Handbook, 2nd.pdf
Unix and Linux系统管理技术手册 - Evi Nemeth, Garth Snyder, Trent R. Hein - UNIX and Linux System Administration Handbook, 4th Edition - 2010.pdf
掌握好这23个Linux命令常用项,可加薪30%
运维工程师(Operations)在国内又称为运维开发工程师(Devops),在国外称为 SRE(SiteReliability Engineering)。负责维护并确保整个服务的高可用性,同时不断优化系统架构、提升部署效率、优化资源利用率提高整体的ROI。
作为工作几年的Linux运维老司机,总结了Linux命令行的常用的一些用法,希望对您有所收获。
1. 搜索
在vi和vim中如果打开一个很大的文件,不容易找到对应的内容,可以使用自带的搜索关键字进行搜索定位:
在vi和vim界面中输入:"/"(反斜杠),之后会出现一个输入框让你输入,当你输入的关键字在文件中存在就会以高亮的形式显示出来,之后按回车就确定定位到当前高亮位置,如果不是你要找的,则可以按:"n",意即寻找下一个输入关键字的内容。
2. vim恢复以及乱码问题
(1) 在vi和vim中如果不小心误删除了一些东西,想要恢复怎么办?
首先要退出编辑状态,即按Esc键,之后再按u撤销之前的修改的内容。
(2) 在用vi或vim打开一个文件的时候,如果有些地方出现一些特殊符号或是乱码,可以通过以下命令尝试:
vim -b mytest.php(其中-b一般是用来查看对应的二进制文件的)
3. 管道命令,即竖杠-->'|'
上面的意思是:将查询出来的内容交给管道后面的命令装饰之后再展示出来
例如:cat install.log | more (more的意思是将一屏放不下的内容以分页的形式显示)
- ls -l /etc | more
如果想看上一页的内容,可以通过:Shift + PageUp 来查看
管道配合grep(过滤)可以达到很好用的组合例如:
cat -n hello.txt | grep "hello" (查看hello.txt文件内容,并过滤出来带有hello的内容) ,-n 表示显示出来第几行的内容
4. find 搜寻文件或目录
find /home -name hello* (查找home目录下的文件名或目录为hello的)
find / -name h?m* (在跟目录下查找h开头第二个字符是任意的,第三个是m,后面的是任意的字符)
find / -size +1000000k (表示在根目录下查询文件大于1000000K的文件)
5 字符串替换命令
:s/well/good/替换当前行第一个well 为 good
:s/well/good/g 替换当前行所有well 为 good
:n,$s/well/good/ 替换第 n 行开始到最后一行中每一行的第一个 well 为 good
:n,$s/well/good/g 替换第 n 行开始到最后一行中每一行所有 well 为 good
n 为数字,若 n 为 .,表示从当前行开始到最后一行
:%s/well/good/ (等同于 :g/well/s//good/) 替换每一行的第一个 well 为 good
:%s/well/good/g (等同于 :g/well/s//good/g) 替换每一行中所有 well 为 good
特殊符号转义:可以使用#作为分隔符,此时中间出现的 / 不会作为分隔符
:s#well/#good/# 替换当前行第一个 well/ 为 good/
:%s#/usr/bin#/bin#g可以把文件中所有路径/usr/bin换成/bin
6. 重定向命令
ls -l /etc/ 希望
ls -l /etc > /home/myback.txt (覆盖重定向)把显示的结果覆盖到/home/myback.txt中去
ls -l /etc >> /home/myback.txt (追加重定向)把显示的结果追加到/home/myback.txt中去
7. 删除多行
删除多行步骤如下:
1. 首先要显示对应的行数这样方能知道从第几行到第几行删除
: set nu
2. 按Esc键退出,在命令行中输入:190,6233d(即[190 , 6233]都删除掉)
如果想要情况整个文件内容,在直接运行以下命令:
清空文件内容:> log.txt
8. 行位定位
直接定位到最后一行:
按Esc键退出,在命令行中输入: G
直接定位到第一行:
按Esc键退出,在命令行中输入: 1 G
直接定位到某一行:(第17行)
按Esc键退出,在命令行中输入:17 G
9. 复制一行或多行
<1. 复制一行
yy 复制当前行
p 粘贴
<2. 复制多行
7yy从当前行开始复制7行
p 粘贴
10. Linux中查看python的版本
- python -V
或者
- python --version
11. grep 的用法
<1. 显示匹配的后n行 (after)
- grep -A n
<2. 显示匹配的前n行 (before)
- grep -B n
<3. 显示匹配的前后n行 (context)
- grep -C n
<4. 忽略大小写
- grep -i str
12. ll或ls显示说明
ll -ht (h会按照标准格式自动转换大小即:456M,1.2G等,t 表示显示内容按照时间倒序排列)
应用案例:
清空8月份的日志文件:
- rm -rf `ll -ht | awk '/8月/ {print6,6,NF}' | awk '{print $NF}'`
说明:awk '/pattern/action'--> awk '/8月/{print6,6,NF}',只显示第六行与最后一行的内容且只保留8月的列表内容显示。
ls中文件颜色的显示代表的意义为:
1.蓝色--> 目录
2.绿色--> 可执行文件
3.红色--> 压缩文件
4.浅蓝色--> 链接文件
5.灰色--> 其他文件
13. 查看某文件被哪个进程所占用
lsof 文件名
14. 创建用户以及查看当前用户
- useradd redis
- passwd redis
如果是Ubuntu系统则需要使用如下命令:
- useradd openstack -m -s /bin/bash
- userdel -r openstack
查看当前系统存在的用户组和用户
/etc/group文件包含所有组
/etc/shadow和/etc/passwd系统存在的所有用户名
15. 常用查看文件大小与Linux系统命令
查看内存使用情况: free -m (m为MB,g为GB)
查看对应磁盘使用情况: df -lh
查看对应CPU使用情况: cat /proc/cpuinfo
会有32个大致相同的内容展示(下标是从0开始的),这就说明该服务器为8核操作系统
或者有更牛逼的命令:
cat /proc/cpuinfo | grep "model name" | head -1(只显示一行对应的CPU型号以及其他信息)
cat /proc/cpuinfo | grep "model name"(系统有几个核就会显示几行)
cat /proc/cpuinfo | grep "model name" | wc -l(统计出一共有多少核)
查看对应服务器版本当前操作系统发行版信息: cat /etc/issue 或 cat /etc/redhat-release
查看更为底层的版本信息: cat /proc/version (例如:CentOS实际最根源为RetHat,此命令将会显示所采用RetHat的版本)
如果想查看某个文件夹当前所占用的空间使用:
- du -h node (cd /data/solr-4.8.0/)
如果想查看当前目录下的所有文件各个大小
- du -sh * (cd /)
16. 查看内存情况
<1. jstat -gc pid 可以看到对应各个内存大小、使用状况以及GC处理情况
<2. jmap -heap [pid] 查看内存分布
<3. jstat -gcutil [pid] 1000 每隔1s输出java进程的gc情况
17. 修改文件夹及其里面的内容的权限
- chown -R solr:solr /home/solr/lib
意思是将 /home/solr/lib 文件夹及其里面内容的用户所属权限修改为solr用户所属权限
18. 查看某个端口链接状态的连接数
- netstat -nlap | grep -i est | grep -i 6379 | awk '{print $4}'
- netstat -nlap | grep -i est | grep -i 1121 | wc -l
平时使用总结,使用此命令如果实在记不住后面参数有哪些,那么直接记住为:-nlap 即可,大部分情况都可以满足我们的需求
netstat常见参数如下:
-a (all)显示所有选项,默认不显示LISTEN相关
-t (tcp)仅显示tcp相关选项
-u (udp)仅显示udp相关选项
-n 拒绝显示别名,能显示数字的全部转化成数字。
-l 仅列出有在 Listen (监听) 的服務状态
-p 显示建立相关链接的程序名
-r 显示路由信息,路由表
-e 显示扩展信息,例如uid等
-s 按各个协议进行统计
-c 每隔一个固定时间,执行该netstat命令。
提示:LISTEN和LISTENING的状态只有用-a或者-l才能看到
grep -i(i表示忽略大小写)
awk '{print $4}'(表示只打印第4列)
grep -i est(est表示:ESTABLISHED,即只显示ESTABLISHED即连接状态的端口)
grep命令最后的那个显示出来的结果以它进行标红,即最后一个grep为:grep -i 6379, 那么打印出来的结果其中的6379标红,结果如下如所示:
19. 同步服务器的时间
- ntpdate pool.ntp.org
将这个命令启用为定时脚本执行,具体如下所示:
1 */2 * * * ntpdate pool.ntp.org
20.不允许ssh登录如何配置
修改vim /etc/sysconfig/sshd_config文件,增加一行:AllowUsers solr,具体如下所示:
使其生效运行如下命令:
- service sshd reload
常用系统级配置总结:
1. 限制登录:/etc/ssh/sshd_config 修改后需重启:service sshd restart
2. 用户配置:/etc/passwd
3. sudo权限:/etc/sudoers
21. 常用JDK系统环境变量配置
1.JAVA_HOME=/usr/java/jdk1.7.0_55
2.CLASSPATH=.:$JAVA_HOME/lib.tools.jar
3.PATH=$JAVA_HOME/bin:$PATH
4.exportJAVA_HOME CLASSPATH PATH
22.查看Redis/Tomcat的版本
- redis-cli info | grep 'redis_version'
tomcat版本需要进入到安装目录下的 bin/ 文件夹:
./version.sh或者sh version.sh
23.怎么看linux的防火墙是否阻止80端口
- 1iptables -vnL |grep":80 "
返回有内容说明开通,没返回内容,则说明阻。
来源:马哥Linux运维
Friday, April 15, 2016
数据库中间件OneProxy使用手册
撰写日期
|
2016年4月1日
|
文档版本
|
v1.0
|
作者
|
李强
|
阅读人群
|
运维、DBA
|
联系方式
|
QQ:1164258114
|
文档声明
|
本手册以作者生产环境为参考,对OneProxy的常用功能使用进行简单的说明;
手册中的groupname、username、password等均为虚构的;
本手册暂不涉及OneProxy的分库分表功能;
本手册中不涉及Percona的编译安装过程;
本手册中假定每个集群的数据库主从都已做好
本手册结合Oneproxy官方文档结合阅读更好
|
变更记录
|
Subscribe to:
Posts (Atom)