20150417-1 选题

This commit is contained in:
DeadFire 2015-04-17 15:44:12 +08:00
parent ff659c2db7
commit 8b1abbaa34
5 changed files with 889 additions and 0 deletions

View File

@ -0,0 +1,130 @@
14 Useful Examples of Linux sort Command Part 1
================================================================================
Sort is a Linux program used for printing lines of input text files and concatenation of all files in sorted order. Sort command takes blank space as field separator and entire Input file as sort key. It is important to notice that sort command dont actually sort the files but only print the sorted output, until your redirect the output.
This article aims at deep insight of Linux sort command with 14 useful practical examples that will show you how to use sort command in Linux.
### 1. First we will be creating a text file (tecmint.txt) to execute sort command examples. Our working directory is /home/$USER/Desktop/tecmint. ###
The option -e in the below command enables interpretion of backslash and /n tells echo to write each string to a new line.
$ echo -e "computer\nmouse\nLAPTOP\ndata\nRedHat\nlaptop\ndebian\nlaptop" > tecmint.txt
![Split String by Lines in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Split-String-by-Lines.gif)
### 2. Before we start with sort lets have a look at the contents of the file and the way it look. ###
$ cat tecmint.txt
![Check Content of File](http://www.tecmint.com/wp-content/uploads/2015/04/Check-Content-of-File.gif)
### 3. Now sort the content of the file using following command. ###
$ sort tecmint.txt
![Sort Content of File linux](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content.gif)
**Note**: The above command dont actually sort the contents of text file but only show the sorted output on terminal.
### 4. Sort the contents of the file tecmint.txt and write it to a file called (sorted.txt) and verify the content by using [cat command][1]. ###
$ sort tecmint.txt > sorted.txt
$ cat sorted.txt
![Sort File Content in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-File-Content.gif)
### 5. Now sort the contents of text file tecmint.txt in reverse order by using -r switch and redirect output to a file reversesorted.txt. Also check the content listing of the newly created file. ###
$ sort -r tecmint.txt > reversesorted.txt
$ cat reversesorted.txt
![Sort Content By Reverse](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-By-Reverse.gif)
### 6. We are going a create a new file (lsl.txt) at the same location for detailed examples and populate it using the output of ls -l for your home directory. ###
$ ls -l /home/$USER > /home/$USER/Desktop/tecmint/lsl.txt
$ cat lsl.txt
![Populate Output of Home Directory](http://www.tecmint.com/wp-content/uploads/2015/04/Populate-Output.gif)
Now will see examples to sort the contents on the basis of other field and not the default initial characters.
### 7. Sort the contents of file lsl.txt on the basis of 2nd column (which represents number of symbolic links). ###
$ sort -nk2 lsl.txt
**Note**: The -n option in the above example sort the contents numerically. Option -n must be used when we wanted to sort a file on the basis of a column which contains numerical values.
![Sort Content by Column](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-by-Column.gif)
### 8. Sort the contents of file lsl.txt on the basis of 9th column (which is the name of the files and folders and is non-numeric). ###
$ sort -k9 lsl.txt
![Sort Content Based on Column](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-Based-on-Column.gif)
### 9. It is not always essential to run sort command on a file. We can pipeline it directly on the terminal with actual command. ###
$ ls -l /home/$USER | sort -nk5
![Sort Content Using Pipe Option](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-By-Pipeline.gif)
### 10. Sort and remove duplicates from the text file tecmint.txt. Check if the duplicate has been removed or not. ###
$ cat tecmint.txt
$ sort -u tecmint.txt
![Sort and Remove Duplicates](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-and-Remove-Duplicates.gif)
Rules so far (what we have observed):
- Lines starting with numbers are preferred in the list and lies at the top until otherwise specified (-r).
- Lines starting with lowercase letters are preferred in the list and lies at the top until otherwise specified (-r).
- Contents are listed on the basis of occurrence of alphabets in dictionary until otherwise specified (-r).
- Sort command by default treat each line as string and then sort it depending upon dictionary occurrence of alphabets (Numeric preferred; see rule 1) until otherwise specified.
### 11. Create a third file lsla.txt at the current location and populate it with the output of ls -lA command. ###
$ ls -lA /home/$USER > /home/$USER/Desktop/tecmint/lsla.txt
$ cat lsla.txt
![Populate Output With Hidden Files](http://www.tecmint.com/wp-content/uploads/2015/04/Populate-Output-With-Hidden-Files.gif)
Those having understanding of ls command knows that ls -lA=ls -l + Hidden files. So most of the contents on these two files would be same.
### 12. Sort the contents of two files on standard output in one go. ###
$ sort lsl.txt lsla.txt
![Sort Contents of Two Files](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-of-Multiple-Files.gif)
Notice the repetition of files and folders.
### 13. Now we can see how to sort, merge and remove duplicates from these two files. ###
$ sort -u lsl.txt lsla.txt
![Sort, Merge and Remove Duplicates from File](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Merge-Duplicates-Content.gif)
Notice that duplicates has been omitted from the output. Also, you can write the output to a new file by redirecting the output to a file.
### 14. We may also sort the contents of a file or the output based upon more than one column. Sort the output of ls -l command on the basis of field 2,5 (Numeric) and 9 (Non-Numeric). ###
$ ls -l /home/$USER | sort -t "," -nk2,5 -k9
![Sort Content By Field Column](http://www.tecmint.com/wp-content/uploads/2015/04/Sort-Content-By-Field-Column.gif)
Thats all for now. In the next article we will cover a few more examples of sort command in detail for you. Till then stay tuned and connected to Tecmint. Keep sharing. Keep commenting. Like and share us and help us get spread.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/sort-command-linux/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/

View File

@ -0,0 +1,359 @@
How to Configure MariaDB Replication on CentOS Linux
================================================================================
Its a process of creating duplicate versions of a the DB. Replication process is not only copies a database, but also synchronizes changes from master to one of the slaves. But this is does not means that slave databases are identical copy of the master, because replication can be configured that only a schema of tables or columns or rows will be replicated, i.e. a partial replication. The replication ensures that those specific configured objects are kept in sync between the different databases.
### Mariadb Replication Concepts ###
**Backups** : Replication can be used for DB backups. For example, you have master -> slave replication. If master is lost (hdd fails, for example) you can restore your db from master.
**Scaling** : You can use master -> slave replication for scaling solution. For example, if you have a few big and have SQL query, using replcation you can separate this queries for each replcations nodes. Write SQL should be performed only on master, for read-only queries slave server can be used.
**Spreading solution** : You can use replication for distribution. For example, you can distribute different sales data to different databases.
**Failover solution** : For example you have, master -> slave(1) -> slave(2) -> slave(3) replication. You can write script for master monitoring , if master fails, script can quickly change slave(1) new for master master -> slave(1) -> slave(2) and your application will continue working whit out downtime
### Simple diagrammatic demonstration of replication ###
![mysql replication principle](http://blog.linoxide.com/wp-content/uploads/2015/04/mysql-replication-principle.png)
Before you start good know what is **binary log** and Ibdata1. The binary log contains a record about all changes in the db, data and structure, as well as how long each statement took to execute. Bin log consists set log files and an index. Its means that main SQL statements such as CREATE, ALTER, INSERT, UPDATE and DELETE will be putted to this log, statements, such as SELECT will not be logged. These info can be logged to general query.log file. In simple **Ibdata1** is a file which contains all tables and all info about db.
### Master server configuration ###
Good to have server updated
sudo yum install update -y && sudo yum install upgrade -y
We are working on centos 7 server
sudo cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
Install MariaDB
sudo yum install mariadb-server -y
Start MariaDB and enable it to start on boot of the server
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Output:
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
Check MariaDB status
sudo service mariadb status
or use
sudo systemctl is-active mariadb.service
Output:
Redirecting to /bin/systemctl status mariadb.service
mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled)
Set MariaDB password
mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("SOME_ROOT_PASSWORD") where User='root';
mysql> flush privileges;
mysql> exit
SOME_ROOT_PASSWORD - your root password. I my case I'ill use "q" - password, then try to login:
sudo mysql -u root -pSOME_ROOT_PASSWORD
Output:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Lets create database with table with some data
Create database/schema
sudo mysql -u root -pSOME_ROOT_PASSWORD
mysql> create database test_repl;
Where:
test_repl - Name of shcema which will be replicated
Output:
Query OK, 1 row affected (0.00 sec)
Create Persons table
mysql> use test_repl;
CREATE TABLE Persons (
PersonID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
);
Output:
mysql> MariaDB [test_repl]> CREATE TABLE Persons (
-> PersonID int,
-> LastName varchar(255),
-> FirstName varchar(255),
-> Address varchar(255),
-> City varchar(255)
-> );
Query OK, 0 rows affected (0.01 sec)
Insert some data
mysql> INSERT INTO Persons VALUES (1, "LastName1", "FirstName1", "Address1", "City1");
mysql> INSERT INTO Persons VALUES (2, "LastName2", "FirstName2", "Address2", "City2");
mysql> INSERT INTO Persons VALUES (3, "LastName3", "FirstName3", "Address3", "City3");
mysql> INSERT INTO Persons VALUES (4, "LastName4", "FirstName4", "Address4", "City4");
mysql> INSERT INTO Persons VALUES (5, "LastName5", "FirstName5", "Address5", "City5");
Output:
Query OK, 5 row affected (0.00 sec)
Check data
mysql> select * from Persons;
Output:
+----------+-----------+------------+----------+-------+
| PersonID | LastName | FirstName | Address | City |
+----------+-----------+------------+----------+-------+
| 1 | LastName1 | FirstName1 | Address1 | City1 |
| 1 | LastName1 | FirstName1 | Address1 | City1 |
| 2 | LastName2 | FirstName2 | Address2 | City2 |
| 3 | LastName3 | FirstName3 | Address3 | City3 |
| 4 | LastName4 | FirstName4 | Address4 | City4 |
| 5 | LastName5 | FirstName5 | Address5 | City5 |
+----------+-----------+------------+----------+-------+
### Configure MariaDB for replication ###
You'll need to edit the my.cnf file on the Master server to enable binary logging and set the server's id. I will use vi text editor, but use can use any suitable for your such as nano, joe etc.
sudo vi /etc/my.cnf
and put to config in [mysqld] section such lines.
log-basename=master
log-bin
binlog-format=row
server_id=1
Output:
![mariadb config master](http://blog.linoxide.com/wp-content/uploads/2015/04/mariadb-config.png)
Then restart MariaDB:
sudo service mariadb restart
Login to MariaDB and check binary logs:
sudo mysql -u root -pq test_repl
mysql> SHOW MASTER STATUS;
Output:
+--------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+--------------------+----------+--------------+------------------+
| mariadb-bin.000002 | 3913 | | |
+--------------------+----------+--------------+------------------+
**Remember** : "File" and "Position" values. YOU WILL NEED THIS VALUE AT SLAVE SERVER
Create user for replication
mysql> GRANT REPLICATION SLAVE ON *.* TO replication_user IDENTIFIED BY 'bigs3cret' WITH GRANT OPTION;
mysql> flush privileges;
Output:
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Check user in db
mysql> select * from mysql.user WHERE user="replication_user"\G;
Output:
mysql> select * from mysql.user WHERE user="replication_user"\G;
*************************** 1. row ***************************
Host: %
User: replication_user
Password: *2AF30E7AEE9BF3AF584FB19653881D2D072FA49C
Select_priv: N
.....
Create DB dump (snapshot of all data which will be replicated) form master
mysqldump -uroot -pSOME_ROOT_PASSWORD test_repl > full-dump.sql
Where:
SOME_ROOT_PASSWORD - password for root user that you have setup
test_repl - name of the data base which will be replicated;
You need to recover mysql dump (full-dump.sql) at slave server. Its needed for replication.
### Slave server configuration ###
All this commands you need to perform at slave server
Lets assume that we have fresh/updated CentOS 7.x server with latest mariaDB server and you can login as root to maria DB server (this was descripbed in first part of the article)
Login to Maria DB console and create DB
mysql -u root -pSOME_ROOT_PASSWORD;
mysql> create database test_repl;
mysql> exit;
Recover data from master at slave server
mysql -u root -pSOME_ROOT_PASSWORD test_repl < full-dump.sql
Where:
full-dump.sql - its DB Dump that you have create at test server.
Login to Maria DB and setup replication
mysql> CHANGE MASTER TO
MASTER_HOST='82.196.5.39',
MASTER_USER='replication_user',
MASTER_PASSWORD='bigs3cret',
MASTER_PORT=3306,
MASTER_LOG_FILE='mariadb-bin.000002',
MASTER_LOG_POS=3913,
MASTER_CONNECT_RETRY=10;
![mariadb setup replication](http://blog.linoxide.com/wp-content/uploads/2015/04/setup-replication.png)
Where:
MASTER_HOST - IP of the master server.
MASTER_USER - replication user at master server
MASTER_PASSWORD - replication user password
MASTER_PORT - mysql port at master
MASTER_LOG_FILE - bin-log file name form master
MASTER_LOG_POS - bin-log position file at master
Start slave mode
mysql> slave start;
Output:
Query OK, 0 rows affected (0.00 sec)
Check slave status
mysql> show slave status\G;
Output:
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 82.196.5.39
Master_User: replication_user
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mariadb-bin.000002
Read_Master_Log_Pos: 4175
Relay_Log_File: mariadb-relay-bin.000002
Relay_Log_Pos: 793
Relay_Master_Log_File: mariadb-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 4175
Relay_Log_Space: 1089
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
At this step all shoul be ok, and not erros should be here.
### Test the replication ###
At MAIN/MASTER server add some entities to DB
mysql -u root -pSOME_ROOT_PASSWORD test_repl
mysql> INSERT INTO Persons VALUES (6, "LastName6", "FirstName6", "Address6", "City6");
mysql> INSERT INTO Persons VALUES (7, "LastName7", "FirstName7", "Address7", "City7");
mysql> INSERT INTO Persons VALUES (8, "LastName8", "FirstName8", "Address8", "City8");
Then go to the SLAVE server and check replicated data
mysql -u root -pSOME_ROOT_PASSWORD test_repl
mysql> select * from Persons;
+----------+-----------+------------+----------+-------+
| PersonID | LastName | FirstName | Address | City |
+----------+-----------+------------+----------+-------+
...................
| 6 | LastName6 | FirstName6 | Address6 | City6 |
| 7 | LastName7 | FirstName7 | Address7 | City7 |
| 8 | LastName8 | FirstName8 | Address8 | City8 |
+----------+-----------+------------+----------+-------+
You can see the data is replicated to slave server. Its mean that replication is working. Hope you enjoyed the article. Let us know if you have any questions.
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/configure-mariadb-replication-centos-linux/
作者:[Bobbin Zachariah][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/bobbin/

View File

@ -0,0 +1,160 @@
How to Install Discourse in a Docker Container
================================================================================
Hi all, today we'll learn how to install Discourse using Docker Platform. Discourse is the 100% open source discussion platform built for the next decade of the Internet featuring as a mailing list, a discussion forum and a long-form chat room. It is a smart way of attempt to reimagine what a modern, sustainable, fully open-source Internet discussion platform should be today, both from a technology standpoint and a sociology standpoint. Discourse is simple, clean, and straightforward way for discussion. It is really an awesome platform for any kinds of discussions on internet featuring such a cool services out of the box. Docker is an open source platform that provides an open platform to pack, ship and run any application as a lightweight container. Docker containers makes Discourse a lot handy and easy to setup app.
So, here are some quick and easy steps in order to install Discourse inside a Docker environment.
### 1. Installing Docker ###
First of all, we need to make sure that we have Docker installed in our host Operating System. To install, we'll need to the run the following command in a shell or terminal.
#### On Ubuntu ####
Package docker is available in Ubuntu's repository so, we'll be using apt manager to install it in sudo or root mode.
# apt-get install docker
#### On CentOS 7 ####
On CentOS 7 machine, we'll use yum manager to install docker as it is also available in CentOS's repository.
# yum install docker
![Installing Docker](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-docker.png)
### 2. Setting Swap Memory ###
If you have RAM size less than 1 GB then, make sure you upgrade your system to 1 GB or above cause Discourse doesn't get installed in 512 MB RAM. If you are now ready to install Discourse with 1 GB or above, follow the following steps to setup swap memory for you VPS or Server.
We'll create an empty swapfile by running the following command.
# install -o root -g root -m 0600 /dev/null /swapfile
If you want your swap memory to be 1 GB, then do the below step and skip the next step.
# dd if=/dev/zero of=/swapfile bs=1k count=1024k
if you want it to be 2 GB, follow the below. Make sure you skip the above step.
# dd if=/dev/zero of=/swapfile bs=1k count=2048k
Then, we'll point Swap Memory as swapfile .
#mkswap /swapfile
To activate it run the following command.
#swapon /swapfile
Now, we'll add it to the file system table so its there after reboot:
# echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
Set the swappiness to 10 so its only uses as an emergency buffer.
# sudo sysctl -w vm.swappiness=10
# echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
### 3. Installing Discourse ###
After installing Docker in our host machine, we'll now go further towards installing Discourse. We'll now clone Discourse from the official Discourse Github into /var/discourse directory. To do so, we'll need to run the following command.
# mkdir /var/discourse/
# cd /var/discourse/
# git clone https://github.com/discourse/discourse_docker.git /var/discourse/
After cloning the git repository, we'll copy the configuration file for our discourse server.
# cp samples/standalone.yml containers/app.yml
![Cloning Discourse Docker](http://blog.linoxide.com/wp-content/uploads/2015/04/cloning-discourse-docker.png)
### 4. Configuring Discourse ###
Next, we'll edit the discourse configuration ie app.yml located inside containers directory using our favorite text editor.
# nano containers/app.yml
Now, we need to set the developer's email address to DISCOURSE_DEVELOPER_EMAILS as follows.
DISCOURSE_DEVELOPER_EMAILS: 'arun@linoxide.com'
Then, we'll set the hostname as the domain name of our server.
DISCOURSE_HOSTNAME: 'discourse.linoxide.com'
Then, set the mail credentials per our SMTP Server hosted in the same discourse machine or vps. The SMTP settings are required to send mail from your Discourse instance
DISCOURSE_SMTP_ADDRESS: smtp.linoxide.com
DISCOURSE_SMTP_PORT: 587 # (optional)
DISCOURSE_SMTP_USER_NAME: admin@linoxide.com # (optional)
DISCOURSE_SMTP_PASSWORD: test123 # (optional)
![](http://blog.linoxide.com/wp-content/uploads/2015/04/discourse-configuration.png)
Discourse Configuration
If you are using a 1 GB instance, set UNICORN_WORKERS to 2 and db_shared_buffers to 128MB so you have more memory room.
It is compulsory to create a mailing server to run Discourse. If you have a server then its cool, we can use its credentials. If you have no existing mail server, or you don't know what it is? No problem, create a free account on [Mandrill][1] ([Mailgun][2], or [Mailjet][3]), and use the credentials provided in the dashboard.
### 5. Starting Discourse App ###
After configuring the discourse configuration file, we'll surely wanna start our Discourse server. To do so, first we'll launch discourse bootstrap by running the following command under the current directory ie /var/discourse/ .
# ./launcher bootstrap app
![Starting Discourse Bootstrap](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse-bootstrap.png)
The above command may take some minutes which automatically configures our Discourse environment. Then, after the processes are finished, we'll need to run the following to start our Discourse App.
#./launcher start app
![Starting Discourse](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse.png)
If everything went as expected accordingly, we'll be able to access our fresh Discourse Web Interface using our favorite Web Browser by pointing the url to http://ip-address/ or http://discourse.linoxide.com/ . Then, we can create a new account and become admin.
![Discourse Web interface](http://blog.linoxide.com/wp-content/uploads/2015/04/Discourse-web-interface.png)
### Maintenance ###
Here below are the usages of the launcher command inside /var/discourse/ directory so that we can commit maintenance and control over the Discourse Docker Container.
Usage: launcher COMMAND CONFIG [--skip-prereqs]
Commands:
start: Start/initialize a container
stop: Stop a running container
restart: Restart a container
destroy: Stop and remove a container
enter: Use nsenter to enter a container
ssh: Start a bash shell in a running container
logs: Docker logs for container
mailtest: Test the mail settings in a container
bootstrap: Bootstrap a container for the config based on a template
rebuild: Rebuild a container (destroy old, bootstrap, start new)
cleanup: Remove all containers that have stopped for > 24 hours
Options:
--skip-prereqs Don't check prerequisites
--docker-args Extra arguments to pass when running docker
### Conclusion ###
Hurray! We have successfully installed Discourse with Docker Technology. Docker technology makes Discourse very much easy to install in any Platform with all the requirement fulfilled. We need our own mailing server or credentials of a mailing server to get started with it. It is a great platform for easy modern mailing list, discussion platform.
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/install-discourse-docker-container/
作者:[Arun Pyasi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/arunp/
[1]:https://mandrillapp.com/
[2]:http://www.mailgun.com/
[3]:https://www.mailjet.com/pricing

View File

@ -0,0 +1,147 @@
How to Install Linux Kernel 4.0 from Elrepo / Source on Ubuntu / CentOs
================================================================================
Hi everyone, today we'll learn how to install the latest Linux Kernel 4.0 from Elrepo and compiling using Source. Linux Kernel 4.0 is the latest Mainline Kernel codenamed Hurr durr Im a sheep till date. It is the kernel released after the stable released of 3.19.4 . April 12 is considered as a big day for all fans of the Open Source movement, as Linus Torvalds announced the release of Linux Kernel 4.0 and its immediate availability. It is considered as a big release as it consists of some awesome features which includes no-reboot patching (Live Patching), New and Updated Drivers, New and Latest Hardware Support and more interesting features with a new version change. But Kernel 4.0 is not considered as a huge release as expected but Linus announced that 4.1 is expected for a bigger release. The Live Patching feature was already integrated with the SUSE Enterprise Linux operating system. Here is the [release announcement][1] you can check for more details about the release.
> **WARNING**: Installing a new kernel may render your system unusable or unstable. If you proceed with the installation using the instructions below, make sure you back up any important data you have to an external hard drive.
### Installing Linux Kernel 4.0 on Ubuntu 15.04 ###
If you are running an Ubuntu 15.04 Distribution of Linux. You can simply install it straight from Ubuntu Kernel site. To install the latest Linux Kernel 4.0 in your Ubuntu 15.04, you'll need to run the following commands under root access in a shell or a terminal.
#### On a 64-bit Ubuntu 15.04 ####
$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.0-vivid/linux-headers-4.0.0-040000-generic_4.0.0-040000.201504121935_amd64.deb
$ sudo dpkg -i linux-headers-4.0.0*.deb linux-image-4.0.0*.deb
#### On a 32-bit Ubuntu 15.04 ####
$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.0-vivid/linux-headers-4.0.0-040000-generic_4.0.0-040000.201504121935_i386.deb
$ sudo dpkg -i linux-headers-4.0.0*.deb linux-image-4.0.0*.deb
### Installing Linux Kernel 4.0 on CentOS 7 ###
We can easily install Linux Kernel 4.0 using two ways in CentOS 7 .
1. Installing from Elrepo Repository
1. Compiling and installing from the Source Code
First we'll gonna go for installing using ELRepo as its the easiest way to do.
#### Installing using Elrepo ####
**1. Downloading and Installing ELRepo**
We'll first gonna download the GPG key of ELRepo and install the relrepo-release package. As we're running CentOS 7, we'll gonna install elrepo-release-7.0-2.el7.elrepo.noarch.rpm using the command below.
Note: If you have a secure boot enabled please see [this page for more information][2].
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
![Adding Elrepo Source](http://blog.linoxide.com/wp-content/uploads/2015/04/adding-elrepo.png)
**2. Updating Linux Kernel to version 4.0**
Now, we'll gonna install the latest stable kernel 4.0 from the ELRepo repository. To do so, we'll need to enter the following commands in a shell or terminal of the CentOS 7.
# yum --enablerepo=elrepo-kernel install kernel-ml
![Installing Linux Kernel 4.0 from ELRepo](http://blog.linoxide.com/wp-content/uploads/2015/04/installing-kernel-4-0-elrepo.png)
The above command will automatically install the Linux Kernel 4.0 build for CentOS 7.
Now, here below is the another way of installing the latest kernel 4.0 by compiling from the source.
#### Compiling and Installing from the Source ####
**1. Installing the Dependencies**
So, first of all we'll need to install the dependencies required to compile the linux kernel. To do so, we'll need to run the following command in a terminal or a shell.
# yum groupinstall "Development Tools"
# yum install gcc ncurses ncurses-devel
![Installing Kernel Dependencies](http://blog.linoxide.com/wp-content/uploads/2015/04/installing-dependencies.png)
Then, we'll gonna update our whole system.
# yum update
**2. Downloading the source**
We'll now download the latest release linux kernel 4.0 source using wget command from the official repository of Linux Kernel. You can also download the kernel directly from the site [kernel.org][3] using your web browser also.
# cd /tmp/
# wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.0.tar.xz
![Download Kernel Source](http://blog.linoxide.com/wp-content/uploads/2015/04/download-kernel-source.png)
**3. Extracting the tarball**
Once the file is downloaded we'll extract it under /usr/src/ directory by running the below command.
# tar -xf linux-4.0.tar.xz -C /usr/src/
# cd /usr/src/linux-4.0/
![Extracting Kernel Tarball](http://blog.linoxide.com/wp-content/uploads/2015/04/extracting-kernel-tarball.png)
**4. Configuring**
We have two options to configure the Linux Kernel. We can either create a new custom configuration or use the old configuration to build and install the Linux Kernel. It all depends on what you really want.
**For New Kernel Configuration**
Now we'll run the make menuconfig command in the shell or terminal to configure the Linux kernel. Once we've executed the below command a pop up window with all the menus appears. Here we can select our new kernel configuration. If you unfamiliar with these menus, just hit double ESC key to exit.
# make menuconfig
![Configuring New Kernel Config](http://blog.linoxide.com/wp-content/uploads/2015/04/configuring-new-kernel-config.png)
**For Old Configuration**
If you like to configure your latest kernel with your old configuration then simple type the below command. If you were asked any stuff, you can choose with Y or N or you can simply press Enter to continue.
# make oldconfig
#### Step 5. Compiling the Linux Kernel ####
Next, we'll execute the make command to compile the Kernel 4.0 . The compilation would take at least 20-30 minutes depends on your system configuration.
Note: If you got an error while compiling the kernel saying bc command not found. You can fix that by installing bc using the command **yum install bc** .
# make
![Make Kernel](http://blog.linoxide.com/wp-content/uploads/2015/04/make-kernel.png)
#### 6. Installing Linux Kernel 4.0 ####
Once the compilation is completed, we'll now finally install the **Kernel** in our Linux System. The below command will create files under /boot directory and also makes a new kernel entry in the Grub Menu.
# make modules_install install
#### 7. Verifying Kernel ####
After installing our latest kernel 4.0 we'll want to verify it. To do so we'll just type the following command on the terminal. If everything went fine, we'll get the kernel version ie. 4.0 enlisted in the output below.
# uname -r
#### Conclusion ####
Hurray, we have successfully installed the latest version of linux kernel ie 4.0 in our CentOS 7 Operating System. Upgrading a linux kernel is always not necessary cause the hardware you got working with the previous version of it may not get working with the newer version. We should make sure that the it includes the features and stuffs that are necessary to make your hardware working. But mostly, the newer stable versions of kernel makes your hardware performance better. So, if you have any questions, comments, feedback please do write on the comment box below and let us know what stuffs needs to be added or improved. Thank You! Enjoy the latest stable version of Linux Kernel 4.0 :-)
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/install-linux-kernel-4-0-elrepo-source/
作者:[Arun Pyasi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/arunp/
[1]:http://lkml.iu.edu/hypermail/linux/kernel/1504.1/03198.html
[2]:http://elrepo.org/tiki/SecureBootKey
[3]:http://kernel.org/

View File

@ -0,0 +1,93 @@
sshuttle A transparent proxy-based VPN using ssh
================================================================================
sshuttle allows you to create a VPN connection from your machine to any remote server that you can connect to via ssh, as long as that server has python 2.3 or higher.To work, you must have root access on the local machine, but you can have a normal account on the server.
It's valid to run sshuttle more than once simultaneously on a single client machine, connecting to a different server every time, so you can be on more than one VPN at once.If run on a router, sshuttle can forward traffic for your entire subnet to the VPN.
### Install sshuttle on ubuntu ###
Open the terminal and run the following command
sudo apt-get install sshuttle
### Using sshuttle ###
#### sshuttle Syntax ####
sshuttle [options...] [-r [username@]sshserver[:port]] [subnets]
#### Option details ####
-r, —remote=[username@]sshserver[:port]
the remote hostname and optional username and ssh port number to use for connecting to the remote server. For example,example.com, testuser@example.com, testuser@example.com:2222, or example.com:2244.
#### sshuttle Examples ####
From the machine use the following command
sudo sshuttle -r username@sshserver 0.0.0.0/0 -vv
When it starts, sshuttle creates an ssh session to the server specified by the -r option. If -r is omitted, it will start both its client and server locally, which is sometimes useful for testing.
After connecting to the remote server, sshuttle uploads its (python) source code to the remote end and executes it there. Thus, you don't need to install sshuttle on the remote server, and there are never sshuttle version conflicts between client and server.
#### More Examples From Man page ####
Test locally by proxying all local connections, without using ssh:
$ sudo sshuttle -v 0/0
Starting sshuttle proxy.
Listening on (0.0.0.0, 12300).
[local sudo] Password:
firewall manager ready.
c : connecting to server...
s: available routes:
s: 192.168.42.0/24
c : connected.
firewall manager: starting transproxy.
c : Accept: 192.168.42.106':50035 -> 192.168.42.121':139.
c : Accept: 192.168.42.121':47523 -> 77.141.99.22':443.
...etc...
^C
firewall manager: undoing changes.
KeyboardInterrupt
c : Keyboard interrupt: exiting.
c : SW#8:192.168.42.121:47523: deleting
c : SW#6:192.168.42.106:50035: deleting
Test connection to a remote server, with automatic hostname and subnet
guessing:
$ sudo sshuttle -vNHr example.org
Starting sshuttle proxy.
Listening on (0.0.0.0, 12300).
firewall manager ready.
c : connecting to server...
s: available routes:
s: 77.141.99.0/24
c : connected.
c : seed_hosts: []
firewall manager: starting transproxy.
hostwatch: Found: testbox1: 1.2.3.4
hostwatch: Found: mytest2: 5.6.7.8
hostwatch: Found: domaincontroller: 99.1.2.3
c : Accept: 192.168.42.121':60554 -> 77.141.99.22':22.
^C
firewall manager: undoing changes.
c : Keyboard interrupt: exiting.
c : SW#6:192.168.42.121:60554: deleting
--------------------------------------------------------------------------------
via: http://www.ubuntugeek.com/sshuttle-a-transparent-proxy-based-vpn-using-ssh.html
作者:[ruchi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.ubuntugeek.com/author/ubuntufix