配置JDK环境:
JAVA_HOME:D:softwareJDK1.7
Path:%JAVA_HOME%in;%JAVA_HOME%lib;
ls(查看当前目录下的文件及文件夹)
sh initNetwork.sh(执行初始化网卡的脚本)
ifup eth0 (启动网卡)
ifconfig -a(192.168.238.128)
配置网卡,一劳永逸,不需要每次重启都配置了,
(把'ifup eth0'输入到/etc/rc.d文件下的rc.local脚本文件中,
rc.local脚本就是每次重启都会自动加载的脚本文件):
echo 'ifup eth0'>>/etc/rc.d/rc.local
重启生效:
reboot
关闭防火墙:service iptables stop
关闭防火墙自启动:chkconfig iptables off
查看防火墙状态:service iptables status
修改主机的名字;配置主机的链接地址:
vi /etc/sysconfig/network
vi /etc/hosts
cd ~ :切换到家目录
cd - :切换到上一次操作的目录
cd .. :切换到上级目录
cd 路径 :切换到路径参数指定目录
pwd :显示当前文件的绝对路径
vi 可编辑的查看文件
vim
less 不能修改查看文件
[root@localhost install]# mkdir -p lhj/kk/ll
[root@localhost install]# tree lhj/
lhj/
└── kk
└── ll
2 directories, 0 files
[root@localhost install]# ll
总用量 8
-rwxr-xr-x. 1 root root 492 7月 16 20:20 initNetwork.sh
drwxr-xr-x. 3 root root 4096 11月 28 00:12 lhj
[root@localhost install]# rm -rf lhj
[root@localhost install]# ls
initNetwork.sh
[root@localhost install]# echo liyongfu
liyongfu
[root@localhost install]# 定义一个变量myage
[root@localhost install]# myage=28
[root@localhost install]# echo $myage
28
[root@localhost install]# echo "my age is 20"
my age is 20
[root@localhost install]# 在文本中写字符串用单引号;如果字符串中有字符,则外面的用双引号,里面的用单引号;
touch是没有该文件就创建,有就不创建
[root@localhost test]# touch mysql.ini
[root@localhost test]# echo 123 > mysql.ini
[root@localhost test]# cat mysql.ini
123
[root@localhost test]# cat -n mysql.ini
1 123
2 123456
[root@localhost test]# cat 是显示内容
[root@localhost test]# -n 是显示行数
[root@localhost test]# > 是覆盖
[root@localhost test]# >> 是追加
[root@localhost test]# 拷贝文件
[root@localhost test]# cp mysql.txt ./mysql.ini
[root@localhost test]# ls
mysql.ini mysql.txt
[root@localhost install]# cp -r test test02/
[root@localhost install]# 拷贝文件夹,带-r
[root@localhost install]# 删除系统下所有文件,系统瘫痪
[root@localhost install]# rm -rf /*
[root@localhost test]# 计算文件的行数
[root@localhost test]# cat mysql.txt|wc -l
7
[root@localhost ~]# cd /install/
[root@localhost install]# ls
initNetwork.sh test test02
[root@localhost install]# 压缩方式01
tar -czvf testdir.tar.gz testdir/ :将目录testdir下的文件打包并压缩
tar -xzvf testdir.tar.gz :解压到当前目录下
tar -zxvf testdir.tar.gz -C Downloads/ :解压到指定的Downloads目录下
[root@localhost install]# 压缩方式02
zip -r test02.zip test02/ :压缩文件夹test02为zip压缩格式,名字为test02.zip
unzip test02.zip -d /software :解压压缩文件test02.zip至/software;-d用来指定目录
[root@localhost install]# mkdir -p lhj/a/b lhj/c/d
[root@localhost install]# tree lhj
lhj
├── a
│ └── b
└── c
└── d
4 directories, 0 files
[root@localhost install]# rm -rf lhj
[root@localhost install]# ls
initNetwork.sh test02 test02.zip test.tar.gz
[root@localhost install]# mkdir -p lhj/a/{a,b}
[root@localhost install]# tree lhj
lhj
└── a
├── a
└── b
3 directories, 0 files
[root@localhost install]#
[root@localhost install]# :上面这行是独创方式
[root@localhost install]#
[root@localhost install]# rm -rf lhj && mkdir -p lhj/{a,b}/c
[root@localhost install]# tree lhj
lhj
├── a
│?? └── c
└── b
└── c
4 directories, 0 files
[root@localhost install]# rm -rf lhj
[root@localhost install]# ls
initNetwork.sh test02 test02.zip test.tar.gz
Linux软件的安装:(关注公众号,回复“linux000”获取相应软件下载链接)
(需要先执行yum install lrzsz -y)(这是在线安装方式,也可以离线方式)
上传文件的方式:
使用:rz -y
下载文件的方式:
使用:sz 文件名
上传文件的方式: (XShell自带的方式)
使用:[root@Redis02 redis-2.8.9]# exit
[d:~]$ sftp 192.168.238.128(需要上传的虚拟机ip)
[root@localhost install]# :文件上传
[root@localhost install]# rz -y :本地拷贝
[root@localhost install]# scp :表示远程拷贝
安装jdk:
[root@localhost install]# tar -zxvf jdk-7u10-linux-i586.gz -C /software
[root@Redis01 install]# vi /etc/profile
在该文件的最后添加:
JAVA_HOME=/software/jdk1.7.0_79
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/lib
export PATH JAVA_HOME
[root@Redis01 ~]# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
[root@Redis01 ~]# javac -version
javac 1.7.0_79
[root@Redis01 install]# mkdir test
[root@Redis01 install]# ls
initNetwork.sh jdk-7u79-linux-x64.tar.gz test
[root@Redis01 install]# cd test
[root@Redis01 test]# touch Test.java
[root@Redis01 test]# vi Test.java
[root@Redis01 test]# javac Test.java
[root@Redis01 test]# java Test
hello word
[root@Redis01 test]# cat Test.java
public class Test{
public static void main(String args[]){
System.out.println("hello word");
}
}
安装tomcat:
[root@Redis01 install]# rz -y
[root@Redis01 install]# ls
apache-tomcat-7.0.69.tar.gz initNetwork.sh
[root@Redis01 install]# tar -zxvf apache-tomcat-7.0.69.tar.gz -C /software
[root@Redis01 ~]# cd /software
[root@Redis01 software]# ls
apache-tomcat-7.0.69 jdk1.7.0_79
[root@Redis01 software]# mv apache-tomcat-7.0.69/ tomcat7.0
[root@Redis01 software]# ls
jdk1.7.0_79 tomcat7.0
[root@Redis01 software]# cd tomcat7.0/
[root@Redis01 tomcat7.0]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[root@Redis01 tomcat7.0]# rm -rf work/*
[root@Redis01 tomcat7.0]# rm -rf logs/*
[root@Redis01 tomcat7.0]# rm -rf temp/*
[root@Redis01 conf]# vi server.xml
vi编辑器中显示行号
:set nu
[root@Redis01 bin]# sh startup.sh
Using CATALINA_BASE: /software/tomcat7.0
Using CATALINA_HOME: /software/tomcat7.0
Using CATALINA_TMPDIR: /software/tomcat7.0/temp
Using JRE_HOME: /software/jdk1.7.0_79
Using CLASSPATH: /software/tomcat7.0/bin/bootstrap.jar:/software/tomcat7.0/bin/tomcat-juli.jar
Tomcat started.
[root@Redis01 bin]# lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 1734 root 42u IPv6 14996 0t0 TCP *:webcache (LISTEN)
[root@Redis01 bin]# ps -ef|grep tomcat
root 1734 1 9 23:11 pts/1 00:00:07 /software/jdk1.7.0_79/bin/java -Djava.util.logging.config.file=/software/tomcat7.0/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/software/tomcat7.0/endorsed -classpath /software/tomcat7.0/bin/bootstrap.jar:/software/tomcat7.0/bin/tomcat-juli.jar -Dcatalina.base=/software/tomcat7.0 -Dcatalina.home=/software/tomcat7.0 -Djava.io.tmpdir=/software/tomcat7.0/temp org.apache.catalina.startup.Bootstrap start
root 1754 1645 0 23:12 pts/1 00:00:00 grep tomcat
[root@Redis01 bin]# curl -I -X GET http://127.0.0.1:8080/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Tue, 28 Nov 2017 15:16:25 GMT
[root@Redis01 bin]# curl -I -X GET http://192.168.238.128:8080/
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Transfer-Encoding: chunked
Date: Tue, 28 Nov 2017 15:16:40 GMT
关闭防火墙:
[root@Redis01 bin]# service iptables stop
iptables:清除防火墙规则: [确定]
iptables:将链设置为政策 ACCEPT:filter [确定]
iptables:正在卸载模块: [确定]
[root@Redis01 bin]# sh shutdown.sh
Using CATALINA_BASE: /software/tomcat7.0
Using CATALINA_HOME: /software/tomcat7.0
Using CATALINA_TMPDIR: /software/tomcat7.0/temp
Using JRE_HOME: /software/jdk1.7.0_79
Using CLASSPATH: /software/tomcat7.0/bin/bootstrap.jar:/software/tomcat7.0/bin/tomcat-juli.jar
[root@Redis01 bin]# lsof -i:8080
安装mysql:
[root@Redis01 install]# rz -y
[root@Redis01 install]# unzip mysql-linux-5.5.32.zip
[root@Redis01 install]# ls
[root@Redis01 install]# cd mysql-ls-5.5.32/
[root@Redis01 mysql-ls-5.5.32]# ls
[root@Redis01 mysql-ls-5.5.32]# sh install.sh
[root@Redis01 software]# ls
jdk1.7.0_79 mysql-5.5.32
[root@Redis01 software]# cd mysql-5.5.32/
[root@Redis01 mysql-5.5.32]# ls
[root@Redis01 mysql-5.5.32]# cd sbin
[root@Redis01 sbin]# ls
[root@Redis01 sbin]# sh mysqld start
Starting MySQL SUCCESS!
[root@Redis01 sbin]# lsof -i:3306
[root@Redis01 sbin]# cd ../
[root@Redis01 mysql-5.5.32]# cd bin
[root@Redis01 bin]# ls
[root@Redis01 bin]# ./mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.5.32 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
mysql> use test
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> create table t_user(uid int(10) primary key auto_increment,uname varchar(30))engine=innodb charset=utf8;
Query OK, 0 rows affected (0.04 sec)
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| t_user |
+----------------+
1 row in set (0.01 sec)
mysql> select * from t_user;
Empty set (0.00 sec)
mysql> insert into t_user values(1,'ligang');
Query OK, 1 row affected (0.00 sec)
mysql> select * from t_user;
+-----+--------+
| uid | uname |
+-----+--------+
| 1 | ligang |
+-----+--------+
1 row in set (0.01 sec)
mysql> exit
Bye
[root@Redis01 bin]# ./mysql -uroot -p123456 -e"select * from test.t_user"
+-----+--------+
| uid | uname |
+-----+--------+
| 1 | ligang |
+-----+--------+
[root@Redis01 bin]# cd ../sbin/
[root@Redis01 sbin]# ls
[root@Redis01 sbin]# sh mysqld stop
Shutting down MySQL.. SUCCESS!
[root@Redis01 sbin]# lsof -i:3306
安装Oracle:
linux安装Oracle11G:参考这篇文章http://cnblogs.com/mmzs/p/9033112.html
安装Redis:
[root@Redis01 install]# ls
initNetwork.sh redis-2.8.9.zip
[root@Redis01 install]# unzip redis-2.8.9.zip -d /software
[root@Redis01 ~]# cd /software/
[root@Redis01 software]# ls
jdk1.7.0_79 mysql-5.5.32 redis-2.8.9 tomcat7.0
[root@Redis01 software]# cd redis-2.8.9/
[root@Redis01 redis-2.8.9]# ls
bin conf dump.rdb redis.log startRedis.sh stopRedis.sh
[root@Redis01 redis-2.8.9]# sh startRedis.sh
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 1639 root 4u IPv6 14055 0t0 TCP *:6379 (LISTEN)
redis-ser 1639 root 5u IPv4 14057 0t0 TCP *:6379 (LISTEN)
redis alreay running....
[root@Redis01 redis-2.8.9]# lsof -i:6379
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 1639 root 4u IPv6 14055 0t0 TCP *:6379 (LISTEN)
redis-ser 1639 root 5u IPv4 14057 0t0 TCP *:6379 (LISTEN)
[root@Redis01 redis-2.8.9]# cd bin/
[root@Redis01 bin]# ls
redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
[root@Redis01 bin]# ./redis-cli -h 192.168.238.128 -p 6379
192.168.238.128:6379> set myname ligang
OK
192.168.238.128:6379> get myname
"ligang"
192.168.238.128:6379> del myname
(integer) 1
192.168.238.128:6379> get myname
(nil)
192.168.238.128:6379> ./redis-cli -h 192.168.238.128 -p 6379 set myname zhangsan
192.168.238.128:6379> quit
安装zookeeper:
上传zookeeper-3.4.10的安装包;
解压到software下;
进入zookeeper-3.4.10创建文件夹data;
在data下创建文件myid,内容是1;
进入conf,复制一份zoo_sample.cfg命名为zoo.cfg;
修改zoo.cfg内容:
dataDir=/software/zookeeper-3.4.10/data
最后一行添加:
server.1=slave01:2888:3888
server.2=salve02:2888:3888
server.3=slave03:2888:3888