首页 文章 精选 留言 我的

精选列表

搜索[AI运维],共10000篇文章
优秀的个人博客,低调大师

《Oracle高性能自动化运维》一一3.1 Redo功能用途

3.1 Redo功能用途Redo是Oracle数据库最重要的组成部分之一,其主要功能有:数据库恢复(Recovery):数据库出现异常故障时,可以利用Redo实现数据库级的恢复;介质恢复(Media Recovery):数据库物理介质异常(丢失、坏块等情况)时,可以利用Redo进行介质恢复;实例恢复(Instance Recovery):数据库实例异常崩溃时,可以借助Redo自动进行实例恢复;日志挖掘(Log Miner):数据库业务数据异常(误删除数据等情况)时,可以借助日志挖掘还原业务数据;流复制(Stream):可以借助Redo流复制实现数据同步功能;数据安全卫士(DataGuard):通过将主库(Master)节点的Redo传递、应用到从库(Standby),实现数据库架构层面的高可用性以及读写分离;数据同步(Golden

优秀的个人博客,低调大师

全新Linux+Python高端运维班第三次作业

1、找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello(); [root@tom~]#grep-E-o"[_[:alpha:]]+\(\)"/etc/rc.d/init.d/functions fstab_decode_str() checkpid() __readlink() __fgrep() __kill_pids_term_kill_checkpids() __kill_pids_term_kill() __umount_loop() __source_netdevs_fstab() __source_netdevs_mtab() __umount_loopback_loop() __find_mounts() __pids_var_run() __pids_pidof() daemon() killproc() pidfileofproc() pidofproc() status() echo_success() echo_failure() echo_passed() echo_warning() update_boot_stage() success() failure() passed() warning() action() action_silent() strstr() confirm() get_numeric_dev() is_ignored_file() is_true() is_false() apply_sysctl() key_is_random() find_crypto_mount_point() init_crypto() 2、使用echo命令输出一个绝对路径,使用grep取出其基名; 扩展:取出其路径名 [root@tom~]#echo/etc/sysconfig/network-scripts/ifcfg-eth0|grep-E-o"[^/]+$" ifcfg-eth0 #extended# [root@tom~]#echo/etc/sysconfig/network-scripts/ifcfg-eth0|grep-E-o"/.*/" /etc/sysconfig/network-scripts/ 3、找出ifconfig命令结果中的1-255之间数字; [root@tom~]#ifconfig eth0Linkencap:EthernetHWaddr08:00:27:DA:EF:CA inetaddr:172.18.11.121Bcast:172.18.11.127Mask:255.255.255.128 inet6addr:fe80::a00:27ff:feda:efca/64Scope:Link UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1 RXpackets:21714errors:0dropped:0overruns:0frame:0 TXpackets:915errors:0dropped:0overruns:0carrier:0 collisions:0txqueuelen:1000 RXbytes:1479394(1.4MiB)TXbytes:133705(130.5KiB) loLinkencap:LocalLoopback inetaddr:127.0.0.1Mask:255.0.0.0 inet6addr:::1/128Scope:Host UPLOOPBACKRUNNINGMTU:65536Metric:1 RXpackets:0errors:0dropped:0overruns:0frame:0 TXpackets:0errors:0dropped:0overruns:0carrier:0 collisions:0txqueuelen:0 RXbytes:0(0.0b)TXbytes:0(0.0b) [root@tom~]#ifconfig|egrep-o"\<([1-9]|[0-9]{2}|1[0-9]{2}|2[0-5]{2})\>" 08 00 27 172 18 11 121 172 18 11 127 255 255 255 128 64 1 2 1 224 2 127 1 255 1 128 1 4、查找当前系统上没有属主或属组的文件; 进一步:查找当前系统上没有属主或属组,且最近3天内曾被访问过的文件或目录; [root@tom~]#find/\(-nouser-o-nogroup\)-a-ls|wc-l find:`/proc/21565/task/21565/fd/5':Nosuchfileordirectory find:`/proc/21565/task/21565/fd/5':Nosuchfileordirectory find:`/proc/21565/task/21565/fdinfo/5':Nosuchfileordirectory find:`/proc/21565/task/21565/fdinfo/5':Nosuchfileordirectory find:`/proc/21565/fd/5':Nosuchfileordirectory find:`/proc/21565/fd/5':Nosuchfileordirectory find:`/proc/21565/fdinfo/5':Nosuchfileordirectory find:`/proc/21565/fdinfo/5':Nosuchfileordirectory 1842 #Nextstep# [root@tom~]#find/\(-nouser-o-nogroup\)-a-atime-3-ls|wc-l find:`/proc/21574/task/21574/fd/5':Nosuchfileordirectory find:`/proc/21574/task/21574/fdinfo/5':Nosuchfileordirectory find:`/proc/21574/fd/5':Nosuchfileordirectory find:`/proc/21574/fdinfo/5':Nosuchfileordirectory 214 5、查找/etc目录下大于1M,且类型为普通文件的所有文件; [root@tom~]#find/etc-size+1M-typef-execls-lh{}\; -rw-r--r--.1rootroot8.1MDec1616:43/etc/selinux/targeted/modules/active/policy.kern -rw-r--r--.1rootroot8.1MDec1616:43/etc/selinux/targeted/policy/policy.24 -rw-r--r--.1rootroot2.2MDec1616:10/etc/gconf/gconf.xml.defaults/%gconf-tree.xml 6、查找/etc/init.d/目录下,所有用户都有执行权限,且其它用户有写权限的文件; [root@tom~]#find/etc/init.d/-perm113 [root@tom~]#ls-lh/etc/init.d/ total440K -rwxr-xr-x.1rootroot1.3KMay122016abrt-ccpp -rwxr-xr-x.1rootroot1.6KMay122016abrtd -rwxr-xr-x.1rootroot1.7KMay122016abrt-oops -rwxr-xr-x.1rootroot1.8KFeb172016acpid -rwxr-xr-x.1rootroot2.1KFeb202015atd -rwxr-xr-x.1rootroot3.5KMay112016auditd -rwxr-xr-x.1rootroot4.0KJul122016autofs -r-xr-xr-x.1rootroot1.4KAug2402:37blk-availability -rwxr-xr-x.1rootroot710Nov112010bluetooth -rwxr-xr-x.1rootroot2.1KMay92016certmonger -rwxr-xr-x.1rootroot12KJul242015cpuspeed -rwxr-xr-x.1rootroot2.8KAug2402:36crond -rwxr-xr-x.1rootroot3.0KMay112016cups -rwxr-xr-x.1rootroot1.7KMay112016dnsmasq -rwxr-xr-x.1rootroot3.2KJul92013firstboot -rw-r--r--.1rootroot25KApr122016functions -rwxr-xr-x.1rootroot1.8KOct152014haldaemon -rwxr-xr-x.1rootroot5.9KApr122016halt -rwxr-xr-x.1rootroot2.0KNov1907:49htcacheclean -rwxr-xr-x.1rootroot3.5KNov1907:49httpd -rwxr-xr-x.1rootroot11KJul242015ip6tables -rwxr-xr-x.1rootroot6.6KMay112016ipsec -rwxr-xr-x.1rootroot11KJul242015iptables -rwxr-xr-x.1rootroot1.9KFeb22016irqbalance -rwxr-xr-x.1rootroot21KNov1823:19kdump -rwxr-xr-x.1rootroot652Apr122016killall -r-xr-xr-x.1rootroot2.1KAug2402:37lvm2-lvmetad -r-xr-xr-x.1rootroot3.0KAug2402:37lvm2-monitor -rwxr-xr-x.1rootroot2.6KJun212016mdmonitor -rwxr-xr-x.1rootroot2.2KApr222015messagebus -rwxr-xr-x.1rootroot6.9KMay112016mysqld -rwxr-xr-x.1rootroot3.0KApr122016netconsole -rwxr-xr-x.1rootroot5.2KApr122016netfs -rwxr-xr-x.1rootroot6.3KApr122016network -rwxr-xr-x.1rootroot2.2KMay112016NetworkManager -rwxr-xr-x.1rootroot6.8KOct504:27nfs -rwxr-xr-x.1rootroot3.5KOct504:27nfslock -rwxr-xr-x.1rootroot1.9KMay32016ntpd -rwxr-xr-x.1rootroot2.0KMay32016ntpdate -rwxr-xr-x.1rootroot2.3KMay112016oddjobd -rwxr-xr-x.1rootroot2.5KMay312010openct -rwxr-xr-x.1rootroot2.2KJul242015pcscd -rwxr-xr-x.1rootroot2.0KMay112016portreserve -rwxr-xr-x.1rootroot3.9KNov102015postfix -rwxr-xr-x.1rootroot9.5KNov522:08postgresql-9.2 -rwxr-xr-x.1rootroot1.7KMay112016pppoe-server -rwxr-xr-x.1rootroot1.6KJul172012psacct -rwxr-xr-x.1rootroot2.0KJan72015quota_nld -rwxr-xr-x.1rootroot1.5KNov132015rdisc -rwxr-xr-x.1rootroot1.8KNov1823:30restorecond -rwxr-xr-x.1rootroot1.8KSep222015rngd -rwxr-xr-x.1rootroot2.1KMay112016rpcbind -rwxr-xr-x.1rootroot2.5KOct504:27rpcgssd -rwxr-xr-x.1rootroot2.3KOct504:27rpcidmapd -rwxr-xr-x.1rootroot2.5KOct504:27rpcsvcgssd -rwxr-xr-x.1rootroot2.0KDec102014rsyslog -rwxr-xr-x.1rootroot1.7KNov1823:30sandbox -rwxr-xr-x.1rootroot2.1KFeb272015saslauthd -rwxr-xr-x.1rootroot647Apr122016single -rwxr-xr-x.1rootroot3.0KFeb222013smartd -rwxr-xr-x.1rootroot2.2KAug2402:47snmpd -rwxr-xr-x.1rootroot1.7KAug2402:47snmptrapd -rwxr-xr-x.1rootroot2.5KMay112016spice-vdagentd -rwxr-xr-x.1rootroot4.6KMay122016sshd -rwxr-xr-x.1rootroot2.7KJul122016sssd -rwxr-xr-x.1rootroot1.2KMay112016sysstat -rwxr-xr-x.1rootroot2.3KSep622:51udev-post -rwxr-xr-x.1rootroot16KNov616:42vboxadd -rwxr-xr-x.1rootroot3.0KNov616:43vboxadd-service -rwxr-xr-x.1rootroot21KNov616:43vboxadd-x11 -rwxr-xr-x.1rootroot3.4KMay112016vsftpd -rwxr-xr-x.1rootroot1.7KFeb222013wdaemon -rwxr-xr-x.1rootroot1.6KAug2402:58winbind -rwxr-xr-x.1rootroot1.9KNov1822:26wpa_supplicant -rwxr-xr-x.1rootroot5.0KMay112016ypbind 7、查找/etc目录下最近一周内其内容被修改过,且不属于root或hadoop的文件; [root@tom~]#find/etc-mtime-7-a-not\(-userroot-o-userhadoop\) [root@tom~]# 8、复制/etc/rc.d/rc.sysinit文件至/tmp目录,将/tmp/rc.sysinit文件中的以至少一个空白字符开头的行的行首加#; [root@tom~]#cp/etc/rc.d/rc.sysinit/tmp [root@tom~]#ls-lh/tmp total24K drwx------.2rootroot4.0KDec1119:18pulse-0QUeAoK4lJM6 -rwxr-xr-x.1rootroot20KFeb1217:07rc.sysinit [root@tom~]#head-n20/tmp/rc.sysinit #!/bin/bash # #/etc/rc.d/rc.sysinit-runonceatboottime # #TakeninpartfromMiquelvanSmoorenburg'sbcheckrc. # HOSTNAME=$(/bin/hostname) set-m if[-f/etc/sysconfig/network];then ./etc/sysconfig/network fi if[-z"$HOSTNAME"-o"$HOSTNAME"="(none)"];then HOSTNAME=localhost fi if[!-e/proc/mounts];then mount-n-tproc/proc/proc [root@tom~]#vim/tmp/rc.sysinit #在末行模式下输入: :%s@^[[:space:]]\+@#&@g [root@tom~]#head-n20/tmp/rc.sysinit #!/bin/bash # #/etc/rc.d/rc.sysinit-runonceatboottime # #TakeninpartfromMiquelvanSmoorenburg'sbcheckrc. # HOSTNAME=$(/bin/hostname) set-m if[-f/etc/sysconfig/network];then #./etc/sysconfig/network fi if[-z"$HOSTNAME"-o"$HOSTNAME"="(none)"];then #HOSTNAME=localhost fi if[!-e/proc/mounts];then #mount-n-tproc/proc/proc [root@tom~]#head-n20/tmp/rc.sysinit #!/bin/bash # /etc/rc.d/rc.sysinit-runonceatboottime # TakeninpartfromMiquelvanSmoorenburg'sbcheckrc. # HOSTNAME=$(/bin/hostname) set-m if[-f/etc/sysconfig/network];then ./etc/sysconfig/network fi if[-z"$HOSTNAME"-o"$HOSTNAME"="(none)"];then HOSTNAME=localhost fi if[!-e/proc/mounts];then mount-n-tproc/proc/proc 9、删除/tmp/rc.sysinit文件中的以#开头,且后面跟了至少一个空白字符的行行的#和空白字符 [root@tom~]#head-n20/tmp/rc.sysinit #!/bin/bash # #/etc/rc.d/rc.sysinit-runonceatboottime # #TakeninpartfromMiquelvanSmoorenburg'sbcheckrc. # HOSTNAME=$(/bin/hostname) set-m if[-f/etc/sysconfig/network];then #./etc/sysconfig/network fi if[-z"$HOSTNAME"-o"$HOSTNAME"="(none)"];then #HOSTNAME=localhost fi if[!-e/proc/mounts];then #mount-n-tproc/proc/proc [root@tom~]#vim/tmp/rc.sysinit #在末行模式下输入: :%s@^#[[:space:]]\+@@g [root@tom~]#head-n20/tmp/rc.sysinit #!/bin/bash # /etc/rc.d/rc.sysinit-runonceatboottime # TakeninpartfromMiquelvanSmoorenburg'sbcheckrc. # HOSTNAME=$(/bin/hostname) set-m if[-f/etc/sysconfig/network];then ./etc/sysconfig/network fi if[-z"$HOSTNAME"-o"$HOSTNAME"="(none)"];then HOSTNAME=localhost fi if[!-e/proc/mounts];then mount-n-tproc/proc/proc 10、将/etc/yum.repos.d/CentOS-Media.repo文件中所有的enabled=0或gpgcheck=0的最后的0修改为1; [root@tom~]#cat/etc/yum.repos.d/CentOS-Media.repo #CentOS-Media.repo # #ThisrepocanbeusedwithmountedDVDmedia,verifythemountpointfor #CentOS-6.Youcanusethisrepoandyumtoinstallitemsdirectlyoffthe #DVDISOthatwerelease. # #Tousethisrepo,putinyourDVDanduseitwiththeotherrepostoo: #yum--enablerepo=c6-media[command] # #orforONLYthemediarepo,dothis: # #yum--disablerepo=\*--enablerepo=c6-media[command] [c6-media] name=CentOS-$releasever-Media baseurl=file:///media/CentOS/ file:///media/cdrom/ file:///media/cdrecorder/ gpgcheck=1 enabled=0 gpgkey= [root@tom~]#vi/etc/yum.repos.d/CentOS-Media.repo #在末行模式下输入: :%s/\(enabled\|gpgcheck\)=0/\1=1/g [root@tom~]#cat/etc/yum.repos.d/CentOS-Media.repo #CentOS-Media.repo # #ThisrepocanbeusedwithmountedDVDmedia,verifythemountpointfor #CentOS-6.Youcanusethisrepoandyumtoinstallitemsdirectlyoffthe #DVDISOthatwerelease. # #Tousethisrepo,putinyourDVDanduseitwiththeotherrepostoo: #yum--enablerepo=c6-media[command] # #orforONLYthemediarepo,dothis: # #yum--disablerepo=\*--enablerepo=c6-media[command] [c6-media] name=CentOS-$releasever-Media baseurl=file:///media/CentOS/ file:///media/cdrom/ file:///media/cdrecorder/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 11、每周2,4,6备份/var/log/messages文件至/backup/messages_logs/目录中,保存的文件名形如messages-20161202 [root@tom~]#crontab-e nocrontabforroot-usinganemptyone crontab:installingnewcrontab [root@tom~]#crontab-l #Backup/var/log/messagesto/backup/messages_logs/ateveryweek2,4,6--sam ****2,4,6cp/var/log/messagesbackup/messages_logs/messages-$(date+%Y%m%D) 12、每天每两小时取当前系统/proc/meminfo文件中的所有以S开头的信息至/stats/memory.txt文件中 [root@tom~]#crontab-e crontab:installingnewcrontab [root@tom~]#crontab-l #Backup/var/log/messagesto/backup/messages_logs/ateveryweek2,4,6--sam ****2,4,6cp/var/log/messagesbackup/messages_logs/messages-$(date+%Y%m%D) #每天每两小时取当前系统/proc/meminfo文件中的所有以S开头的信息至/stats/memory.txt文件中 **/2***cat/proc/meminfo|grep"^S">>/stats/memory.txt 13、写一个脚本创建10用户user10-user19;密码同用户名; [root@tombin]#vimuadd #!/bin/bash #adduser10-user19. for((i=10;i<=19;i++));do iduser$i&>/dev/null&&exit0||useradduser$i&&echo"user$i"|passwd--stdinuser$i done [root@tombin]#ll total4 -rw-r--r--.1rootroot155Feb1218:02uadd [root@tombin]#chmod755uadd [root@tombin]#ll total4 -rwxr-xr-x.1rootroot155Feb1218:02uadd [root@tombin]#uadd Changingpasswordforuseruser10. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser11. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser12. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser13. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser14. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser15. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser16. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser17. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser18. passwd:allauthenticationtokensupdatedsuccessfully. Changingpasswordforuseruser19. passwd:allauthenticationtokensupdatedsuccessfully. [root@tombin]#tail/etc/passwd user10:x:3009:3009::/home/user10:/bin/bash user11:x:3010:3010::/home/user11:/bin/bash user12:x:3011:3011::/home/user12:/bin/bash user13:x:3012:3012::/home/user13:/bin/bash user14:x:3013:3013::/home/user14:/bin/bash user15:x:3014:3014::/home/user15:/bin/bash user16:x:3015:3015::/home/user16:/bin/bash user17:x:3016:3016::/home/user17:/bin/bash user18:x:3017:3017::/home/user18:/bin/bash user19:x:3018:3018::/home/user19:/bin/bash

优秀的个人博客,低调大师

【运维小实验】基于VMware的虚拟Linux集群搭建-lvs+keepalived

通过keepalived实现lvs服务器的的双机热备和真实服务器之间的负载均衡的blog挺多的,在搭建的时候也参考了相关博文,不同人搭建的实验环境不一样,本文是基于VM搭建的虚拟集群环境,全部虚拟机网卡模式为NAT方式相连,处于同一网段。 搭建环境: 使用redhead 2.6.32-431.el6.x86_64版本的linux,创建四台,配置相关网络信息,确保同一网段下。 配置好各自ip即可,虚拟ip在配置lvs时设定。 安装配置LVS 1.在主备Lvs上安装ipvsadm和keepalived LVS是通过IPVS模块实现的,检查kernel是否支持LVS的IPVS模块,再安装IPVS管理软件ipvsadm [root@rex ~]# modprobe -l | grep ipvs kernel/net/netfilter/ipvs/ip_vs.ko kernel/net/netfilter/ipvs/ip_vs_rr.ko kernel/net/netfilter/ipvs/ip_vs_wrr.ko kernel/net/netfilter/ipvs/ip_vs_lc.ko kernel/net/netfilter/ipvs/ip_vs_wlc.ko kernel/net/netfilter/ipvs/ip_vs_lblc.ko kernel/net/netfilter/ipvs/ip_vs_lblcr.ko kernel/net/netfilter/ipvs/ip_vs_dh.ko kernel/net/netfilter/ipvs/ip_vs_sh.ko kernel/net/netfilter/ipvs/ip_vs_sed.ko kernel/net/netfilter/ipvs/ip_vs_nq.ko kernel/net/netfilter/ipvs/ip_vs_ftp.ko kernel/net/netfilter/ipvs/ip_vs_pe_sip.ko 安装ipvsadm [root@rex ~]# yum install ipvsadm 能通过ipvsadm --help查看相关信息即安装成功。 安装keepalived 安装依赖库:yum install -y openssl openssl-devel(我是缺这两个,具体编译时候如果报错则安装相关提示补安装相关缺漏) 下载keepalived: http://www.keepalived.org/software/keepalived-1.2.6.tar.gz 安装命令: # tar zxvf keepalived-1.2.6.tar.gz # cd keepalived-1.2.6 # ./configure --sysconf=/etc --with-kernel-dir=/lib/modules/2.6.32-431.el6.x86_64 #指定配置文件存放路径,指定使用内核源码中的头文件。 #make #make install #ln -s /usr/local/sbin/keepalived /sbin/ #把启动命令软连接到sbin,方便以后直接使用 能通过keepalived --help查看相关信息即安装成功。 配置LVS: 主LVS: ! Configuration File for keepalived global_defs { notification_email {#配置告警邮件发送 XXXX@qq.com } notification_email_from Keepalived@localhost smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL } vrrp_instance VI_1 { state MASTER#主LVS标志 interface eth1#设置对外服务口 virtual_router_id 51 priority 100#设置优先级,优先级高的为主机 advert_int 1#设置同步时间间隔 authentication {#设置主备LVS验证类型和密码,两边必须一致 auth_type PASS auth_pass 1111 } virtual_ipaddress {#设置虚拟服务IP 192.168.153.110 } } virtual_server 192.168.153.110 80 { delay_loop 6#健康检查时间间隔 lb_algo rr#负载均衡算法,此为轮询算法 lb_kind DR#负载均衡转发规则,也就是IP转发规则,DR转发方式最快,但是所有机器必须在一个网段内,还有NAT和TUNEL两种转发方式 protocol TCP real_server 192.168.153.131 80 { weight 1 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } real_server 192.168.153.135 80 { weight 1 TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 } } } 备用LVS配置:复制上面配置修改两处即可:1.state MASTER改为state BACKUP 2.将priority 100改低,这里改为80 配置Realserver 对所有Realserver重复做一下步骤 在/etc/init.d下创建脚本lvsrs 1 #!/bin/bash 2 3 VIP=192.168.153.110 4 ./etc/rc.d/init.d/functions 5 case "$1" in 6 start) 7 echo "Start LVS of Realserver!" 8 /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up 9 echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore 10 echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce 11 echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore 12 echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce 13 14 ;; 15 16 stop) 17 18 /sbin/ifconfig lo:0 down 19 echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore 20 echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce 21 echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore 22 echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce 23 echo "RealServer Stoped" 24 25 ;; 26 27 *) 28 29 echo "Usage: $0 {start|stop}" 30 31 exit 1 32 33 esac 修改其执行权限:chmod 755 /etc/init.d/lvsrs 执行启动脚本: #service lvsrs start 查看其ip: lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:480 (480.0 b) TX bytes:480 (480.0 b) lo:0 Link encap:Local Loopback inet addr:192.168.153.110 Mask:255.255.255.255 UP LOOPBACK RUNNING MTU:16436 Metric:1 在realserver上安装apache并且启动! 在/var/www/hmtl/下添加index.html测试主页,不同server用不同界面进行区分。 启动LVS并且测试: 主备LVS启动:/etc/init.d/keepalived start 查看启动状态: 主LVS: Feb 4 20:11:41 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Transition to MASTER STATE Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Entering MASTER STATE Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) setting protocol VIPs. Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth2 for 192.168.153.110 Feb 4 20:11:42 rex Keepalived_healthcheckers[9521]: Netlink reflector reports IP 192.168.153.110 added Feb 4 20:11:47 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth2 for 192.168.153.110 备LVS: Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Received higher prio advert Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Entering BACKUP STATE Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) removing protocol VIPs. Feb 4 20:18:16 rex Keepalived_healthcheckers[9521]: Netlink reflector reports IP 192.168.153.110 removed Feb 4 20:19:06 rex dhclient[1265]: DHCPREQUEST on eth2 to 192.168.153.254 port 67 (xid=0x6f9b7b38) 用ip addr和ipvsadm查看路由情况 主LVS# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:3e:ce:ce brd ff:ff:ff:ff:ff:ff inet 192.168.153.133/24 brd 192.168.153.255 scope global eth1 inet 192.168.153.110/32 scope global eth1 inet6 fe80::20c:29ff:fe3e:cece/64 scope link valid_lft forever preferred_lft forever 备LVS# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:0e:6c:b0 brd ff:ff:ff:ff:ff:ff inet 192.168.153.134/24 brd 192.168.153.255 scope global eth2 inet6 fe80::20c:29ff:fe0e:6cb0/64 scope link valid_lft forever preferred_lft forever [root@rex ~]# ipvsadm IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP bogon:http rr -> bogon:http Route 1 0 0 -> bogon:http Route 1 0 0 测试: 1.高可用×××测试--主备lvs切换 把主lvs stop!然后查看备lvs日志,然后把主恢复,再看备lvs的日志 Feb 4 20:11:41 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Transition to MASTER STATE Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Entering MASTER STATE Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) setting protocol VIPs. Feb 4 20:11:42 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth2 for 192.168.153.110 Feb 4 20:11:42 rex Keepalived_healthcheckers[9521]: Netlink reflector reports IP 192.168.153.110 added Feb 4 20:11:47 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth2 for 192.168.153.110 Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Received higher prio advert Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) Entering BACKUP STATE Feb 4 20:18:16 rex Keepalived_vrrp[9522]: VRRP_Instance(VI_1) removing protocol VIPs. Feb 4 20:18:16 rex Keepalived_healthcheckers[9521]: Netlink reflector reports IP 192.168.153.110 removed Feb 4 20:19:06 rex dhclient[1265]: DHCPREQUEST on eth2 to 192.168.153.254 port 67 (xid=0x6f9b7b38) Feb 4 20:19:06 rex dhclient[1265]: DHCPACK from 192.168.153.254 (xid=0x6f9b7b38) Feb 4 20:19:06 rex dhclient[1265]: bound to 192.168.153.134 -- renewal in 737 seconds. Feb 4 20:19:06 rex NetworkManager[1241]: <info> (eth2): DHCPv4 state changed renew -> renew Feb 4 20:19:06 rex NetworkManager[1241]: <info> address 192.168.153.134 Feb 4 20:19:06 rex NetworkManager[1241]: <info> prefix 24 (255.255.255.0) Feb 4 20:19:06 rex NetworkManager[1241]: <info> gateway 192.168.153.2 Feb 4 20:19:06 rex NetworkManager[1241]: <info> nameserver '192.168.153.2' Feb 4 20:19:06 rex NetworkManager[1241]: <info> domain name 'localdomain' 2.负载均衡测试 在本地浏览器上访问192.168.153.110,不断刷新,可以看到代表不同realserver的主界面。 3.故障切换测试 把realserver1的服务stop掉,查看LVS的日志,然后恢复再看: Feb 4 20:25:59 rex Keepalived_healthcheckers[9588]: Netlink reflector reports IP 192.168.153.110 added Feb 4 20:26:04 rex Keepalived_vrrp[9589]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth1 for 192.168.153.110 Feb 4 20:27:53 rex Keepalived_healthcheckers[9588]: TCP connection to [192.168.153.135]:80 failed !!! Feb 4 20:27:53 rex Keepalived_healthcheckers[9588]: Removing service [192.168.153.135]:80 from VS [192.168.153.110]:80 Feb 4 20:27:53 rex Keepalived_healthcheckers[9588]: Remote SMTP server [192.168.200.1]:25 connected. Feb 4 20:28:14 rex Keepalived_healthcheckers[9588]: Error reading data from remote SMTP server [192.168.200.1]:25. Feb 4 20:28:29 rex Keepalived_healthcheckers[9588]: TCP connection to [192.168.153.135]:80 success. Feb 4 20:28:29 rex Keepalived_healthcheckers[9588]: Adding service [192.168.153.135]:80 to VS [192.168.153.110]:80 Feb 4 20:28:29 rex Keepalived_healthcheckers[9588]: Remote SMTP server [192.168.200.1]:25 connected.

优秀的个人博客,低调大师

让脚本替你看住 MisakaNet:腾讯云 CVM 自动化运维清单

MisakaNet(失败经验库)作者 Ikalus1988,Apache 2.0 许可,GitHub 仓库 493 star,官网 misakanet.org。核心就是一份 Git 仓库:393 条去重后的 canonical lessons、333 个节点,检索用纯 Python 标准库实现 BM25,既不需要数据库,也没有常驻进程。形态轻,要盯的事就少。一台腾讯云 CVM 上值得自动化的事情只有三件:同步有没有跟上上游、检索还能不能用、仓库与配置有没有备份。

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册