标签:inf rest isp 执行命令 vendor thread mysql的安装 inux format
安装linux和安装虚拟机略过,直接进行环境的安装
java环境变量:
1 export JAVA_HOME=/usr/jdk1.8.0_171 2 export PATH=$JAVA_HOME/bin:$PATH
1 [root@localhost ~]# find / -name "java" 2 /etc/pki/ca-trust/extracted/java 3 /etc/pki/java 4 /usr/jdk1.8.0_171/bin/java 5 /usr/jdk1.8.0_171/jre/bin/java
1 [root@localhost ~]# mv apache-tomcat-7.0.93 tomcat7 2 [root@localhost ~]# ll 3 总用量 8932 4 -rw-------. 1 root root 1501 11月 18 22:51 anaconda-ks.cfg 5 -rw-r--r--. 1 root root 9138957 11月 19 08:11 apache-tomcat-7.0.93.tar.gz 6 drwxr-xr-x. 9 root root 220 11月 19 08:13 tomcat7 7 [root@localhost ~]# cd tomcat7/ 8 [root@localhost tomcat7]# ll 9 总用量 132 10 drwxr-xr-x. 2 root root 4096 11月 19 08:13 bin 11 -rw-r--r--. 1 root root 18099 2月 17 2019 BUILDING.txt 12 drwxr-xr-x. 2 root root 158 2月 17 2019 conf 13 -rw-r--r--. 1 root root 6090 2月 17 2019 CONTRIBUTING.md 14 drwxr-xr-x. 2 root root 4096 11月 19 08:13 lib 15 -rw-r--r--. 1 root root 56846 2月 17 2019 LICENSE 16 drwxr-xr-x. 2 root root 6 2月 17 2019 logs 17 -rw-r--r--. 1 root root 1241 2月 17 2019 NOTICE 18 -rw-r--r--. 1 root root 3255 2月 17 2019 README.md 19 -rw-r--r--. 1 root root 9368 2月 17 2019 RELEASE-NOTES 20 -rw-r--r--. 1 root root 16978 2月 17 2019 RUNNING.txt 21 drwxr-xr-x. 2 root root 30 11月 19 08:13 temp 22 drwxr-xr-x. 7 root root 81 2月 17 2019 webapps 23 drwxr-xr-x. 2 root root 6 2月 17 2019 work
1 [root@localhost bin]# systemctl status firewalld(查看防火墙状态) 2 ● firewalld.service - firewalld - dynamic firewall daemon 3 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 4 Active: active (running) since 二 2019-11-19 07:25:34 CST; 1h 3min ago 5 Docs: man:firewalld(1) 6 Main PID: 654 (firewalld) 7 CGroup: /system.slice/firewalld.service 8 └─654 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid 9 10 11月 19 07:25:20 localhost.localdomain systemd[1]: Starting firewalld - dynamic fir.... 11 11月 19 07:25:34 localhost.localdomain systemd[1]: Started firewalld - dynamic fire.... 12 Hint: Some lines were ellipsized, use -l to show in full. 13 [root@localhost bin]# 14 [root@localhost bin]# 15 [root@localhost bin]# systemctl stop firewalld(暂时关闭防火墙) 16 [root@localhost bin]# systemctl disable firewalld(永久关闭防火墙) 17 Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. 18 Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
1 [root@localhost bin]# ps -aux|grep "tomcat" 2 root 12662 9.9 8.3 2288956 85008 pts/0 Sl 08:38 0:03 /usr/jdk1.8.0_171/bin/java -Djava.util.logging.config.file=/usr/tomcat7/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Dignore.endorsed.dirs= -classpath /usr/tomcat7/bin/bootstrap.jar:/usr/tomcat7/bin/tomcat-juli.jar -Dcatalina.base=/usr/tomcat7 -Dcatalina.home=/usr/tomcat7 -Djava.io.tmpdir=/usr tomcat7/temp org.apache.catalina.startup.Bootstrap start 3 root 12726 0.0 0.0 112720 980 pts/0 R+ 08:39 0:00 grep --color=auto tomcat
1 [root@localhost logs]# tail -f catalina.out 2 十一月 19, 2019 8:39:00 上午 org.apache.catalina.startup.HostConfig deployDirectory 3 信息: Deploying web application directory /usr/tomcat7/webapps/manager 4 十一月 19, 2019 8:39:00 上午 org.apache.catalina.startup.HostConfig deployDirectory 5 信息: Deployment of web application directory /usr/tomcat7/webapps/manager has finished in 59 ms 6 十一月 19, 2019 8:39:00 上午 org.apache.coyote.AbstractProtocol start 7 信息: Starting ProtocolHandler ["http-bio-8080"] 8 十一月 19, 2019 8:39:00 上午 org.apache.coyote.AbstractProtocol start 9 信息: Starting ProtocolHandler ["ajp-bio-8009"] 10 十一月 19, 2019 8:39:00 上午 org.apache.catalina.startup.Catalina start 11 信息: Server startup in 1658 ms 12 pwd
1 [root@localhost conf]# vim server.xml 2 [root@localhost conf]# pwd 3 /usr/tomcat7/conf 4 修改内容: 5 <Connector port="8081" protocol="HTTP/1.1" 6 connectionTimeout="20000" 7 redirectPort="8443" URIEncoding="UTF-8" />
1 [root@localhost /]# rpm -qa | grep mariadb 2 mariadb-libs-5.5.56-2.el7.x86_64 3 [root@localhost /]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64(卸载) 4 [root@localhost /]# rpm -qa | grep mariadb 5 [root@localhost /]#
1 [root@localhost /]# cd /root/mysql/ 2 [root@localhost mysql]# ls 3 mysql-community-client-5.6.42-2.el7.x86_64.rpm 4 mysql-community-common-5.6.42-2.el7.x86_64.rpm 5 mysql-community-libs-5.6.42-2.el7.x86_64.rpm 6 mysql-community-server-5.6.42-2.el7.x86_64.rpm 7 net-tools-2.0-0.22.20131004git.el7.x86_64.rpm 8 perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm 9 perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm 10 perl-Data-Dumper-2.145-3.el7.x86_64.rpm 11 perl-DBI-1.627-4.el7.x86_64.rpm 12 perl-IO-Compress-2.061-2.el7.noarch.rpm 13 perl-Net-Daemon-0.48-5.el7.noarch.rpm 14 perl-PlRPC-0.2020-14.el7.noarch.rpm
1 [root@localhost mysql]# rpm -ivh perl-* 2 准备中... ################################# [100%] 3 正在升级/安装... 4 1:perl-Net-Daemon-0.48-5.el7 ################################# [ 14%] 5 2:perl-Data-Dumper-2.145-3.el7 ################################# [ 29%] 6 3:perl-Compress-Raw-Zlib-1:2.061-4.################################# [ 43%] 7 4:perl-Compress-Raw-Bzip2-2.061-3.e################################# [ 57%] 8 5:perl-IO-Compress-2.061-2.el7 ################################# [ 71%] 9 6:perl-PlRPC-0.2020-14.el7 ################################# [ 86%] 10 7:perl-DBI-1.627-4.el7 ################################# [100%] 11 [root@localhost mysql]# rpm -ivh net-tools-2.0-0.22.20131004git.el7.x86_64.rpm 12 准备中... ################################# [100%] 13 正在升级/安装... 14 1:net-tools-2.0-0.22.20131004git.el################################# [100%] 15 [root@localhost mysql]# rpm -ivh mysql-community-common-5.6.42-2.el7.x86_64.rpm 16 警告:mysql-community-common-5.6.42-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 17 准备中... ################################# [100%] 18 正在升级/安装... 19 1:mysql-community-common-5.6.42-2.e################################# [100%] 20 [root@localhost mysql]# rpm -ivh mysql-community-libs-5.6.42-2.el7.x86_64.rpm 21 警告:mysql-community-libs-5.6.42-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 22 准备中... ################################# [100%] 23 正在升级/安装... 24 1:mysql-community-libs-5.6.42-2.el7################################# [100%] 25 [root@localhost mysql]# rpm -ivh mysql-community-client-5.6.42-2.el7.x86_64.rpm 26 警告:mysql-community-client-5.6.42-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 27 准备中... ################################# [100%] 28 正在升级/安装... 29 1:mysql-community-client-5.6.42-2.e################################# [100%] 30 [root@localhost mysql]# rpm -ivh mysql-community-server-5.6.42-2.el7.x86_64.rpm 31 警告:mysql-community-server-5.6.42-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 32 准备中... ################################# [100%] 33 正在升级/安装... 34 1:mysql-community-server-5.6.42-2.e################################# [100%]
1 [mysql56-community] 2 name=MySQL 5.6 Community Server 3 baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ 4 enabled=1 5 gpgcheck=0 6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
1 mysql> show databases; 2 +--------------------+ 3 | Database | 4 +--------------------+ 5 | information_schema | 6 | mysql | 7 | performance_schema | 8 +--------------------+ 9 3 rows in set (0.00 sec) 10 11 mysql> use mysql 12 Reading table information for completion of table and column names 13 You can turn off this feature to get a quicker startup with -A 14 15 Database changed 16 mysql> show tables; 17 +---------------------------+ 18 | Tables_in_mysql | 19 +---------------------------+ 20 | columns_priv | 21 | db | 22 | event | 23 | func | 24 | general_log | 25 | help_category | 26 | help_keyword | 27 | help_relation | 28 | help_topic | 29 | innodb_index_stats | 30 | innodb_table_stats | 31 | ndb_binlog_index | 32 | plugin | 33 | proc | 34 | procs_priv | 35 | proxies_priv | 36 | servers | 37 | slave_master_info | 38 | slave_relay_log_info | 39 | slave_worker_info | 40 | slow_log | 41 | tables_priv | 42 | time_zone | 43 | time_zone_leap_second | 44 | time_zone_name | 45 | time_zone_transition | 46 | time_zone_transition_type | 47 | user | 48 +---------------------------+ 49 28 rows in set (0.00 sec) 50 51 #执行下面两个指令就可以连接数据库了 52 mysql> update user set host=‘%‘; 53 ERROR 1062 (23000): Duplicate entry ‘%-root‘ for key ‘PRIMARY‘ 54 55 56 mysql> flush privileges; 57 Query OK, 0 rows affected (0.00 sec)
1 # mysql的主配置文件 2 server-id=1 3 log-bin=mysql-bin 4 log-slave-updates 5 slave-skip-errors=all 6 #就上边那点配置 7 8 # mysql的主配置文件 9 server-id=2 10 log-bin=mysql-bin 11 log-slave-updates 12 slave-skip-errors=all 13 #就上边那点配置 14 15 # mysql的主配置文件 16 server-id=3 17 log-bin=mysql-bin 18 log-slave-updates 19 slave-skip-errors=all 20 #就上边那点配置
1 mysql> SHOW VARIABLES like ‘server_id‘; 2 +---------------+-------+ 3 | Variable_name | Value | 4 +---------------+-------+ 5 | server_id | 3 | 6 +---------------+-------+ 7 1 row in set (0.00 sec)
1 mysql> show master status; 2 +------------------+----------+--------------+------------------+-------------------+ 3 | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | 4 +------------------+----------+--------------+------------------+-------------------+ 5 | mysql-bin.000001 | 120 | | | | 6 +------------------+----------+--------------+------------------+-------------------+ 7 1 row in set (0.00 sec)
将主节点的配置给从节点
1 mysql> change master to 2 -> 3 -> master_host=‘192.168.56.121‘, 4 -> 5 -> master_user=‘root‘, 6 -> 7 -> master_password=‘123456‘, 8 -> 9 -> master_log_file=‘mysql-bin.000001‘, 10 -> 11 -> master_log_pos=120; 12 Query OK, 0 rows affected, 2 warnings (0.18 sec)
1 #两个必须为yes 2 Slave_IO_Running: No 3 Slave_SQL_Running: Yes
1 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work. 2 上一个IO错误:致命错误:从I/O线程停止,因为主服务器和从服务器具有相同的MySQL服务器Uuid;这些Uuid必须不同,复制才能工作。
1 [root@localhost ~]# find / -name "auto.cnf" 2 /var/lib/mysql/auto.cnf 3 [root@localhost ~]# rm -rf /var/lib/mysql/auto.cnf 4 [root@localhost ~]# systemctl restart mysqld
1 mysql> start slave; 2 Query OK, 0 rows affected, 1 warning (0.00 sec) 3 4 mysql> show slave status\G 5 Slave_IO_Running: Yes 6 Slave_SQL_Running: Yes
1 export MYCAT_HOME=/usr/mycat 2 export PATH=$JAVA_HOME/bin:$PATH:$MYCAT_HOME/bin
[root@localhost ~]# mycat
Usage: /usr/mycat/bin/mycat { console | start | stop | restart | status | dump }
1 <?xml version="1.0"?> 2 <!DOCTYPE mycat:schema SYSTEM "schema.dtd"> 3 <mycat:schema xmlns:mycat="http://io.mycat/"> 4 5 <!-- 定义MyCat的逻辑库 --> 6 <schema name="mycat" checkSQLschema="false" sqlMaxLimit="100" dataNode="testNode"></schema> 7 <!-- 定义MyCat的数据节点 --> 8 <dataNode name="testNode" dataHost="dtHost" database="kg" /> 9 <dataHost name="dtHost" maxCon="1000" minCon="10" balance="1" 10 writeType="0" dbType="mysql" dbDriver="native" switchType="-1" slaveThreshold="100"> 11 <heartbeat>select user()</heartbeat> 12 <!-- can have multi write hosts --> 13 <writeHost host="hostM1" url="192.168.56.121:3306" user="root" 14 password="123456"> 15 <!-- can have multi read hosts --> 16 <readHost host="hostS1" url="192.168.56.122:3306" user="root" password="123456" /> 17 <readHost host="hostS2" url="192.168.56.123:3306" user="root" password="123456" /> 18 19 </writeHost> 20 </dataHost> 21 22 23 </mycat:schema>
1 <!DOCTYPE mycat:server SYSTEM "server.dtd"> 2 <mycat:server xmlns:mycat="http://io.mycat/"> 3 4 <system> 5 <!-- 这里配置的都是一些系统属性,可以自己查看mycat文--> 6 <property name="defaultSqlParser">druidparser</property> 7 <property name="charset">utf8</property> 8 </system> 9 10 11 <user name="root"> 12 <property name="password">123456</property> 13 <property name="schemas">mycat</property> 14 </user> 15 16 17 18 </mycat:server>
1 # url: jdbc:mysql://localhost:3306/kg 2 url: jdbc:mysql://192.168.56.124:8066/mycat?characterEncoding=UTF-8 #测试用 3 4 把以前的访问地址换为mycat的配置,
make & make install (安装,默认路径/usr/local/nginx)
1 /usr/local/nginx/sbin 2 [root@localhost sbin]# ./nginx
[root@localhost conf]# vim nginx.conf
1 #配置tomcat的分布式的tomcat和端口号 2 upstream tomcat-servers { 3 #ip_hash; 4 server 192.168.56.125:8085; 5 server 192.168.56.126:8086; 6 server 192.168.56.127:8087; 7 } 8 9 #原有的配置访问的是index.html 10 11 # location / { 12 # root html; 13 # index index.html index.htm; 14 # } 15 #配置nginx默认去访问配置好的tomcat 16 location / { 17 proxy_pass http://tomcat-servers; 18 proxy_redirect off; 19 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 20 proxy_set_header X-Real-IP $remote_addr; 21 proxy_set_header Host $http_host; 22 proxy_next_upstream http_502 http_504 error timeout invalid_header; 23 }
1 [root@localhost ~]# cd /usr/redis/bin/ 2 [root@localhost bin]# ./redis-cli -h 192.168.56.129 -p 6379 3 192.168.56.129:6379> set name xiaohei 4 (error) DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command ‘CONFIG SET protected-mode no‘ from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to ‘no‘, and then restarting the server. 3) If you started the server manually just for testing, restart it with the ‘--protected-mode no‘ option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. 5 192.168.56.129:6379> 6 [root@localhost bin]# ./redis-cli 7 127.0.0.1:6379> set name xiaohei 8 OK 9 127.0.0.1:6379>
1 [root@localhost redis-4.0.10]# cp redis.conf /usr/redis/ 2 [root@localhost redis-4.0.10]# cd /usr/redis/ 3 [root@localhost redis]# ls 4 bin redis.conf 5 [root@localhost redis]# vim redis.conf 6 7 #通过/port进行查找vim中的关键字 8 #启动的时候注意,加载一下配置文件 9 [root@localhost redis]# cd bin/ 10 [root@localhost bin]# ./redis-server ../redis.conf 11 #如下可见端口号被给为了6380 12 _._ 13 _.-``__ ‘‘-._ 14 _.-`` `. `_. ‘‘-._ Redis 4.0.10 (00000000/0) 64 bit 15 .-`` .-```. ```\/ _.,_ ‘‘-._ 16 ( ‘ , .-` | `, ) Running in standalone mode 17 |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6380 18 | `-._ `._ / _.-‘ | PID: 5460 19 `-._ `-._ `-./ _.-‘ _.-‘ 20 |`-._`-._ `-.__.-‘ _.-‘_.-‘| 21 | `-._`-._ _.-‘_.-‘ | http://redis.io 22 `-._ `-._`-.__.-‘_.-‘ _.-‘ 23 |`-._`-._ `-.__.-‘ _.-‘_.-‘| 24 | `-._`-._ _.-‘_.-‘ | 25 `-._ `-._`-.__.-‘_.-‘ _.-‘ 26 `-._ `-.__.-‘ _.-‘ 27 `-._ _.-‘ 28 `-.__.-‘
[root@localhost bin]# ./redis-cli -p 6380
127.0.0.1:6380>
1 [root@localhost bin]# ./redis-server ../redis.conf 2 5474:C 20 Nov 19:47:16.718 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 3 5474:C 20 Nov 19:47:16.718 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=5474, just started 4 5474:C 20 Nov 19:47:16.718 # Configuration loaded 5 [root@localhost bin]# ps -aux|grep "redis" 6 root 5466 0.0 0.5 16316 5388 pts/0 S+ 19:38 0:00 ./redis-cli -p 6380 7 root 5475 0.0 0.7 145316 7576 ? Ssl 19:47 0:00 ./redis-server 127.0.0.1:6380 8 root 5481 0.0 0.0 112728 972 pts/1 R+ 19:47 0:00 grep --color=auto redis
1 #导入依赖 2 <!--操作redis的相关依赖--> 3 <dependency> 4 <groupId>redis.clients</groupId> 5 <artifactId>jedis</artifactId> 6 <version>2.9.0</version> 7 </dependency> 8 </dependencies> 9 10 #操作jedis的API 11 public class TestJedis { 12 13 //操作字符串 14 @Test 15 public void test1(){ 16 17 /* 18 * 开启redis的远程访问全限 redis.conf 配置文件开启 19 bind 0.0.0.0 20 * */ 21 //创建redis客户端 22 Jedis jedis = new Jedis("192.168.92.19", 7000); 23 //选择操作哪一个库 使用0号库 name xiaohei 24 jedis.select(0); 25 // jedis.set("name","xiaohei"); 26 //jedis.append("name","特别黑真的特别黑"); 27 jedis.del("name"); 28 String name = jedis.get("name"); 29 System.out.println(name); 30 //关闭客户端 31 jedis.close(); 32 } 33 34 //操作list集合 35 @Test 36 public void test2(){ 37 //创建客户端 38 Jedis jedis = new Jedis("192.168.92.19", 7000); 39 jedis.select(0); 40 //存储list集合 41 // jedis.lpush("names","xiaohei","xiaobai","xiaohua","xiaojr"); 42 // jedis.lpop("names"); 43 String names = jedis.lindex("names", 0); 44 System.out.println(names); 45 //遍历 46 /* List<String> names = jedis.lrange("names", 0, -1); 47 for (String name : names) { 48 System.out.println(name); 49 }*/ 50 jedis.close(); 51 52 } 53 54 }
1 #本次演示在springboot中: 2 3 #先导入依赖: 4 <!--引入redis的依赖--> 5 <dependency> 6 <groupId>org.springframework.boot</groupId> 7 <artifactId>spring-boot-starter-data-redis</artifactId> 8 </dependency> 9 10 #yml配置文件 11 spring: 12 redis: 13 database: 0 #访问redis指定的数据库 14 host: 192.168.56.129 #访问redis的ip 15 port: 6380 #访问的端口号 16 17 #测试类中的方法 18 #第一个将序列化的对象存入到数据库中,再通过反序列化将redis中的数据取出来 19 #第二个是通过操作字符串进行存取 20 @RunWith(SpringRunner.class) 21 @SpringBootTest(classes = Application.class) 22 public class TestDAO { 23 24 @Autowired 25 private RedisTemplate redisTemplate; //操作返回的是对象 26 @Autowired 27 private StringRedisTemplate redis; //操作返回的是字符串 28 //还有很多方法就不列举了,具体的查询API 29 @Test 30 public void redis(){ 31 redis.opsForValue().set("000","lili"); 32 } 33 }
标签:inf rest isp 执行命令 vendor thread mysql的安装 inux format
原文地址:https://www.cnblogs.com/Consola/p/11889357.html