#fdisk -l
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000f3770
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 19920511 9959232 83 Linux
/dev/vda2 19920512 20969087 524288 82 Linux swap / Solaris
3、尝试能否通过新建分区解决的时候,发现了另一个bug,居然能看到主机的真实磁盘大小!
#fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): u
Changing display/entry units to cylinders (DEPRECATED!).
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First cylinder (1306-20805, default 1306):
Using default value 1306
Last cylinder, +cylinders or +size{K,M,G} (1306-20805, default 20805):
Using default value 20805
Partition 3 of type Linux and of size 149.4 GiB is set
//剩余149.4G,加上我自己的10G,这块SSD的大小应该是160G的,当然仅此而已了,想要盗用还是不可能的,至少我办不到。囧
Command (m for help): q
fdisk -l
//虽然fdisk看到的vda3貌似很厉害的样子
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000f3770
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 19920511 9959232 83 Linux
/dev/vda2 19920512 20969087 524288 82 Linux swap / Solaris
/dev/vda3 20969088 334232324 156631618+ 83 Linux
4、partprobe的时候果然报错了哈哈哈
#partprobe
Error: Can't have a partition outside the disk!
#resize2fs /dev/vda1 (其实核心就是这个命令) resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/vda1 is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2 The filesystem on /dev/vda1 is now 2489808 blocks long.
[root@nmserver-7 ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
1.4 查看服务状态
[root@nmserver-7 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 五 2017-07-21 17:21:37 CST; 6min ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2449 (httpd) Status: "Total requests: 11; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─2449 /usr/sbin/httpd -DFOREGROUND ├─2450 /usr/sbin/httpd -DFOREGROUND ├─2451 /usr/sbin/httpd -DFOREGROUND ├─2452 /usr/sbin/httpd -DFOREGROUND ├─2453 /usr/sbin/httpd -DFOREGROUND ├─2454 /usr/sbin/httpd -DFOREGROUND ├─2493 /usr/sbin/httpd -DFOREGROUND ├─2494 /usr/sbin/httpd -DFOREGROUND └─2495 /usr/sbin/httpd -DFOREGROUND 7月 21 17:21:35 nmserver-7.test.com systemd[1]: Starting The Apache HTTP Server... 7月 21 17:21:36 nmserver-7.test.com httpd[2449]: AH00558: httpd: Could not reliably determine the server's fully q...ssage 7月 21 17:21:37 nmserver-7.test.com systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
[root@nmserver-7 ~]# netstat -tulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 1084/sshd tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 9760/mysqld tcp6 0 0 [::]:ssh [::]:* LISTEN 1084/sshd tcp6 0 0 [::]:http [::]:* LISTEN 2449/httpd udp 0 0 localhost:323 0.0.0.0:* 592/chronyd udp6 0 0 localhost:323 [::]:* 592/chronyd
2.3 数据库安全设置
[root@nmserver-7 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
2.4 登陆数据库测试
[root@nmserver-7 ~]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 11 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.02 sec) MariaDB [(none)]>
安装cmake:
yum install cmake
或源码安装:
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
tar -xzvf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2
./bootstrap ; make ; make install
cd ~
新增mysql用户组:
groupadd mysql
新增mysql用户:
useradd -r -g mysql mysql
新建mysql安装目录:
mkdir -p /usr/local/mysql
新建mysql数据库数据文件目录:
mkdir -p /data/mysqldb
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.34.tar.gz
tar -zxvf mysql-5.6.34.tar.gz
cd mysql-5.6.34
MySQL问题解决:-bash:mysql:command not found
因为mysql命令的路径在/usr/local/mysql/bin下面,所以你直接使用mysql命令时,
系统在/usr/bin下面查此命令,所以找不到了
解决办法是:
ln -s /usr/local/mysql/bin/mysql /usr/bin 做个链接即可
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/usr/local/mysql/mysql.sock’ (2)
1、先查看 /etc/rc.d/init.d/mysqld status 看看mysql服务是否已经启动.
另外看看是不是权限问题.
$service mysqld start
或
$service mysql start
–我开始遇到的就是因为服务没启动,因为第一次玩mysql不是很熟悉,呵呵。
2、确定你的mysql.sock是不是在那个位置,
mysql -u 你的mysql用户名 -p -S /var/lib/mysql/mysql.sock
Error: Package: php-gd-5.6.11-1.el6.remi.x86_64 (remi-php56) Requires:
gd-last(x86-64) >= 2.1.1 Error: Package:
php-gd-5.6.11-1.el6.remi.x86_64 (remi-php56) Requires:
libgd.so.3()(64bit) You could try using –skip-broken to work around
the problem You could try running: rpm -Va –nofiles –nodigest
报错的原因是因为PHP安装的版本是5.6.10 ,现在yum默认找的是php5.3版本。这个问题也是不好解决,我搞了两个小时都没能好,最后得到高人指点,运行
yum install php-gd –enablerepo=remi-php56
1
在运行一下
yum install php-gd
1
你会神奇的发现你的gd开启了O(∩_∩)O哈哈~
四、MYSQL安装
首先进入本机的源文件目录
cd /usr/local/src
1
如果以下三步你发现运行的特别慢那么,请马上Ctrl+c,删除刚刚下载的rpm包,按照这个教程来安装mysql
https://www.linuxidc.com/Linux/2016-09/135288.htm
cat /var/log/mysqld.log|grep ‘A temporary password’
1
出现下面代码
2017-11-12T13:35:37.013617Z 1 [Note] A temporary password is generated for root@localhost: bkv,dy,)o7Ss
最后一行冒号后面的部分就是初始密码,我的密码就是 bkv,dy,)o7Ss
连接数据库
mysql -u root -p
1
更改默认密码:
切换数据库:
use mysql;
1
如果这个时候出现 mysql 报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executin,直接修改root密码,就不用切换数据库了
修改root密码:
alter user ‘root’@’localhost’ identified by ‘your_password’;
1
将your_password替换成你自己的密码就可以了,当然,这个密码是强密码,要求密码包含大小写字母、数字及标点符号,长度应该在6位以上,不然就会失败。
重新使用新的密码登录,如果可以正常登录说明你的MySQL已经成功安装在CentOS 7.4上了
[root@localhost ~]#getsebool -a |grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
allow_tftp_anon_write --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_disable_trans --> off
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
安装mysql-server的过程没有提示输入root的password
安装成功后,输入指令mysql -uroot,提示Access denied for user ‘root’@’localhost’
输入sudo mysql -uroot可以直接连接成功
输入sudo mysql -uroot -p后回车输入任意password也可以直接连接成功
输入mysql -h 127.0.0.1 -P 3306 -uroot -p提示Access denied for user ‘root’@’localhost’
因此,java程序通过jdbc来连接数据库也是提示:Access denied for user ‘root’@’localhost’