配置JDK環境:
JAVA_HOME:D:\software\JDK1.7
Path:%JAVA_HOME%\bin;%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