16.
以下是平台信息 CentOS Linux release 7.1.1503 (Core) Linux mysql-dev1 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 25 curl -O http://memcached.org/files/memcached-1.4.25.tar.gz 26 curl -O http://mirrors.cnnic.cn/apache/zookeeper/stable/zookeeper-3.4.8.tar.gz 27 curl -O http://www.apache.org/dyn/closer.cgi?path=/activemq/5.9.1/apache-activemq-5.9.1-bin.tar.gz 官网提供的这个链接无效 28 curl -O http://archive.apache.org/dist/activemq/5.9.1/apache-activemq-5.9.1-bin.tar.gz 31 curl -O https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz 1.免密码登录,就这两步 ssh-keygen -t rsa -P '' scp .ssh/id_rsa.pub 192.168.1.242:/root/.ssh/authorized_keys [root@manage ~]# cat manager.sh while echo "please input host which you want connect: " do select host in 240 241 242 238-db 247-db 248-db do break done case $host in "240") ssh 192.168.1.240;; "241") ssh 192.168.1.241;; "242") ssh 192.168.1.242;; "238-db") ssh 192.168.1.238;; "247-db") ssh 192.168.1.247;; "248-db") ssh 192.168.1.248;; *) break;; esac done 2.安装jdk与tomcat mkdir packages cd packages/ curl -O ftp://192.168.1.100/03%BF%AA%B7%A2%B9%A4%BE%DF/Java/jdk/jdk-7u79-linux-x64.rpm curl -O ftp://192.168.1.100/03%BF%AA%B7%A2%B9%A4%BE%DF/Tomcat/apache-tomcat-8.0.30.tar.gz rpm -ivh jdk-7u79-linux-x64.rpm cat <<EOF > /etc/profile.d/java.sh JAVA_HOME=/usr/java/jdk1.7.0_79 CLASSPATH=$CLASSPATH:$JAVA_HOME/lib PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH CLASSPATH EOF source /etc/profile tar zxvf apache-tomcat-8.0.30.tar.gz ./apache-tomcat-8.0.30/bin/startup.sh 3.安装mysql #hostnamectl set-hostname mysql-test-cn #systemctl stop firewalld #cd /root/packages/mysql #yum -y install perl net-tools nfs-utils #systemctl start rpcbind #rpm -e --nodeps mariadb-libs #mount 192.168.1.250:/nfs/html /mnt #cd /mnt #rpm -ivh mysql-commercial-client-5.7.10-1.1.el7.x86_64.rpm mysql-commercial-common-5.7.10-1.1.el7.x86_64.rpm mysql-commercial-libs-5.7.10-1.1.el7.x86_64.rpm mysql-commercial-server-5.7.10-1.1.el7.x86_64.rpm #systemctl start mysqld pass=$(grep "temporary password" /var/log/mysqld.log |awk -F ': ' '{print $2}') mysql --connect-expired-password -p"$pass" <<EOF SET PASSWORD FOR 'root'@'localhost'= "123456"; grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option; EOF #cd #umount /mnt echo $PWD 4.安装memcached memcached 1.4.15 libevent 2.0.21-stable yum install memcached vi /etc/sysconfig/memcached grep mem /etc/passwd systemctl status memcached systemctl start memcached systemctl enable memcached systemctl status memcached memcached-tool 127.0.0.1:11211 stats 5.安装zookeeper tar zxvf zookeeper-3.4.8.tar.gz cd zookeeper-3.4.8 cp conf/zoo_sample.cfg conf/zoo.cfg mkdir /home/zookeeper vi conf/zoo.cfg ./bin/zkServer.sh start/stop ss -lnp|grep zoo ss -lnp|grep 2181 ./bin/zkCli.sh -server 127.0.0.1:2181 6.安装activemq tar zxvf apache-activemq-5.9.1-bin.tar.gz cd packages/apache-activemq-5.9.1 ./bin/activemq start ss -lnp|grep 8161 ss -lnp|grep 11211 ss -lnp|grep java
15.
[Tue Jan 19 11:23:47 1101 /dev/pts/0 192.168.2.250 ~/sh]#bash legs
please enter name of an animal: ii
the ii has an unknown number of legs.
[Tue Jan 19 11:24:28 1101 /dev/pts/0 192.168.2.250 ~/sh]#bash legs
please enter name of an animal: dog
the dog has four legs.
[Tue Jan 19 11:25:20 1102 /dev/pts/0 192.168.2.250 ~/sh]#cat legs
echo -n "please enter name of an animal: " read animal echo -n "the $animal has " case $animal in horse|dog|cat)echo -n "four";; man|kangaroo)echo -n "two";; *)echo -n "an unknown number of";; esac echo " legs."
14.删除程序产生的日志,只保留一个当天日期的文件,并且在每天20点时清空此文件,感觉有点重复,要么只保留一个文件,要么清空都可以达到减少占用磁盘的目的。
[Thu Mar 26 10:01:40 1071 /dev/pts/1 192.168.2.109 /usr/local/ps/log]#cat /var/prtg/scripts/pslog #find /usr/local/ps/log -ctime +0|xargs rm -rf #>/usr/local/ps/log/debug* a=debug`date +%Y%m%d`.log for i in `ls *.log` do if [ "$i" != "$a" ] then rm -rf $i else >$i fi done
13.
黑白棋盘
其实是个双循环,
外层执行第一层循环时
内层共执行8次,并判断是单或双,
是单的话,total是双,tmp余数是0,输出背景为灰的两个空格
是双的话,total是单,tmp余数是1,输出背景为黑的两个空格
外层第一层最后一个echo ""是换行
然后执行第二层外循环
[Wed Mar 25|15:40:23 ~ 1081 /bin/bash ]# cat black #!/bin/bash for((i=1;i<=8;i++)) do for((j=1;j<=8;j++)) do total=$(($i+$j)) tmp=$(($total%2)) if [ $tmp -eq 0 ] then echo -e -n "